blob: 70208a7d06faf6f293321c788025bd31bf99bd03 [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);
69 virtual void keyEvent(rdr::U32 key, bool down);
70 virtual void clientCutText(const char* str, int len);
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000071 virtual Point getFbSize();
72
73 // -=- Clipboard
74
75 virtual void notifyClipboardChanged(const char* text, int len);
76
77 // -=- Display events
78
79 virtual void notifyDisplayEvent(WMMonitor::Notifier::DisplayEventType evt);
80
81 // -=- EventHandler interface
82
83 HANDLE getUpdateEvent() {return updateEvent;}
84 virtual void processEvent(HANDLE event);
85
86 // -=- Notification of whether or not SDisplay is started
87
88 void setStatusLocation(bool* status) {statusLocation = status;}
89
90 friend class SDisplayCore;
91
92 static IntParameter updateMethod;
93 static BoolParameter disableLocalInputs;
94 static StringParameter disconnectAction;
95 static BoolParameter removeWallpaper;
96 static BoolParameter removePattern;
97 static BoolParameter disableEffects;
98
Pierre Ossman4ab1e5d2016-01-12 12:29:32 +010099 // -=- Use by VNC Config to determine whether hooks are available
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000100 static bool areHooksAvailable();
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000101
102
103 protected:
104 bool isRestartRequired();
105 void startCore();
106 void stopCore();
107 void restartCore();
108 void recreatePixelBuffer(bool force=false);
109 bool flushChangeTracker(); // true if flushed, false if empty
110
111 VNCServer* server;
112
113 // -=- Display pixel buffer
114 DeviceFrameBuffer* pb;
115 DeviceContext* device;
116
117 // -=- The coordinates of Window's entire virtual Screen
118 Rect screenRect;
119
120 // -=- All changes are collected in UN-CLIPPED Display coords and merged
121 // When they are to be flushed to the VNCServer, they are changed
122 // to server coords and clipped appropriately.
123 SimpleUpdateTracker updates;
124 ClippingUpdateTracker clipper;
125
126 // -=- Internal SDisplay implementation
127 SDisplayCore* core;
128 int updateMethod_;
129
130 // Inputs
131 SPointer* ptr;
132 SKeyboard* kbd;
133 Clipboard* clipboard;
134 WMBlockInput* inputs;
135
136 // Desktop state
137 WMMonitor* monitor;
138
139 // Desktop optimisation
140 CleanDesktop* cleanDesktop;
141 bool isWallpaperRemoved;
142 bool isPatternRemoved;
143 bool areEffectsDisabled;
144
145 // Cursor
146 WMCursor* cursor;
147 WMCursor::Info old_cursor;
148 Region old_cursor_region;
149 Point cursor_renderpos;
150
151 // -=- Event signalled to trigger an update to be flushed
152 Handle updateEvent;
153
154 // -=- Where to write the active/inactive indicator to
155 bool* statusLocation;
156 };
157
158 }
159}
160
161#endif // __RFB_SDISPLAY_H__