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