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.

SDisplay.h 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. *
  3. * This is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This software is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this software; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  16. * USA.
  17. */
  18. // -=- SDisplay.h
  19. //
  20. // The SDisplay class encapsulates a system display.
  21. #ifndef __RFB_SDISPLAY_H__
  22. #define __RFB_SDISPLAY_H__
  23. #include <rfb/SDesktop.h>
  24. #include <rfb/UpdateTracker.h>
  25. #include <rfb/Configuration.h>
  26. #include <rfb_win32/Handle.h>
  27. #include <rfb_win32/EventManager.h>
  28. #include <rfb_win32/SInput.h>
  29. #include <rfb_win32/Clipboard.h>
  30. #include <rfb_win32/CleanDesktop.h>
  31. #include <rfb_win32/WMCursor.h>
  32. #include <rfb_win32/WMNotifier.h>
  33. #include <rfb_win32/DeviceFrameBuffer.h>
  34. #include <rfb_win32/DeviceContext.h>
  35. namespace rfb {
  36. namespace win32 {
  37. //
  38. // -=- SDisplay
  39. //
  40. class SDisplayCore {
  41. public:
  42. virtual ~SDisplayCore() {};
  43. virtual void setScreenRect(const Rect& screenRect_) = 0;
  44. virtual void flushUpdates() = 0;
  45. virtual const char* methodName() const = 0;
  46. };
  47. class QueryConnectionHandler {
  48. public:
  49. virtual ~QueryConnectionHandler() {}
  50. virtual void queryConnection(network::Socket* sock,
  51. const char* userName) = 0;
  52. };
  53. class SDisplay : public SDesktop,
  54. WMMonitor::Notifier,
  55. Clipboard::Notifier,
  56. public EventHandler
  57. {
  58. public:
  59. SDisplay();
  60. virtual ~SDisplay();
  61. // -=- SDesktop interface
  62. virtual void start(VNCServer* vs);
  63. virtual void stop();
  64. virtual void terminate();
  65. virtual void queryConnection(network::Socket* sock,
  66. const char* userName);
  67. virtual void pointerEvent(const Point& pos, int buttonmask);
  68. virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
  69. virtual void clientCutText(const char* str, int len);
  70. // -=- Clipboard
  71. virtual void notifyClipboardChanged(const char* text, int len);
  72. // -=- Display events
  73. virtual void notifyDisplayEvent(WMMonitor::Notifier::DisplayEventType evt);
  74. // -=- EventHandler interface
  75. HANDLE getUpdateEvent() {return updateEvent;}
  76. HANDLE getTerminateEvent() {return terminateEvent;}
  77. virtual void processEvent(HANDLE event);
  78. // -=- Notification of whether or not SDisplay is started
  79. void setStatusLocation(bool* status) {statusLocation = status;}
  80. // -=- Set handler for incoming connections
  81. void setQueryConnectionHandler(QueryConnectionHandler* qch) {
  82. queryConnectionHandler = qch;
  83. }
  84. static IntParameter updateMethod;
  85. static BoolParameter disableLocalInputs;
  86. static StringParameter disconnectAction;
  87. static BoolParameter removeWallpaper;
  88. static BoolParameter disableEffects;
  89. // -=- Use by VNC Config to determine whether hooks are available
  90. static bool areHooksAvailable();
  91. protected:
  92. bool isRestartRequired();
  93. void startCore();
  94. void stopCore();
  95. void restartCore();
  96. void recreatePixelBuffer(bool force=false);
  97. bool flushChangeTracker(); // true if flushed, false if empty
  98. bool checkLedState();
  99. VNCServer* server;
  100. // -=- Display pixel buffer
  101. DeviceFrameBuffer* pb;
  102. DeviceContext* device;
  103. // -=- The coordinates of Window's entire virtual Screen
  104. Rect screenRect;
  105. // -=- All changes are collected in UN-CLIPPED Display coords and merged
  106. // When they are to be flushed to the VNCServer, they are changed
  107. // to server coords and clipped appropriately.
  108. SimpleUpdateTracker updates;
  109. ClippingUpdateTracker clipper;
  110. // -=- Internal SDisplay implementation
  111. SDisplayCore* core;
  112. int updateMethod_;
  113. // Inputs
  114. SPointer* ptr;
  115. SKeyboard* kbd;
  116. Clipboard* clipboard;
  117. WMBlockInput* inputs;
  118. // Desktop state
  119. WMMonitor* monitor;
  120. // Desktop optimisation
  121. CleanDesktop* cleanDesktop;
  122. bool isWallpaperRemoved;
  123. bool areEffectsDisabled;
  124. // Cursor
  125. WMCursor* cursor;
  126. WMCursor::Info old_cursor;
  127. Region old_cursor_region;
  128. Point cursor_renderpos;
  129. // -=- Event signalled to trigger an update to be flushed
  130. Handle updateEvent;
  131. // -=- Event signalled to terminate the server
  132. Handle terminateEvent;
  133. // -=- Where to write the active/inactive indicator to
  134. bool* statusLocation;
  135. // -=- Whom to query incoming connections
  136. QueryConnectionHandler* queryConnectionHandler;
  137. unsigned ledState;
  138. };
  139. }
  140. }
  141. #endif // __RFB_SDISPLAY_H__