blob: c1d5c1e270c7b2df4d085b44858e44755d9337cf [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
55 class SDisplay : public SDesktop,
56 WMMonitor::Notifier,
57 Clipboard::Notifier,
58 public EventHandler
59 {
60 public:
61 SDisplay();
62 virtual ~SDisplay();
63
64 // -=- SDesktop interface
65
66 virtual void start(VNCServer* vs);
67 virtual void stop();
68 virtual void pointerEvent(const Point& pos, int buttonmask);
Pierre Ossman5ae28212017-05-16 14:30:38 +020069 virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000070 virtual void clientCutText(const char* str, int len);
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000071
72 // -=- Clipboard
73
74 virtual void notifyClipboardChanged(const char* text, int len);
75
76 // -=- Display events
77
78 virtual void notifyDisplayEvent(WMMonitor::Notifier::DisplayEventType evt);
79
80 // -=- EventHandler interface
81
82 HANDLE getUpdateEvent() {return updateEvent;}
83 virtual void processEvent(HANDLE event);
84
85 // -=- Notification of whether or not SDisplay is started
86
87 void setStatusLocation(bool* status) {statusLocation = status;}
88
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000089 static IntParameter updateMethod;
90 static BoolParameter disableLocalInputs;
91 static StringParameter disconnectAction;
92 static BoolParameter removeWallpaper;
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000093 static BoolParameter disableEffects;
94
Pierre Ossman4ab1e5d2016-01-12 12:29:32 +010095 // -=- Use by VNC Config to determine whether hooks are available
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000096 static bool areHooksAvailable();
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000097
98
99 protected:
100 bool isRestartRequired();
101 void startCore();
102 void stopCore();
103 void restartCore();
104 void recreatePixelBuffer(bool force=false);
105 bool flushChangeTracker(); // true if flushed, false if empty
Rahul Kalec719e4a2017-07-13 00:36:02 +0200106 bool checkLedState();
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000107
108 VNCServer* server;
109
110 // -=- Display pixel buffer
111 DeviceFrameBuffer* pb;
112 DeviceContext* device;
113
114 // -=- The coordinates of Window's entire virtual Screen
115 Rect screenRect;
116
117 // -=- All changes are collected in UN-CLIPPED Display coords and merged
118 // When they are to be flushed to the VNCServer, they are changed
119 // to server coords and clipped appropriately.
120 SimpleUpdateTracker updates;
121 ClippingUpdateTracker clipper;
122
123 // -=- Internal SDisplay implementation
124 SDisplayCore* core;
125 int updateMethod_;
126
127 // Inputs
128 SPointer* ptr;
129 SKeyboard* kbd;
130 Clipboard* clipboard;
131 WMBlockInput* inputs;
132
133 // Desktop state
134 WMMonitor* monitor;
135
136 // Desktop optimisation
137 CleanDesktop* cleanDesktop;
138 bool isWallpaperRemoved;
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000139 bool areEffectsDisabled;
140
141 // Cursor
142 WMCursor* cursor;
143 WMCursor::Info old_cursor;
144 Region old_cursor_region;
145 Point cursor_renderpos;
146
147 // -=- Event signalled to trigger an update to be flushed
148 Handle updateEvent;
149
150 // -=- Where to write the active/inactive indicator to
151 bool* statusLocation;
Rahul Kalec719e4a2017-07-13 00:36:02 +0200152
153 unsigned ledState;
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000154 };
155
156 }
157}
158
159#endif // __RFB_SDISPLAY_H__