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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. * Copyright 2011-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. // -=- SDisplay.h
  20. //
  21. // The SDisplay class encapsulates a system display.
  22. #ifndef __RFB_SDISPLAY_H__
  23. #define __RFB_SDISPLAY_H__
  24. #include <rfb/SDesktop.h>
  25. #include <rfb/UpdateTracker.h>
  26. #include <rfb/Configuration.h>
  27. #include <rfb_win32/Handle.h>
  28. #include <rfb_win32/EventManager.h>
  29. #include <rfb_win32/SInput.h>
  30. #include <rfb_win32/Clipboard.h>
  31. #include <rfb_win32/CleanDesktop.h>
  32. #include <rfb_win32/WMCursor.h>
  33. #include <rfb_win32/WMNotifier.h>
  34. #include <rfb_win32/DeviceFrameBuffer.h>
  35. #include <rfb_win32/DeviceContext.h>
  36. namespace rfb {
  37. namespace win32 {
  38. //
  39. // -=- SDisplay
  40. //
  41. class SDisplayCore {
  42. public:
  43. virtual ~SDisplayCore() {};
  44. virtual void setScreenRect(const Rect& screenRect_) = 0;
  45. virtual void flushUpdates() = 0;
  46. virtual const char* methodName() const = 0;
  47. };
  48. class QueryConnectionHandler {
  49. public:
  50. virtual ~QueryConnectionHandler() {}
  51. virtual void queryConnection(network::Socket* sock,
  52. const char* userName) = 0;
  53. };
  54. class SDisplay : public SDesktop,
  55. WMMonitor::Notifier,
  56. Clipboard::Notifier,
  57. public EventHandler
  58. {
  59. public:
  60. SDisplay();
  61. virtual ~SDisplay();
  62. // -=- SDesktop interface
  63. virtual void start(VNCServer* vs);
  64. virtual void stop();
  65. virtual void terminate();
  66. virtual void queryConnection(network::Socket* sock,
  67. const char* userName);
  68. virtual void handleClipboardRequest();
  69. virtual void handleClipboardAnnounce(bool available);
  70. virtual void handleClipboardData(const char* data);
  71. virtual void pointerEvent(const Point& pos, int buttonmask);
  72. virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
  73. // -=- Clipboard events
  74. virtual void notifyClipboardChanged(bool available);
  75. // -=- Display events
  76. virtual void notifyDisplayEvent(WMMonitor::Notifier::DisplayEventType evt);
  77. // -=- EventHandler interface
  78. HANDLE getUpdateEvent() {return updateEvent;}
  79. HANDLE getTerminateEvent() {return terminateEvent;}
  80. virtual void processEvent(HANDLE event);
  81. // -=- Notification of whether or not SDisplay is started
  82. void setStatusLocation(bool* status) {statusLocation = status;}
  83. // -=- Set handler for incoming connections
  84. void setQueryConnectionHandler(QueryConnectionHandler* qch) {
  85. queryConnectionHandler = qch;
  86. }
  87. static IntParameter updateMethod;
  88. static BoolParameter disableLocalInputs;
  89. static StringParameter disconnectAction;
  90. static BoolParameter removeWallpaper;
  91. static BoolParameter disableEffects;
  92. // -=- Use by VNC Config to determine whether hooks are available
  93. static bool areHooksAvailable();
  94. protected:
  95. bool isRestartRequired();
  96. void startCore();
  97. void stopCore();
  98. void restartCore();
  99. void recreatePixelBuffer(bool force=false);
  100. bool flushChangeTracker(); // true if flushed, false if empty
  101. bool checkLedState();
  102. VNCServer* server;
  103. // -=- Display pixel buffer
  104. DeviceFrameBuffer* pb;
  105. DeviceContext* device;
  106. // -=- The coordinates of Window's entire virtual Screen
  107. Rect screenRect;
  108. // -=- All changes are collected in UN-CLIPPED Display coords and merged
  109. // When they are to be flushed to the VNCServer, they are changed
  110. // to server coords and clipped appropriately.
  111. SimpleUpdateTracker updates;
  112. ClippingUpdateTracker clipper;
  113. // -=- Internal SDisplay implementation
  114. SDisplayCore* core;
  115. int updateMethod_;
  116. // Inputs
  117. SPointer* ptr;
  118. SKeyboard* kbd;
  119. Clipboard* clipboard;
  120. WMBlockInput* inputs;
  121. // Desktop state
  122. WMMonitor* monitor;
  123. // Desktop optimisation
  124. CleanDesktop* cleanDesktop;
  125. bool isWallpaperRemoved;
  126. bool areEffectsDisabled;
  127. // Cursor
  128. WMCursor* cursor;
  129. WMCursor::Info old_cursor;
  130. Region old_cursor_region;
  131. Point cursor_renderpos;
  132. // -=- Event signalled to trigger an update to be flushed
  133. Handle updateEvent;
  134. // -=- Event signalled to terminate the server
  135. Handle terminateEvent;
  136. // -=- Where to write the active/inactive indicator to
  137. bool* statusLocation;
  138. // -=- Whom to query incoming connections
  139. QueryConnectionHandler* queryConnectionHandler;
  140. unsigned ledState;
  141. };
  142. }
  143. }
  144. #endif // __RFB_SDISPLAY_H__