blob: 3e85aac3bffac1d296a5dce2bc57a74a930f8332 [file] [log] [blame]
Peter Åstrand (astrand)3112f502017-10-10 12:27:38 +02001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
2 * Copyright (C) 2004-2008 Constantin Kaplinsky. All Rights Reserved.
Peter Åstrand (astrand)3a1db162017-10-16 11:11:45 +02003 * Copyright 2017 Peter Astrand <astrand@cendio.se> for Cendio AB
Peter Åstrand (astrand)3112f502017-10-10 12:27:38 +02004 *
5 * This is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This software is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this software; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18 * USA.
19 */
20
21#ifndef __XDESKTOP_H__
22#define __XDESKTOP_H__
23
Pierre Ossmancd7931d2018-10-05 17:48:58 +020024#include <rfb/SDesktop.h>
Peter Åstrand (astrand)3112f502017-10-10 12:27:38 +020025#include <tx/TXWindow.h>
Peter Åstrand (astrand)242c5b22018-03-07 13:00:47 +010026#include <unixcommon.h>
Peter Åstrand (astrand)3112f502017-10-10 12:27:38 +020027
28#include <X11/XKBlib.h>
29#ifdef HAVE_XDAMAGE
30#include <X11/extensions/Xdamage.h>
31#endif
32
Pierre Ossmaneef6c9a2018-10-05 17:11:25 +020033#include <vncconfig/QueryConnectDialog.h>
34
Peter Åstrand (astrand)3112f502017-10-10 12:27:38 +020035class Geometry;
36class XPixelBuffer;
37
38// number of XKb indicator leds to handle
39#define XDESKTOP_N_LEDS 3
40
Pierre Ossmaneef6c9a2018-10-05 17:11:25 +020041class XDesktop : public rfb::SDesktop,
42 public TXGlobalEventHandler,
43 public QueryResultCallback
Peter Åstrand (astrand)3112f502017-10-10 12:27:38 +020044{
45public:
46 XDesktop(Display* dpy_, Geometry *geometry);
47 virtual ~XDesktop();
48 void poll();
49 // -=- SDesktop interface
50 virtual void start(rfb::VNCServer* vs);
51 virtual void stop();
Pierre Ossman10688ef2018-09-29 11:24:19 +020052 virtual void terminate();
Peter Åstrand (astrand)3112f502017-10-10 12:27:38 +020053 bool isRunning();
Pierre Ossmaneef6c9a2018-10-05 17:11:25 +020054 virtual void queryConnection(network::Socket* sock,
55 const char* userName);
Peter Åstrand (astrand)3112f502017-10-10 12:27:38 +020056 virtual void pointerEvent(const rfb::Point& pos, int buttonMask);
57 KeyCode XkbKeysymToKeycode(Display* dpy, KeySym keysym);
58 virtual void keyEvent(rdr::U32 keysym, rdr::U32 xtcode, bool down);
59 virtual void clientCutText(const char* str, int len);
Peter Åstrand (astrand)242c5b22018-03-07 13:00:47 +010060 virtual unsigned int setScreenLayout(int fb_width, int fb_height,
61 const rfb::ScreenSet& layout);
62
Peter Åstrand (astrand)3112f502017-10-10 12:27:38 +020063 // -=- TXGlobalEventHandler interface
64 virtual bool handleGlobalEvent(XEvent* ev);
65
Pierre Ossmaneef6c9a2018-10-05 17:11:25 +020066 // -=- QueryResultCallback interface
67 virtual void queryApproved();
68 virtual void queryRejected();
69
Peter Åstrand (astrand)3112f502017-10-10 12:27:38 +020070protected:
71 Display* dpy;
72 Geometry* geometry;
73 XPixelBuffer* pb;
Pierre Ossmancd7931d2018-10-05 17:48:58 +020074 rfb::VNCServer* server;
Pierre Ossmaneef6c9a2018-10-05 17:11:25 +020075 QueryConnectDialog* queryConnectDialog;
76 network::Socket* queryConnectSock;
Peter Åstrand (astrand)3112f502017-10-10 12:27:38 +020077 int oldButtonMask;
78 bool haveXtest;
79 bool haveDamage;
80 int maxButtons;
81 std::map<KeySym, KeyCode> pressedKeys;
82 bool running;
83#ifdef HAVE_XDAMAGE
84 Damage damage;
85 int xdamageEventBase;
86#endif
87 int xkbEventBase;
88#ifdef HAVE_XFIXES
89 int xfixesEventBase;
90#endif
Peter Åstrand (astrand)242c5b22018-03-07 13:00:47 +010091#ifdef HAVE_XRANDR
92 int xrandrEventBase;
93 OutputIdMap outputIdMap;
94 unsigned long randrSyncSerial;
95#endif
Peter Åstrand (astrand)3112f502017-10-10 12:27:38 +020096 int ledMasks[XDESKTOP_N_LEDS];
97 unsigned ledState;
98 const unsigned short *codeMap;
99 unsigned codeMapLen;
Peter Åstrand (astrand)3abc7d42017-10-11 15:12:10 +0200100 bool setCursor();
Peter Åstrand (astrand)242c5b22018-03-07 13:00:47 +0100101 rfb::ScreenSet computeScreenLayout();
Peter Åstrand (astrand)3112f502017-10-10 12:27:38 +0200102};
103
104#endif // __XDESKTOP_H__