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.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. virtual void keyEvent(rdr::U32 keysym, rdr::U32 xtcode, bool down);
  52. virtual void clientCutText(const char* str);
  53. virtual unsigned int setScreenLayout(int fb_width, int fb_height,
  54. const rfb::ScreenSet& layout);
  55. // -=- TXGlobalEventHandler interface
  56. virtual bool handleGlobalEvent(XEvent* ev);
  57. // -=- QueryResultCallback interface
  58. virtual void queryApproved();
  59. virtual void queryRejected();
  60. protected:
  61. Display* dpy;
  62. Geometry* geometry;
  63. XPixelBuffer* pb;
  64. rfb::VNCServer* server;
  65. QueryConnectDialog* queryConnectDialog;
  66. network::Socket* queryConnectSock;
  67. int oldButtonMask;
  68. bool haveXtest;
  69. bool haveDamage;
  70. int maxButtons;
  71. std::map<KeySym, KeyCode> pressedKeys;
  72. bool running;
  73. #ifdef HAVE_XDAMAGE
  74. Damage damage;
  75. int xdamageEventBase;
  76. #endif
  77. int xkbEventBase;
  78. #ifdef HAVE_XFIXES
  79. int xfixesEventBase;
  80. #endif
  81. #ifdef HAVE_XRANDR
  82. int xrandrEventBase;
  83. OutputIdMap outputIdMap;
  84. unsigned long randrSyncSerial;
  85. #endif
  86. int ledMasks[XDESKTOP_N_LEDS];
  87. unsigned ledState;
  88. const unsigned short *codeMap;
  89. unsigned codeMapLen;
  90. bool setCursor();
  91. rfb::ScreenSet computeScreenLayout();
  92. };
  93. #endif // __XDESKTOP_H__