blob: ff52c0149d7f2f82f177059783c11722ab38f51b [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
33class Geometry;
34class XPixelBuffer;
35
36// number of XKb indicator leds to handle
37#define XDESKTOP_N_LEDS 3
38
39class XDesktop : public rfb::SDesktop, public TXGlobalEventHandler
40{
41public:
42 XDesktop(Display* dpy_, Geometry *geometry);
43 virtual ~XDesktop();
44 void poll();
45 // -=- SDesktop interface
46 virtual void start(rfb::VNCServer* vs);
47 virtual void stop();
48 bool isRunning();
49 virtual void pointerEvent(const rfb::Point& pos, int buttonMask);
50 KeyCode XkbKeysymToKeycode(Display* dpy, KeySym keysym);
51 virtual void keyEvent(rdr::U32 keysym, rdr::U32 xtcode, bool down);
52 virtual void clientCutText(const char* str, int len);
Peter Åstrand (astrand)242c5b22018-03-07 13:00:47 +010053 virtual unsigned int setScreenLayout(int fb_width, int fb_height,
54 const rfb::ScreenSet& layout);
55
Peter Åstrand (astrand)3112f502017-10-10 12:27:38 +020056 // -=- TXGlobalEventHandler interface
57 virtual bool handleGlobalEvent(XEvent* ev);
58
59protected:
60 Display* dpy;
61 Geometry* geometry;
62 XPixelBuffer* pb;
63 rfb::VNCServerST* server;
64 int oldButtonMask;
65 bool haveXtest;
66 bool haveDamage;
67 int maxButtons;
68 std::map<KeySym, KeyCode> pressedKeys;
69 bool running;
70#ifdef HAVE_XDAMAGE
71 Damage damage;
72 int xdamageEventBase;
73#endif
74 int xkbEventBase;
75#ifdef HAVE_XFIXES
76 int xfixesEventBase;
77#endif
Peter Åstrand (astrand)242c5b22018-03-07 13:00:47 +010078#ifdef HAVE_XRANDR
79 int xrandrEventBase;
80 OutputIdMap outputIdMap;
81 unsigned long randrSyncSerial;
82#endif
Peter Åstrand (astrand)3112f502017-10-10 12:27:38 +020083 int ledMasks[XDESKTOP_N_LEDS];
84 unsigned ledState;
85 const unsigned short *codeMap;
86 unsigned codeMapLen;
Peter Åstrand (astrand)3abc7d42017-10-11 15:12:10 +020087 bool setCursor();
Peter Åstrand (astrand)242c5b22018-03-07 13:00:47 +010088 rfb::ScreenSet computeScreenLayout();
Peter Åstrand (astrand)3112f502017-10-10 12:27:38 +020089};
90
91#endif // __XDESKTOP_H__