blob: 6dbb50a5b185bb9a49e13d1069ffaaf02eea6bb3 [file] [log] [blame]
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
2 *
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +00003 * 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
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000023#ifndef __RFB_SDISPLAY_H__
24#define __RFB_SDISPLAY_H__
25
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000026#include <rfb/SDesktop.h>
27#include <rfb/UpdateTracker.h>
28#include <rfb/Configuration.h>
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +000029#include <rfb_win32/Handle.h>
30#include <rfb_win32/EventManager.h>
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000031#include <rfb_win32/SInput.h>
32#include <rfb_win32/Clipboard.h>
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +000033#include <rfb_win32/CleanDesktop.h>
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000034#include <rfb_win32/WMCursor.h>
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000035#include <rfb_win32/WMNotifier.h>
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +000036#include <rfb_win32/DeviceFrameBuffer.h>
37#include <rfb_win32/DeviceContext.h>
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000038
39namespace rfb {
40
41 namespace win32 {
42
43 //
44 // -=- SDisplay
45 //
46
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +000047 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 };
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000054
55 class SDisplay : public SDesktop,
56 WMMonitor::Notifier,
57 Clipboard::Notifier,
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +000058 public EventHandler
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000059 {
60 public:
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +000061 SDisplay();
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000062 virtual ~SDisplay();
63
64 // -=- SDesktop interface
65
66 virtual void start(VNCServer* vs);
67 virtual void stop();
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +000068 virtual void pointerEvent(const Point& pos, int buttonmask);
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000069 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
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000074 // -=- 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;}
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +000085 virtual void processEvent(HANDLE event);
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000086
87 // -=- Notification of whether or not SDisplay is started
88
89 void setStatusLocation(bool* status) {statusLocation = status;}
90
91 friend class SDisplayCore;
92
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +000093 static IntParameter updateMethod;
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +000094 static BoolParameter disableLocalInputs;
95 static StringParameter disconnectAction;
96 static BoolParameter removeWallpaper;
97 static BoolParameter removePattern;
98 static BoolParameter disableEffects;
99
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +0000100 // -=- Use by VNC Config to determine whether hooks, driver, etc are available
101 static bool areHooksAvailable();
102 static bool isDriverAvailable();
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +0000103
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +0000104
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
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +0000112
113 VNCServer* server;
114
115 // -=- Display pixel buffer
116 DeviceFrameBuffer* pb;
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +0000117 DeviceContext* device;
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +0000118
119 // -=- The coordinates of Window's entire virtual Screen
120 Rect screenRect;
121
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +0000122 // -=- 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;
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +0000127
128 // -=- Internal SDisplay implementation
129 SDisplayCore* core;
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +0000130 int updateMethod_;
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +0000131
Constantin Kaplinsky0a1eca12006-04-16 07:28:14 +0000132 // 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;
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +0000149 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__