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. |
Peter Åstrand (astrand) | 3a1db16 | 2017-10-16 11:11:45 +0200 | [diff] [blame] | 3 | * Copyright 2017 Peter Astrand <astrand@cendio.se> for Cendio AB |
Peter Åstrand (astrand) | 3112f50 | 2017-10-10 12:27:38 +0200 | [diff] [blame] | 4 | * |
| 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 Ossman | cd7931d | 2018-10-05 17:48:58 +0200 | [diff] [blame] | 24 | #include <rfb/SDesktop.h> |
Peter Åstrand (astrand) | 3112f50 | 2017-10-10 12:27:38 +0200 | [diff] [blame] | 25 | #include <tx/TXWindow.h> |
Peter Åstrand (astrand) | 242c5b2 | 2018-03-07 13:00:47 +0100 | [diff] [blame] | 26 | #include <unixcommon.h> |
Peter Åstrand (astrand) | 3112f50 | 2017-10-10 12:27:38 +0200 | [diff] [blame] | 27 | |
| 28 | #include <X11/XKBlib.h> |
| 29 | #ifdef HAVE_XDAMAGE |
| 30 | #include <X11/extensions/Xdamage.h> |
| 31 | #endif |
| 32 | |
Pierre Ossman | eef6c9a | 2018-10-05 17:11:25 +0200 | [diff] [blame] | 33 | #include <vncconfig/QueryConnectDialog.h> |
| 34 | |
Peter Åstrand (astrand) | 3112f50 | 2017-10-10 12:27:38 +0200 | [diff] [blame] | 35 | class Geometry; |
| 36 | class XPixelBuffer; |
| 37 | |
| 38 | // number of XKb indicator leds to handle |
| 39 | #define XDESKTOP_N_LEDS 3 |
| 40 | |
Pierre Ossman | eef6c9a | 2018-10-05 17:11:25 +0200 | [diff] [blame] | 41 | class XDesktop : public rfb::SDesktop, |
| 42 | public TXGlobalEventHandler, |
| 43 | public QueryResultCallback |
Peter Åstrand (astrand) | 3112f50 | 2017-10-10 12:27:38 +0200 | [diff] [blame] | 44 | { |
| 45 | public: |
| 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 Ossman | eef6c9a | 2018-10-05 17:11:25 +0200 | [diff] [blame] | 53 | virtual void queryConnection(network::Socket* sock, |
| 54 | const char* userName); |
Peter Åstrand (astrand) | 3112f50 | 2017-10-10 12:27:38 +0200 | [diff] [blame] | 55 | 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) | 242c5b2 | 2018-03-07 13:00:47 +0100 | [diff] [blame] | 59 | virtual unsigned int setScreenLayout(int fb_width, int fb_height, |
| 60 | const rfb::ScreenSet& layout); |
| 61 | |
Peter Åstrand (astrand) | 3112f50 | 2017-10-10 12:27:38 +0200 | [diff] [blame] | 62 | // -=- TXGlobalEventHandler interface |
| 63 | virtual bool handleGlobalEvent(XEvent* ev); |
| 64 | |
Pierre Ossman | eef6c9a | 2018-10-05 17:11:25 +0200 | [diff] [blame] | 65 | // -=- QueryResultCallback interface |
| 66 | virtual void queryApproved(); |
| 67 | virtual void queryRejected(); |
| 68 | |
Peter Åstrand (astrand) | 3112f50 | 2017-10-10 12:27:38 +0200 | [diff] [blame] | 69 | protected: |
| 70 | Display* dpy; |
| 71 | Geometry* geometry; |
| 72 | XPixelBuffer* pb; |
Pierre Ossman | cd7931d | 2018-10-05 17:48:58 +0200 | [diff] [blame] | 73 | rfb::VNCServer* server; |
Pierre Ossman | eef6c9a | 2018-10-05 17:11:25 +0200 | [diff] [blame] | 74 | QueryConnectDialog* queryConnectDialog; |
| 75 | network::Socket* queryConnectSock; |
Peter Åstrand (astrand) | 3112f50 | 2017-10-10 12:27:38 +0200 | [diff] [blame] | 76 | 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) | 242c5b2 | 2018-03-07 13:00:47 +0100 | [diff] [blame] | 90 | #ifdef HAVE_XRANDR |
| 91 | int xrandrEventBase; |
| 92 | OutputIdMap outputIdMap; |
| 93 | unsigned long randrSyncSerial; |
| 94 | #endif |
Peter Åstrand (astrand) | 3112f50 | 2017-10-10 12:27:38 +0200 | [diff] [blame] | 95 | int ledMasks[XDESKTOP_N_LEDS]; |
| 96 | unsigned ledState; |
| 97 | const unsigned short *codeMap; |
| 98 | unsigned codeMapLen; |
Peter Åstrand (astrand) | 3abc7d4 | 2017-10-11 15:12:10 +0200 | [diff] [blame] | 99 | bool setCursor(); |
Peter Åstrand (astrand) | 242c5b2 | 2018-03-07 13:00:47 +0100 | [diff] [blame] | 100 | rfb::ScreenSet computeScreenLayout(); |
Peter Åstrand (astrand) | 3112f50 | 2017-10-10 12:27:38 +0200 | [diff] [blame] | 101 | }; |
| 102 | |
| 103 | #endif // __XDESKTOP_H__ |