Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

XserverDesktop.h 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. * Copyright 2009-2011 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 <rfb/SDesktop.h>
  29. #include <rfb/HTTPServer.h>
  30. #include <rfb/PixelBuffer.h>
  31. #include <rfb/Configuration.h>
  32. #include <rfb/VNCServerST.h>
  33. #include <rdr/SubstitutingInStream.h>
  34. #include "Input.h"
  35. extern "C" {
  36. #define class c_class
  37. #include <scrnintstr.h>
  38. #include <os.h>
  39. #ifdef RANDR
  40. #include <randrstr.h>
  41. #endif
  42. #undef class
  43. }
  44. namespace rfb {
  45. class VNCServerST;
  46. }
  47. namespace network { class TcpListener; class Socket; }
  48. class XserverDesktop : public rfb::SDesktop, public rfb::FullFramePixelBuffer,
  49. public rdr::Substitutor,
  50. public rfb::VNCServerST::QueryConnectionHandler {
  51. public:
  52. XserverDesktop(ScreenPtr pScreen, network::TcpListener* listener,
  53. network::TcpListener* httpListener_,
  54. const char* name, const rfb::PixelFormat &pf,
  55. void* fbptr, int stride);
  56. virtual ~XserverDesktop();
  57. // methods called from X server code
  58. void blockUpdates();
  59. void unblockUpdates();
  60. void setFramebuffer(int w, int h, void* fbptr, int stride);
  61. void refreshScreenLayout();
  62. void bell();
  63. void serverCutText(const char* str, int len);
  64. void setDesktopName(const char* name);
  65. void setCursor(CursorPtr cursor);
  66. void add_changed(RegionPtr reg);
  67. void add_copied(RegionPtr dst, int dx, int dy);
  68. void ignoreHooks(bool b) { ignoreHooks_ = b; }
  69. void blockHandler(fd_set* fds, OSTimePtr timeout);
  70. void wakeupHandler(fd_set* fds, int nfds);
  71. void writeBlockHandler(fd_set* fds);
  72. void writeWakeupHandler(fd_set* fds, int nfds);
  73. void addClient(network::Socket* sock, bool reverse);
  74. void disconnectClients();
  75. // QueryConnect methods called from X server code
  76. // getQueryTimeout()
  77. // Returns the timeout associated with a particular
  78. // connection, identified by an opaque Id passed to the
  79. // X code earlier. Also optionally gets the address and
  80. // name associated with that connection.
  81. // Returns zero if the Id is not recognised.
  82. int getQueryTimeout(void* opaqueId,
  83. const char** address=0,
  84. const char** username=0);
  85. // approveConnection()
  86. // Used by X server code to supply the result of a query.
  87. void approveConnection(void* opaqueId, bool accept,
  88. const char* rejectMsg=0);
  89. // rfb::SDesktop callbacks
  90. virtual void pointerEvent(const rfb::Point& pos, int buttonMask);
  91. virtual void keyEvent(rdr::U32 key, bool down);
  92. virtual void clientCutText(const char* str, int len);
  93. virtual rfb::Point getFbSize() { return rfb::Point(width(), height()); }
  94. virtual unsigned int setScreenLayout(int fb_width, int fb_height,
  95. const rfb::ScreenSet& layout);
  96. // rfb::PixelBuffer callbacks
  97. virtual void grabRegion(const rfb::Region& r);
  98. // rdr::Substitutor callback
  99. virtual char* substitute(const char* varName);
  100. // rfb::VNCServerST::QueryConnectionHandler callback
  101. virtual rfb::VNCServerST::queryResult queryConnection(network::Socket* sock,
  102. const char* userName,
  103. char** reason);
  104. private:
  105. rfb::ScreenSet computeScreenLayout();
  106. #ifdef RANDR
  107. RRModePtr findRandRMode(RROutputPtr output, int width, int height);
  108. #endif
  109. ScreenPtr pScreen;
  110. InputDevice *inputDevice;
  111. rfb::VNCServerST* server;
  112. rfb::HTTPServer* httpServer;
  113. network::TcpListener* listener;
  114. network::TcpListener* httpListener;
  115. bool deferredUpdateTimerSet;
  116. bool grabbing;
  117. bool ignoreHooks_;
  118. bool directFbptr;
  119. void* queryConnectId;
  120. rfb::CharArray queryConnectAddress;
  121. rfb::CharArray queryConnectUsername;
  122. #ifdef RANDR
  123. typedef std::map<RROutputPtr, rdr::U32> OutputIdMap;
  124. OutputIdMap outputIdMap;
  125. #endif
  126. };
  127. #endif