blob: 1773b785eddbcc9e246cd443ec1ba8f745bef2a0 [file] [log] [blame]
Constantin Kaplinsky729598c2006-05-25 05:12:25 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
Pierre Ossman66f1db52019-05-02 12:32:03 +02002 * Copyright 2011-2019 Pierre Ossman for Cendio AB
Constantin Kaplinsky729598c2006-05-25 05:12:25 +00003 *
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
20// -=- SDisplay.h
21//
22// The SDisplay class encapsulates a system display.
23
24#ifndef __RFB_SDISPLAY_H__
25#define __RFB_SDISPLAY_H__
26
27#include <rfb/SDesktop.h>
28#include <rfb/UpdateTracker.h>
29#include <rfb/Configuration.h>
30#include <rfb_win32/Handle.h>
31#include <rfb_win32/EventManager.h>
32#include <rfb_win32/SInput.h>
33#include <rfb_win32/Clipboard.h>
34#include <rfb_win32/CleanDesktop.h>
35#include <rfb_win32/WMCursor.h>
36#include <rfb_win32/WMNotifier.h>
37#include <rfb_win32/DeviceFrameBuffer.h>
38#include <rfb_win32/DeviceContext.h>
39
40namespace rfb {
41
42 namespace win32 {
43
44 //
45 // -=- SDisplay
46 //
47
48 class SDisplayCore {
49 public:
50 virtual ~SDisplayCore() {};
51 virtual void setScreenRect(const Rect& screenRect_) = 0;
52 virtual void flushUpdates() = 0;
53 virtual const char* methodName() const = 0;
54 };
55
Pierre Ossmaneef6c9a2018-10-05 17:11:25 +020056 class QueryConnectionHandler {
57 public:
58 virtual ~QueryConnectionHandler() {}
59 virtual void queryConnection(network::Socket* sock,
60 const char* userName) = 0;
61 };
62
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000063 class SDisplay : public SDesktop,
64 WMMonitor::Notifier,
65 Clipboard::Notifier,
66 public EventHandler
67 {
68 public:
69 SDisplay();
70 virtual ~SDisplay();
71
72 // -=- SDesktop interface
73
74 virtual void start(VNCServer* vs);
75 virtual void stop();
Pierre Ossman10688ef2018-09-29 11:24:19 +020076 virtual void terminate();
Pierre Ossmaneef6c9a2018-10-05 17:11:25 +020077 virtual void queryConnection(network::Socket* sock,
78 const char* userName);
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000079 virtual void pointerEvent(const Point& pos, int buttonmask);
Pierre Ossman5ae28212017-05-16 14:30:38 +020080 virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
Pierre Ossman66f1db52019-05-02 12:32:03 +020081 virtual void clientCutText(const char* str);
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000082
83 // -=- Clipboard
84
Pierre Ossman66f1db52019-05-02 12:32:03 +020085 virtual void notifyClipboardChanged(const char* text);
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000086
87 // -=- Display events
88
89 virtual void notifyDisplayEvent(WMMonitor::Notifier::DisplayEventType evt);
90
91 // -=- EventHandler interface
92
93 HANDLE getUpdateEvent() {return updateEvent;}
Pierre Ossman10688ef2018-09-29 11:24:19 +020094 HANDLE getTerminateEvent() {return terminateEvent;}
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000095 virtual void processEvent(HANDLE event);
96
97 // -=- Notification of whether or not SDisplay is started
98
99 void setStatusLocation(bool* status) {statusLocation = status;}
100
Pierre Ossmaneef6c9a2018-10-05 17:11:25 +0200101 // -=- Set handler for incoming connections
102
103 void setQueryConnectionHandler(QueryConnectionHandler* qch) {
104 queryConnectionHandler = qch;
105 }
106
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000107 static IntParameter updateMethod;
108 static BoolParameter disableLocalInputs;
109 static StringParameter disconnectAction;
110 static BoolParameter removeWallpaper;
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000111 static BoolParameter disableEffects;
112
Pierre Ossman4ab1e5d2016-01-12 12:29:32 +0100113 // -=- Use by VNC Config to determine whether hooks are available
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000114 static bool areHooksAvailable();
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000115
116
117 protected:
118 bool isRestartRequired();
119 void startCore();
120 void stopCore();
121 void restartCore();
122 void recreatePixelBuffer(bool force=false);
123 bool flushChangeTracker(); // true if flushed, false if empty
Rahul Kalec719e4a2017-07-13 00:36:02 +0200124 bool checkLedState();
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000125
126 VNCServer* server;
127
128 // -=- Display pixel buffer
129 DeviceFrameBuffer* pb;
130 DeviceContext* device;
131
132 // -=- The coordinates of Window's entire virtual Screen
133 Rect screenRect;
134
135 // -=- All changes are collected in UN-CLIPPED Display coords and merged
136 // When they are to be flushed to the VNCServer, they are changed
137 // to server coords and clipped appropriately.
138 SimpleUpdateTracker updates;
139 ClippingUpdateTracker clipper;
140
141 // -=- Internal SDisplay implementation
142 SDisplayCore* core;
143 int updateMethod_;
144
145 // Inputs
146 SPointer* ptr;
147 SKeyboard* kbd;
148 Clipboard* clipboard;
149 WMBlockInput* inputs;
150
151 // Desktop state
152 WMMonitor* monitor;
153
154 // Desktop optimisation
155 CleanDesktop* cleanDesktop;
156 bool isWallpaperRemoved;
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000157 bool areEffectsDisabled;
158
159 // Cursor
160 WMCursor* cursor;
161 WMCursor::Info old_cursor;
162 Region old_cursor_region;
163 Point cursor_renderpos;
164
165 // -=- Event signalled to trigger an update to be flushed
166 Handle updateEvent;
Pierre Ossman10688ef2018-09-29 11:24:19 +0200167 // -=- Event signalled to terminate the server
168 Handle terminateEvent;
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000169
170 // -=- Where to write the active/inactive indicator to
171 bool* statusLocation;
Rahul Kalec719e4a2017-07-13 00:36:02 +0200172
Pierre Ossmaneef6c9a2018-10-05 17:11:25 +0200173 // -=- Whom to query incoming connections
174 QueryConnectionHandler* queryConnectionHandler;
175
Rahul Kalec719e4a2017-07-13 00:36:02 +0200176 unsigned ledState;
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000177 };
178
179 }
180}
181
182#endif // __RFB_SDISPLAY_H__