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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. * Copyright 2009-2015 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 bell();
  53. void setLEDState(unsigned int state);
  54. void serverCutText(const char* str);
  55. void setDesktopName(const char* name);
  56. void setCursor(int width, int height, int hotX, int hotY,
  57. const unsigned char *rgbaData);
  58. void add_changed(const rfb::Region &region);
  59. void add_copied(const rfb::Region &dest, const rfb::Point &delta);
  60. void handleSocketEvent(int fd, bool read, bool write);
  61. void blockHandler(int* timeout);
  62. void addClient(network::Socket* sock, bool reverse);
  63. void disconnectClients();
  64. // QueryConnect methods called from X server code
  65. // getQueryConnect()
  66. // Returns information about the currently waiting query
  67. // (or an id of 0 if there is none waiting)
  68. void getQueryConnect(uint32_t* opaqueId, const char** address,
  69. const char** username, int *timeout);
  70. // approveConnection()
  71. // Used by X server code to supply the result of a query.
  72. void approveConnection(uint32_t opaqueId, bool accept,
  73. const char* rejectMsg=0);
  74. // rfb::SDesktop callbacks
  75. virtual void start(rfb::VNCServer* vs);
  76. virtual void stop();
  77. virtual void terminate();
  78. virtual void queryConnection(network::Socket* sock,
  79. const char* userName);
  80. virtual void pointerEvent(const rfb::Point& pos, int buttonMask);
  81. virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
  82. virtual void clientCutText(const char* str);
  83. virtual unsigned int setScreenLayout(int fb_width, int fb_height,
  84. const rfb::ScreenSet& layout);
  85. // rfb::PixelBuffer callbacks
  86. virtual void grabRegion(const rfb::Region& r);
  87. protected:
  88. bool handleListenerEvent(int fd,
  89. std::list<network::SocketListener*>* sockets,
  90. network::SocketServer* sockserv);
  91. bool handleSocketEvent(int fd,
  92. network::SocketServer* sockserv,
  93. bool read, bool write);
  94. virtual bool handleTimeout(rfb::Timer* t);
  95. private:
  96. int screenIndex;
  97. rfb::VNCServer* server;
  98. std::list<network::SocketListener*> listeners;
  99. bool directFbptr;
  100. uint32_t queryConnectId;
  101. network::Socket* queryConnectSocket;
  102. rfb::CharArray queryConnectAddress;
  103. rfb::CharArray queryConnectUsername;
  104. rfb::Timer queryConnectTimer;
  105. OutputIdMap outputIdMap;
  106. rfb::Point oldCursorPos;
  107. };
  108. #endif