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.

XserverDesktop.h 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. * Copyright 2009-2019 Pierre Ossman for Cendio AB
  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. // XserverDesktop.h
  21. //
  22. #ifndef __XSERVERDESKTOP_H__
  23. #define __XSERVERDESKTOP_H__
  24. #ifdef HAVE_DIX_CONFIG_H
  25. #include <dix-config.h>
  26. #endif
  27. #include <map>
  28. #include <stdint.h>
  29. #include <rfb/SDesktop.h>
  30. #include <rfb/PixelBuffer.h>
  31. #include <rfb/Configuration.h>
  32. #include <rfb/Timer.h>
  33. #include <unixcommon.h>
  34. #include "Input.h"
  35. namespace rfb {
  36. class VNCServerST;
  37. }
  38. namespace network { class SocketListener; class Socket; class SocketServer; }
  39. class XserverDesktop : public rfb::SDesktop, public rfb::FullFramePixelBuffer,
  40. public rfb::Timer::Callback {
  41. public:
  42. XserverDesktop(int screenIndex,
  43. std::list<network::SocketListener*> listeners_,
  44. const char* name, const rfb::PixelFormat &pf,
  45. int width, int height, void* fbptr, int stride);
  46. virtual ~XserverDesktop();
  47. // methods called from X server code
  48. void blockUpdates();
  49. void unblockUpdates();
  50. void setFramebuffer(int w, int h, void* fbptr, int stride);
  51. void refreshScreenLayout();
  52. void requestClipboard();
  53. void announceClipboard(bool available);
  54. void sendClipboardData(const char* data);
  55. void bell();
  56. void setLEDState(unsigned int state);
  57. void setDesktopName(const char* name);
  58. void setCursor(int width, int height, int hotX, int hotY,
  59. const unsigned char *rgbaData);
  60. void add_changed(const rfb::Region &region);
  61. void add_copied(const rfb::Region &dest, const rfb::Point &delta);
  62. void handleSocketEvent(int fd, bool read, bool write);
  63. void blockHandler(int* timeout);
  64. void addClient(network::Socket* sock, bool reverse);
  65. void disconnectClients();
  66. // QueryConnect methods called from X server code
  67. // getQueryConnect()
  68. // Returns information about the currently waiting query
  69. // (or an id of 0 if there is none waiting)
  70. void getQueryConnect(uint32_t* opaqueId, const char** address,
  71. const char** username, int *timeout);
  72. // approveConnection()
  73. // Used by X server code to supply the result of a query.
  74. void approveConnection(uint32_t opaqueId, bool accept,
  75. const char* rejectMsg=0);
  76. // rfb::SDesktop callbacks
  77. virtual void start(rfb::VNCServer* vs);
  78. virtual void stop();
  79. virtual void terminate();
  80. virtual void queryConnection(network::Socket* sock,
  81. const char* userName);
  82. virtual void pointerEvent(const rfb::Point& pos, int buttonMask);
  83. virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
  84. virtual unsigned int setScreenLayout(int fb_width, int fb_height,
  85. const rfb::ScreenSet& layout);
  86. virtual void handleClipboardRequest();
  87. virtual void handleClipboardAnnounce(bool available);
  88. virtual void handleClipboardData(const char* data);
  89. // rfb::PixelBuffer callbacks
  90. virtual void grabRegion(const rfb::Region& r);
  91. protected:
  92. bool handleListenerEvent(int fd,
  93. std::list<network::SocketListener*>* sockets,
  94. network::SocketServer* sockserv);
  95. bool handleSocketEvent(int fd,
  96. network::SocketServer* sockserv,
  97. bool read, bool write);
  98. virtual bool handleTimeout(rfb::Timer* t);
  99. private:
  100. int screenIndex;
  101. rfb::VNCServer* server;
  102. std::list<network::SocketListener*> listeners;
  103. bool directFbptr;
  104. uint32_t queryConnectId;
  105. network::Socket* queryConnectSocket;
  106. rfb::CharArray queryConnectAddress;
  107. rfb::CharArray queryConnectUsername;
  108. rfb::Timer queryConnectTimer;
  109. OutputIdMap outputIdMap;
  110. rfb::Point oldCursorPos;
  111. };
  112. #endif