blob: c9106f8b5d7d69ca62a1b21e798b281865035752 [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>
26
27#include <X11/XKBlib.h>
28#ifdef HAVE_XDAMAGE
29#include <X11/extensions/Xdamage.h>
30#endif
31
32class Geometry;
33class XPixelBuffer;
34
35// number of XKb indicator leds to handle
36#define XDESKTOP_N_LEDS 3
37
38class XDesktop : public rfb::SDesktop, public TXGlobalEventHandler
39{
40public:
41 XDesktop(Display* dpy_, Geometry *geometry);
42 virtual ~XDesktop();
43 void poll();
44 // -=- SDesktop interface
45 virtual void start(rfb::VNCServer* vs);
46 virtual void stop();
47 bool isRunning();
48 virtual void pointerEvent(const rfb::Point& pos, int buttonMask);
49 KeyCode XkbKeysymToKeycode(Display* dpy, KeySym keysym);
50 virtual void keyEvent(rdr::U32 keysym, rdr::U32 xtcode, bool down);
51 virtual void clientCutText(const char* str, int len);
52 // -=- TXGlobalEventHandler interface
53 virtual bool handleGlobalEvent(XEvent* ev);
54
55protected:
56 Display* dpy;
57 Geometry* geometry;
58 XPixelBuffer* pb;
59 rfb::VNCServerST* server;
60 int oldButtonMask;
61 bool haveXtest;
62 bool haveDamage;
63 int maxButtons;
64 std::map<KeySym, KeyCode> pressedKeys;
65 bool running;
66#ifdef HAVE_XDAMAGE
67 Damage damage;
68 int xdamageEventBase;
69#endif
70 int xkbEventBase;
71#ifdef HAVE_XFIXES
72 int xfixesEventBase;
73#endif
74 int ledMasks[XDESKTOP_N_LEDS];
75 unsigned ledState;
76 const unsigned short *codeMap;
77 unsigned codeMapLen;
Peter Åstrand (astrand)3abc7d42017-10-11 15:12:10 +020078 bool setCursor();
Peter Åstrand (astrand)3112f502017-10-10 12:27:38 +020079};
80
81#endif // __XDESKTOP_H__