Peter Åstrand (astrand) | 3112f50 | 2017-10-10 12:27:38 +0200 | [diff] [blame] | 1 | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. |
| 2 | * Copyright (C) 2004-2008 Constantin Kaplinsky. All Rights Reserved. |
| 3 | * |
| 4 | * This is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This software is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this software; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 17 | * USA. |
| 18 | */ |
| 19 | |
| 20 | #ifndef __XDESKTOP_H__ |
| 21 | #define __XDESKTOP_H__ |
| 22 | |
| 23 | #include <rfb/VNCServerST.h> |
| 24 | #include <tx/TXWindow.h> |
| 25 | |
| 26 | #include <X11/XKBlib.h> |
| 27 | #ifdef HAVE_XDAMAGE |
| 28 | #include <X11/extensions/Xdamage.h> |
| 29 | #endif |
| 30 | |
| 31 | class Geometry; |
| 32 | class XPixelBuffer; |
| 33 | |
| 34 | // number of XKb indicator leds to handle |
| 35 | #define XDESKTOP_N_LEDS 3 |
| 36 | |
| 37 | class XDesktop : public rfb::SDesktop, public TXGlobalEventHandler |
| 38 | { |
| 39 | public: |
| 40 | XDesktop(Display* dpy_, Geometry *geometry); |
| 41 | virtual ~XDesktop(); |
| 42 | void poll(); |
| 43 | // -=- SDesktop interface |
| 44 | virtual void start(rfb::VNCServer* vs); |
| 45 | virtual void stop(); |
| 46 | bool isRunning(); |
| 47 | virtual void pointerEvent(const rfb::Point& pos, int buttonMask); |
| 48 | KeyCode XkbKeysymToKeycode(Display* dpy, KeySym keysym); |
| 49 | virtual void keyEvent(rdr::U32 keysym, rdr::U32 xtcode, bool down); |
| 50 | virtual void clientCutText(const char* str, int len); |
| 51 | // -=- TXGlobalEventHandler interface |
| 52 | virtual bool handleGlobalEvent(XEvent* ev); |
| 53 | |
| 54 | protected: |
| 55 | Display* dpy; |
| 56 | Geometry* geometry; |
| 57 | XPixelBuffer* pb; |
| 58 | rfb::VNCServerST* server; |
| 59 | int oldButtonMask; |
| 60 | bool haveXtest; |
| 61 | bool haveDamage; |
| 62 | int maxButtons; |
| 63 | std::map<KeySym, KeyCode> pressedKeys; |
| 64 | bool running; |
| 65 | #ifdef HAVE_XDAMAGE |
| 66 | Damage damage; |
| 67 | int xdamageEventBase; |
| 68 | #endif |
| 69 | int xkbEventBase; |
| 70 | #ifdef HAVE_XFIXES |
| 71 | int xfixesEventBase; |
| 72 | #endif |
| 73 | int ledMasks[XDESKTOP_N_LEDS]; |
| 74 | unsigned ledState; |
| 75 | const unsigned short *codeMap; |
| 76 | unsigned codeMapLen; |
| 77 | }; |
| 78 | |
| 79 | #endif // __XDESKTOP_H__ |