blob: dc616e942bc522466195bdf8578ac1a7cb1612bf [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
24#include <rfb/VNCServerST.h>
25#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();
52 bool isRunning();
Pierre Ossmaneef6c9a2018-10-05 17:11:25 +020053 virtual void queryConnection(network::Socket* sock,
54 const char* userName);
Peter Åstrand (astrand)3112f502017-10-10 12:27:38 +020055 virtual void pointerEvent(const rfb::Point& pos, int buttonMask);
56 KeyCode XkbKeysymToKeycode(Display* dpy, KeySym keysym);
57 virtual void keyEvent(rdr::U32 keysym, rdr::U32 xtcode, bool down);
58 virtual void clientCutText(const char* str, int len);
Peter Åstrand (astrand)242c5b22018-03-07 13:00:47 +010059 virtual unsigned int setScreenLayout(int fb_width, int fb_height,
60 const rfb::ScreenSet& layout);
61
Peter Åstrand (astrand)3112f502017-10-10 12:27:38 +020062 // -=- TXGlobalEventHandler interface
63 virtual bool handleGlobalEvent(XEvent* ev);
64
Pierre Ossmaneef6c9a2018-10-05 17:11:25 +020065 // -=- QueryResultCallback interface
66 virtual void queryApproved();
67 virtual void queryRejected();
68
Peter Åstrand (astrand)3112f502017-10-10 12:27:38 +020069protected:
70 Display* dpy;
71 Geometry* geometry;
72 XPixelBuffer* pb;
73 rfb::VNCServerST* server;
Pierre Ossmaneef6c9a2018-10-05 17:11:25 +020074 QueryConnectDialog* queryConnectDialog;
75 network::Socket* queryConnectSock;
Peter Åstrand (astrand)3112f502017-10-10 12:27:38 +020076 int oldButtonMask;
77 bool haveXtest;
78 bool haveDamage;
79 int maxButtons;
80 std::map<KeySym, KeyCode> pressedKeys;
81 bool running;
82#ifdef HAVE_XDAMAGE
83 Damage damage;
84 int xdamageEventBase;
85#endif
86 int xkbEventBase;
87#ifdef HAVE_XFIXES
88 int xfixesEventBase;
89#endif
Peter Åstrand (astrand)242c5b22018-03-07 13:00:47 +010090#ifdef HAVE_XRANDR
91 int xrandrEventBase;
92 OutputIdMap outputIdMap;
93 unsigned long randrSyncSerial;
94#endif
Peter Åstrand (astrand)3112f502017-10-10 12:27:38 +020095 int ledMasks[XDESKTOP_N_LEDS];
96 unsigned ledState;
97 const unsigned short *codeMap;
98 unsigned codeMapLen;
Peter Åstrand (astrand)3abc7d42017-10-11 15:12:10 +020099 bool setCursor();
Peter Åstrand (astrand)242c5b22018-03-07 13:00:47 +0100100 rfb::ScreenSet computeScreenLayout();
Peter Åstrand (astrand)3112f502017-10-10 12:27:38 +0200101};
102
103#endif // __XDESKTOP_H__