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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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 pointerEvent(const Point& pos, int buttonmask);
  69. virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
  70. virtual void clientCutText(const char* str);
  71. // -=- Clipboard
  72. virtual void notifyClipboardChanged(const char* text);
  73. // -=- Display events
  74. virtual void notifyDisplayEvent(WMMonitor::Notifier::DisplayEventType evt);
  75. // -=- EventHandler interface
  76. HANDLE getUpdateEvent() {return updateEvent;}
  77. HANDLE getTerminateEvent() {return terminateEvent;}
  78. virtual void processEvent(HANDLE event);
  79. // -=- Notification of whether or not SDisplay is started
  80. void setStatusLocation(bool* status) {statusLocation = status;}
  81. // -=- Set handler for incoming connections
  82. void setQueryConnectionHandler(QueryConnectionHandler* qch) {
  83. queryConnectionHandler = qch;
  84. }
  85. static IntParameter updateMethod;
  86. static BoolParameter disableLocalInputs;
  87. static StringParameter disconnectAction;
  88. static BoolParameter removeWallpaper;
  89. static BoolParameter disableEffects;
  90. // -=- Use by VNC Config to determine whether hooks are available
  91. static bool areHooksAvailable();
  92. protected:
  93. bool isRestartRequired();
  94. void startCore();
  95. void stopCore();
  96. void restartCore();
  97. void recreatePixelBuffer(bool force=false);
  98. bool flushChangeTracker(); // true if flushed, false if empty
  99. bool checkLedState();
  100. VNCServer* server;
  101. // -=- Display pixel buffer
  102. DeviceFrameBuffer* pb;
  103. DeviceContext* device;
  104. // -=- The coordinates of Window's entire virtual Screen
  105. Rect screenRect;
  106. // -=- All changes are collected in UN-CLIPPED Display coords and merged
  107. // When they are to be flushed to the VNCServer, they are changed
  108. // to server coords and clipped appropriately.
  109. SimpleUpdateTracker updates;
  110. ClippingUpdateTracker clipper;
  111. // -=- Internal SDisplay implementation
  112. SDisplayCore* core;
  113. int updateMethod_;
  114. // Inputs
  115. SPointer* ptr;
  116. SKeyboard* kbd;
  117. Clipboard* clipboard;
  118. WMBlockInput* inputs;
  119. // Desktop state
  120. WMMonitor* monitor;
  121. // Desktop optimisation
  122. CleanDesktop* cleanDesktop;
  123. bool isWallpaperRemoved;
  124. bool areEffectsDisabled;
  125. // Cursor
  126. WMCursor* cursor;
  127. WMCursor::Info old_cursor;
  128. Region old_cursor_region;
  129. Point cursor_renderpos;
  130. // -=- Event signalled to trigger an update to be flushed
  131. Handle updateEvent;
  132. // -=- Event signalled to terminate the server
  133. Handle terminateEvent;
  134. // -=- Where to write the active/inactive indicator to
  135. bool* statusLocation;
  136. // -=- Whom to query incoming connections
  137. QueryConnectionHandler* queryConnectionHandler;
  138. unsigned ledState;
  139. };
  140. }
  141. }
  142. #endif // __RFB_SDISPLAY_H__