blob: 6aac59ae392aa1d31f231c71fe110c9ff6f21a21 [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
99 // -=- Use by VNC Config to determine whether hooks, driver, etc are available
100 static bool areHooksAvailable();
101 static bool isDriverAvailable();
102
103
104 protected:
105 bool isRestartRequired();
106 void startCore();
107 void stopCore();
108 void restartCore();
109 void recreatePixelBuffer(bool force=false);
110 bool flushChangeTracker(); // true if flushed, false if empty
111
112 VNCServer* server;
113
114 // -=- Display pixel buffer
115 DeviceFrameBuffer* pb;
116 DeviceContext* device;
117
118 // -=- The coordinates of Window's entire virtual Screen
119 Rect screenRect;
120
121 // -=- All changes are collected in UN-CLIPPED Display coords and merged
122 // When they are to be flushed to the VNCServer, they are changed
123 // to server coords and clipped appropriately.
124 SimpleUpdateTracker updates;
125 ClippingUpdateTracker clipper;
126
127 // -=- Internal SDisplay implementation
128 SDisplayCore* core;
129 int updateMethod_;
130
131 // Inputs
132 SPointer* ptr;
133 SKeyboard* kbd;
134 Clipboard* clipboard;
135 WMBlockInput* inputs;
136
137 // Desktop state
138 WMMonitor* monitor;
139
140 // Desktop optimisation
141 CleanDesktop* cleanDesktop;
142 bool isWallpaperRemoved;
143 bool isPatternRemoved;
144 bool areEffectsDisabled;
145
146 // Cursor
147 WMCursor* cursor;
148 WMCursor::Info old_cursor;
149 Region old_cursor_region;
150 Point cursor_renderpos;
151
152 // -=- Event signalled to trigger an update to be flushed
153 Handle updateEvent;
154
155 // -=- Where to write the active/inactive indicator to
156 bool* statusLocation;
157 };
158
159 }
160}
161
162#endif // __RFB_SDISPLAY_H__