blob: 76ddf50bb81b3419036ff72f70578996d9a79bb7 [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 Ossmaneef6c9a2018-10-05 17:11:25 +020075 virtual void queryConnection(network::Socket* sock,
76 const char* userName);
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000077 virtual void pointerEvent(const Point& pos, int buttonmask);
Pierre Ossman5ae28212017-05-16 14:30:38 +020078 virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000079 virtual void clientCutText(const char* str, int len);
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000080
81 // -=- Clipboard
82
83 virtual void notifyClipboardChanged(const char* text, int len);
84
85 // -=- Display events
86
87 virtual void notifyDisplayEvent(WMMonitor::Notifier::DisplayEventType evt);
88
89 // -=- EventHandler interface
90
91 HANDLE getUpdateEvent() {return updateEvent;}
92 virtual void processEvent(HANDLE event);
93
94 // -=- Notification of whether or not SDisplay is started
95
96 void setStatusLocation(bool* status) {statusLocation = status;}
97
Pierre Ossmaneef6c9a2018-10-05 17:11:25 +020098 // -=- Set handler for incoming connections
99
100 void setQueryConnectionHandler(QueryConnectionHandler* qch) {
101 queryConnectionHandler = qch;
102 }
103
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000104 static IntParameter updateMethod;
105 static BoolParameter disableLocalInputs;
106 static StringParameter disconnectAction;
107 static BoolParameter removeWallpaper;
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000108 static BoolParameter disableEffects;
109
Pierre Ossman4ab1e5d2016-01-12 12:29:32 +0100110 // -=- Use by VNC Config to determine whether hooks are available
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000111 static bool areHooksAvailable();
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000112
113
114 protected:
115 bool isRestartRequired();
116 void startCore();
117 void stopCore();
118 void restartCore();
119 void recreatePixelBuffer(bool force=false);
120 bool flushChangeTracker(); // true if flushed, false if empty
Rahul Kalec719e4a2017-07-13 00:36:02 +0200121 bool checkLedState();
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000122
123 VNCServer* server;
124
125 // -=- Display pixel buffer
126 DeviceFrameBuffer* pb;
127 DeviceContext* device;
128
129 // -=- The coordinates of Window's entire virtual Screen
130 Rect screenRect;
131
132 // -=- All changes are collected in UN-CLIPPED Display coords and merged
133 // When they are to be flushed to the VNCServer, they are changed
134 // to server coords and clipped appropriately.
135 SimpleUpdateTracker updates;
136 ClippingUpdateTracker clipper;
137
138 // -=- Internal SDisplay implementation
139 SDisplayCore* core;
140 int updateMethod_;
141
142 // Inputs
143 SPointer* ptr;
144 SKeyboard* kbd;
145 Clipboard* clipboard;
146 WMBlockInput* inputs;
147
148 // Desktop state
149 WMMonitor* monitor;
150
151 // Desktop optimisation
152 CleanDesktop* cleanDesktop;
153 bool isWallpaperRemoved;
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000154 bool areEffectsDisabled;
155
156 // Cursor
157 WMCursor* cursor;
158 WMCursor::Info old_cursor;
159 Region old_cursor_region;
160 Point cursor_renderpos;
161
162 // -=- Event signalled to trigger an update to be flushed
163 Handle updateEvent;
164
165 // -=- Where to write the active/inactive indicator to
166 bool* statusLocation;
Rahul Kalec719e4a2017-07-13 00:36:02 +0200167
Pierre Ossmaneef6c9a2018-10-05 17:11:25 +0200168 // -=- Whom to query incoming connections
169 QueryConnectionHandler* queryConnectionHandler;
170
Rahul Kalec719e4a2017-07-13 00:36:02 +0200171 unsigned ledState;
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000172 };
173
174 }
175}
176
177#endif // __RFB_SDISPLAY_H__