You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

XDesktop.h 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. * Copyright (C) 2004-2008 Constantin Kaplinsky. All Rights Reserved.
  3. * Copyright 2017 Peter Astrand <astrand@cendio.se> for Cendio AB
  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. #ifndef __XDESKTOP_H__
  21. #define __XDESKTOP_H__
  22. #include <rfb/SDesktop.h>
  23. #include <tx/TXWindow.h>
  24. #include <unixcommon.h>
  25. #include <X11/XKBlib.h>
  26. #ifdef HAVE_XDAMAGE
  27. #include <X11/extensions/Xdamage.h>
  28. #endif
  29. #include <vncconfig/QueryConnectDialog.h>
  30. class Geometry;
  31. class XPixelBuffer;
  32. // number of XKb indicator leds to handle
  33. #define XDESKTOP_N_LEDS 3
  34. class XDesktop : public rfb::SDesktop,
  35. public TXGlobalEventHandler,
  36. public QueryResultCallback
  37. {
  38. public:
  39. XDesktop(Display* dpy_, Geometry *geometry);
  40. virtual ~XDesktop();
  41. void poll();
  42. // -=- SDesktop interface
  43. virtual void start(rfb::VNCServer* vs);
  44. virtual void stop();
  45. virtual void terminate();
  46. bool isRunning();
  47. virtual void queryConnection(network::Socket* sock,
  48. const char* userName);
  49. virtual void pointerEvent(const rfb::Point& pos, int buttonMask);
  50. KeyCode XkbKeysymToKeycode(Display* dpy, KeySym keysym);
  51. KeyCode addKeysym(Display* dpy, KeySym keysym);
  52. void deleteAddedKeysyms(Display* dpy);
  53. KeyCode keysymToKeycode(Display* dpy, KeySym keysym);
  54. virtual void keyEvent(uint32_t keysym, uint32_t xtcode, bool down);
  55. virtual void clientCutText(const char* str);
  56. virtual unsigned int setScreenLayout(int fb_width, int fb_height,
  57. const rfb::ScreenSet& layout);
  58. // -=- TXGlobalEventHandler interface
  59. virtual bool handleGlobalEvent(XEvent* ev);
  60. // -=- QueryResultCallback interface
  61. virtual void queryApproved();
  62. virtual void queryRejected();
  63. protected:
  64. Display* dpy;
  65. Geometry* geometry;
  66. XPixelBuffer* pb;
  67. rfb::VNCServer* server;
  68. QueryConnectDialog* queryConnectDialog;
  69. network::Socket* queryConnectSock;
  70. int oldButtonMask;
  71. bool haveXtest;
  72. bool haveDamage;
  73. int maxButtons;
  74. std::map<KeySym, KeyCode> addedKeysyms;
  75. std::map<KeySym, KeyCode> pressedKeys;
  76. bool running;
  77. #ifdef HAVE_XDAMAGE
  78. Damage damage;
  79. int xdamageEventBase;
  80. #endif
  81. int xkbEventBase;
  82. #ifdef HAVE_XFIXES
  83. int xfixesEventBase;
  84. #endif
  85. #ifdef HAVE_XRANDR
  86. int xrandrEventBase;
  87. OutputIdMap outputIdMap;
  88. unsigned long randrSyncSerial;
  89. #endif
  90. int ledMasks[XDESKTOP_N_LEDS];
  91. unsigned ledState;
  92. const unsigned short *codeMap;
  93. unsigned codeMapLen;
  94. bool setCursor();
  95. rfb::ScreenSet computeScreenLayout();
  96. };
  97. #endif // __XDESKTOP_H__