blob: 6dbfabbc0c4107aa2b9e83a80c8e3f7a70517a7c [file] [log] [blame]
Constantin Kaplinsky729598c2006-05-25 05:12:25 +00001/* 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
19// -=- SDisplay.h
20//
21// The SDisplay class encapsulates a system display.
22
23#ifndef __RFB_SDISPLAY_H__
24#define __RFB_SDISPLAY_H__
25
26#include <rfb/SDesktop.h>
27#include <rfb/UpdateTracker.h>
28#include <rfb/Configuration.h>
29#include <rfb_win32/Handle.h>
30#include <rfb_win32/EventManager.h>
31#include <rfb_win32/SInput.h>
32#include <rfb_win32/Clipboard.h>
33#include <rfb_win32/CleanDesktop.h>
34#include <rfb_win32/WMCursor.h>
35#include <rfb_win32/WMNotifier.h>
36#include <rfb_win32/DeviceFrameBuffer.h>
37#include <rfb_win32/DeviceContext.h>
38
39namespace rfb {
40
41 namespace win32 {
42
43 //
44 // -=- SDisplay
45 //
46
47 class SDisplayCore {
48 public:
49 virtual ~SDisplayCore() {};
50 virtual void setScreenRect(const Rect& screenRect_) = 0;
51 virtual void flushUpdates() = 0;
52 virtual const char* methodName() const = 0;
53 };
54
Pierre Ossmaneef6c9a2018-10-05 17:11:25 +020055 class QueryConnectionHandler {
56 public:
57 virtual ~QueryConnectionHandler() {}
58 virtual void queryConnection(network::Socket* sock,
59 const char* userName) = 0;
60 };
61
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000062 class SDisplay : public SDesktop,
63 WMMonitor::Notifier,
64 Clipboard::Notifier,
65 public EventHandler
66 {
67 public:
68 SDisplay();
69 virtual ~SDisplay();
70
71 // -=- SDesktop interface
72
73 virtual void start(VNCServer* vs);
74 virtual void stop();
Pierre Ossman10688ef2018-09-29 11:24:19 +020075 virtual void terminate();
Pierre Ossmaneef6c9a2018-10-05 17:11:25 +020076 virtual void queryConnection(network::Socket* sock,
77 const char* userName);
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000078 virtual void pointerEvent(const Point& pos, int buttonmask);
Pierre Ossman5ae28212017-05-16 14:30:38 +020079 virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000080 virtual void clientCutText(const char* str, int len);
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000081
82 // -=- Clipboard
83
84 virtual void notifyClipboardChanged(const char* text, int len);
85
86 // -=- Display events
87
88 virtual void notifyDisplayEvent(WMMonitor::Notifier::DisplayEventType evt);
89
90 // -=- EventHandler interface
91
92 HANDLE getUpdateEvent() {return updateEvent;}
Pierre Ossman10688ef2018-09-29 11:24:19 +020093 HANDLE getTerminateEvent() {return terminateEvent;}
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000094 virtual void processEvent(HANDLE event);
95
96 // -=- Notification of whether or not SDisplay is started
97
98 void setStatusLocation(bool* status) {statusLocation = status;}
99
Pierre Ossmaneef6c9a2018-10-05 17:11:25 +0200100 // -=- Set handler for incoming connections
101
102 void setQueryConnectionHandler(QueryConnectionHandler* qch) {
103 queryConnectionHandler = qch;
104 }
105
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000106 static IntParameter updateMethod;
107 static BoolParameter disableLocalInputs;
108 static StringParameter disconnectAction;
109 static BoolParameter removeWallpaper;
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000110 static BoolParameter disableEffects;
111
Pierre Ossman4ab1e5d2016-01-12 12:29:32 +0100112 // -=- Use by VNC Config to determine whether hooks are available
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000113 static bool areHooksAvailable();
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000114
115
116 protected:
117 bool isRestartRequired();
118 void startCore();
119 void stopCore();
120 void restartCore();
121 void recreatePixelBuffer(bool force=false);
122 bool flushChangeTracker(); // true if flushed, false if empty
Rahul Kalec719e4a2017-07-13 00:36:02 +0200123 bool checkLedState();
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000124
125 VNCServer* server;
126
127 // -=- Display pixel buffer
128 DeviceFrameBuffer* pb;
129 DeviceContext* device;
130
131 // -=- The coordinates of Window's entire virtual Screen
132 Rect screenRect;
133
134 // -=- All changes are collected in UN-CLIPPED Display coords and merged
135 // When they are to be flushed to the VNCServer, they are changed
136 // to server coords and clipped appropriately.
137 SimpleUpdateTracker updates;
138 ClippingUpdateTracker clipper;
139
140 // -=- Internal SDisplay implementation
141 SDisplayCore* core;
142 int updateMethod_;
143
144 // Inputs
145 SPointer* ptr;
146 SKeyboard* kbd;
147 Clipboard* clipboard;
148 WMBlockInput* inputs;
149
150 // Desktop state
151 WMMonitor* monitor;
152
153 // Desktop optimisation
154 CleanDesktop* cleanDesktop;
155 bool isWallpaperRemoved;
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000156 bool areEffectsDisabled;
157
158 // Cursor
159 WMCursor* cursor;
160 WMCursor::Info old_cursor;
161 Region old_cursor_region;
162 Point cursor_renderpos;
163
164 // -=- Event signalled to trigger an update to be flushed
165 Handle updateEvent;
Pierre Ossman10688ef2018-09-29 11:24:19 +0200166 // -=- Event signalled to terminate the server
167 Handle terminateEvent;
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000168
169 // -=- Where to write the active/inactive indicator to
170 bool* statusLocation;
Rahul Kalec719e4a2017-07-13 00:36:02 +0200171
Pierre Ossmaneef6c9a2018-10-05 17:11:25 +0200172 // -=- Whom to query incoming connections
173 QueryConnectionHandler* queryConnectionHandler;
174
Rahul Kalec719e4a2017-07-13 00:36:02 +0200175 unsigned ledState;
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000176 };
177
178 }
179}
180
181#endif // __RFB_SDISPLAY_H__