]>
Commit | Line | Data |
---|---|---|
a9abb5c6 JR |
1 | diff -up tigervnc-1.3.0/unix/xserver/hw/vnc/Input.cc.inputreset tigervnc-1.3.0/unix/xserver/hw/vnc/Input.cc |
2 | --- tigervnc-1.3.0/unix/xserver/hw/vnc/Input.cc.inputreset 2013-07-01 13:41:24.000000000 +0100 | |
3 | +++ tigervnc-1.3.0/unix/xserver/hw/vnc/Input.cc 2014-07-14 13:08:01.482660946 +0100 | |
4 | @@ -68,6 +68,9 @@ rfb::BoolParameter avoidShiftNumLock("Av | |
5 | ||
6 | #define BUTTONS 7 | |
7 | ||
8 | +class InputDevice *vncInputDevice; | |
9 | +InputDevice InputDevice::singleton; | |
10 | + | |
11 | /* Event queue is shared between all devices. */ | |
12 | #if XORG == 15 | |
13 | static xEvent *eventq = NULL; | |
14 | @@ -116,11 +119,13 @@ static void enqueueEvents(DeviceIntPtr d | |
15 | } | |
16 | #endif /* XORG < 111 */ | |
17 | ||
18 | -InputDevice::InputDevice(rfb::VNCServerST *_server) | |
19 | - : server(_server), initialized(false), oldButtonMask(0) | |
20 | +InputDevice::InputDevice() | |
21 | + : oldButtonMask(0) | |
22 | { | |
23 | int i; | |
24 | ||
25 | + vncInputDevice = this; | |
26 | + | |
27 | #if XORG < 111 | |
28 | initEventq(); | |
29 | #endif | |
30 | @@ -195,16 +200,12 @@ void InputDevice::PointerMove(const rfb: | |
31 | cursorPos = pos; | |
32 | } | |
33 | ||
34 | -void InputDevice::PointerSync(void) | |
35 | +const rfb::Point &InputDevice::getPointerPos(void) | |
36 | { | |
37 | - if (cursorPos.equals(oldCursorPos)) | |
38 | - return; | |
39 | - | |
40 | - oldCursorPos = cursorPos; | |
41 | - server->setCursorPos(cursorPos); | |
42 | + return cursorPos; | |
43 | } | |
44 | ||
45 | -static int pointerProc(DeviceIntPtr pDevice, int onoff) | |
46 | +int InputDevice::pointerProc(DeviceIntPtr pDevice, int onoff) | |
47 | { | |
48 | BYTE map[BUTTONS + 1]; | |
49 | DevicePtr pDev = (DevicePtr)pDevice; | |
50 | @@ -229,6 +230,8 @@ static int pointerProc(DeviceIntPtr pDev | |
51 | btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT); | |
52 | btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP); | |
53 | btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN); | |
54 | + btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT); | |
55 | + btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT); | |
56 | ||
57 | axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X); | |
58 | axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y); | |
59 | @@ -253,10 +256,9 @@ static int pointerProc(DeviceIntPtr pDev | |
60 | case DEVICE_OFF: | |
61 | pDev->on = FALSE; | |
62 | break; | |
63 | -#if 0 | |
64 | case DEVICE_CLOSE: | |
65 | + singleton.pointerDev = NULL; | |
66 | break; | |
67 | -#endif | |
68 | } | |
69 | ||
70 | return Success; | |
71 | @@ -269,9 +271,7 @@ static void keyboardBell(int percent, De | |
72 | vncBell(); | |
73 | } | |
74 | ||
75 | -extern void GetInitKeyboardMap(KeySymsPtr keysyms, CARD8 *modmap); | |
76 | - | |
77 | -static int keyboardProc(DeviceIntPtr pDevice, int onoff) | |
78 | +int InputDevice::keyboardProc(DeviceIntPtr pDevice, int onoff) | |
79 | { | |
80 | #if XORG < 17 | |
81 | KeySymsRec keySyms; | |
82 | @@ -298,6 +298,9 @@ static int keyboardProc(DeviceIntPtr pDe | |
83 | case DEVICE_OFF: | |
84 | pDev->on = FALSE; | |
85 | break; | |
86 | + case DEVICE_CLOSE: | |
87 | + singleton.keyboardDev = NULL; | |
88 | + break; | |
89 | } | |
90 | ||
91 | return Success; | |
92 | @@ -305,11 +308,9 @@ static int keyboardProc(DeviceIntPtr pDe | |
93 | ||
94 | void InputDevice::InitInputDevice(void) | |
95 | { | |
96 | - if (initialized) | |
97 | + if ((pointerDev != NULL) || (keyboardDev != NULL)) | |
98 | return; | |
99 | ||
100 | - initialized = true; | |
101 | - | |
102 | #if XORG < 17 | |
103 | pointerDev = AddInputDevice( | |
104 | #if XORG >= 16 | |
105 | diff -up tigervnc-1.3.0/unix/xserver/hw/vnc/InputCore.cc.inputreset tigervnc-1.3.0/unix/xserver/hw/vnc/InputCore.cc | |
106 | --- tigervnc-1.3.0/unix/xserver/hw/vnc/InputCore.cc.inputreset 2013-07-01 13:41:24.000000000 +0100 | |
107 | +++ tigervnc-1.3.0/unix/xserver/hw/vnc/InputCore.cc 2014-07-14 13:08:01.483660952 +0100 | |
108 | @@ -174,7 +174,7 @@ KeySym keyboardMap[MAP_LEN * KEYSYMS_PER | |
109 | XK_Menu, NoSymbol, | |
110 | }; | |
111 | ||
112 | -void GetInitKeyboardMap(KeySymsPtr keysyms, CARD8 *modmap) | |
113 | +void InputDevice::GetInitKeyboardMap(KeySymsPtr keysyms, CARD8 *modmap) | |
114 | { | |
115 | int i; | |
116 | ||
117 | diff -up tigervnc-1.3.0/unix/xserver/hw/vnc/Input.h.inputreset tigervnc-1.3.0/unix/xserver/hw/vnc/Input.h | |
118 | --- tigervnc-1.3.0/unix/xserver/hw/vnc/Input.h.inputreset 2013-07-01 13:41:24.000000000 +0100 | |
119 | +++ tigervnc-1.3.0/unix/xserver/hw/vnc/Input.h 2014-07-14 13:08:01.483660952 +0100 | |
120 | @@ -29,20 +29,27 @@ | |
121 | ||
122 | #include <list> | |
123 | ||
124 | -#include <rfb/VNCServerST.h> | |
125 | +#include <rdr/types.h> | |
126 | +#include <rfb/Rect.h> | |
127 | ||
128 | extern "C" { | |
129 | #include "input.h" | |
130 | +/* The Xorg headers define macros that wreak havoc with STL */ | |
131 | +#undef max | |
132 | }; | |
133 | ||
134 | #include "xorg-version.h" | |
135 | ||
136 | -/* Represents input device (keyboard + pointer) */ | |
137 | +/* | |
138 | + * Represents input device (keyboard + pointer) | |
139 | + * | |
140 | + * Is a singleton as input devices are global in the X server so | |
141 | + * we do not have one per desktop (i.e. per screen). | |
142 | + */ | |
143 | +extern class InputDevice *vncInputDevice; | |
144 | + | |
145 | class InputDevice { | |
146 | public: | |
147 | - /* Create new InputDevice instance */ | |
148 | - InputDevice(rfb::VNCServerST *_server); | |
149 | - | |
150 | /* | |
151 | * Press or release buttons. Relationship between buttonMask and | |
152 | * buttons is specified in RFB protocol. | |
153 | @@ -52,27 +59,28 @@ public: | |
154 | /* Move pointer to target location (point coords are absolute). */ | |
155 | void PointerMove(const rfb::Point &point); | |
156 | ||
157 | - /* | |
158 | - * Send pointer position to clients. If not called then Move() calls | |
159 | - * won't be visible to VNC clients. | |
160 | - */ | |
161 | - void PointerSync(void); | |
162 | + /* Get current known location of the pointer */ | |
163 | + const rfb::Point &getPointerPos(void); | |
164 | ||
165 | + /* Press or release one or more keys to get the given symbol */ | |
166 | void KeyboardPress(rdr::U32 keysym) { keyEvent(keysym, true); } | |
167 | void KeyboardRelease(rdr::U32 keysym) { keyEvent(keysym, false); } | |
168 | ||
169 | /* | |
170 | - * Init input device. This cannot be done in the constructor | |
171 | - * because constructor is called during X server extensions | |
172 | - * initialization. Devices must be initialized after core | |
173 | - * pointer/keyboard initialization which is actually after extesions | |
174 | - * initialization. Check InitExtensions(), InitCoreDevices() and | |
175 | - * InitInput() calls in dix/main.c. Instead it is called from | |
176 | - * XserverDesktop at an appropriate time. | |
177 | + * Init input device. | |
178 | + * This has to be called after core pointer/keyboard | |
179 | + * initialization which unfortunately is after extesions | |
180 | + * initialization (which means we cannot call it in | |
181 | + * vncExtensionInit(). Check InitExtensions(), | |
182 | + * InitCoreDevices() and InitInput() calls in dix/main.c. | |
183 | + * Instead we call it from XserverDesktop at an appropriate | |
184 | + * time. | |
185 | */ | |
186 | void InitInputDevice(void); | |
187 | ||
188 | private: | |
189 | + InputDevice(); | |
190 | + | |
191 | void keyEvent(rdr::U32 keysym, bool down); | |
192 | ||
193 | /* Backend dependent functions below here */ | |
194 | @@ -96,22 +104,28 @@ private: | |
195 | KeyCode addKeysym(KeySym keysym, unsigned state); | |
196 | ||
197 | private: | |
198 | + static int pointerProc(DeviceIntPtr pDevice, int onoff); | |
199 | + static int keyboardProc(DeviceIntPtr pDevice, int onoff); | |
200 | + | |
201 | #if XORG >= 17 | |
202 | static void vncXkbProcessDeviceEvent(int screenNum, | |
203 | InternalEvent *event, | |
204 | DeviceIntPtr dev); | |
205 | +#else | |
206 | + static void GetInitKeyboardMap(KeySymsPtr keysyms, CARD8 *modmap); | |
207 | #endif | |
208 | ||
209 | private: | |
210 | - rfb::VNCServerST *server; | |
211 | - bool initialized; | |
212 | DeviceIntPtr keyboardDev; | |
213 | DeviceIntPtr pointerDev; | |
214 | ||
215 | int oldButtonMask; | |
216 | - rfb::Point cursorPos, oldCursorPos; | |
217 | + rfb::Point cursorPos; | |
218 | ||
219 | KeySym pressedKeys[256]; | |
220 | + | |
221 | +private: | |
222 | + static InputDevice singleton; | |
223 | }; | |
224 | ||
225 | #endif | |
226 | diff -up tigervnc-1.3.0/unix/xserver/hw/vnc/InputXKB.cc.inputreset tigervnc-1.3.0/unix/xserver/hw/vnc/InputXKB.cc | |
227 | --- tigervnc-1.3.0/unix/xserver/hw/vnc/InputXKB.cc.inputreset 2014-07-14 13:07:53.145619157 +0100 | |
228 | +++ tigervnc-1.3.0/unix/xserver/hw/vnc/InputXKB.cc 2014-07-14 13:08:01.484660958 +0100 | |
229 | @@ -42,18 +42,6 @@ extern "C" { | |
230 | #undef class | |
231 | } | |
232 | ||
233 | -#if XORG < 19 | |
234 | -static int vncXkbScreenPrivateKeyIndex; | |
235 | -static DevPrivateKey vncXkbScreenPrivateKey = &vncXkbScreenPrivateKeyIndex; | |
236 | -#else | |
237 | -static DevPrivateKeyRec vncXkbPrivateKeyRec; | |
238 | -#define vncXkbScreenPrivateKey (&vncXkbPrivateKeyRec) | |
239 | -#endif | |
240 | - | |
241 | -#define vncXkbScreenPrivate(pScreen) \ | |
242 | - (*(InputDevice**) dixLookupPrivate(&(pScreen)->devPrivates, \ | |
243 | - vncXkbScreenPrivateKey)) | |
244 | - | |
245 | #ifndef KEYBOARD_OR_FLOAT | |
246 | #define KEYBOARD_OR_FLOAT MASTER_KEYBOARD | |
247 | #endif | |
248 | @@ -209,18 +197,6 @@ static unsigned XkbKeyEffectiveGroup(Xkb | |
249 | ||
250 | void InputDevice::PrepareInputDevices(void) | |
251 | { | |
252 | -#if XORG < 19 | |
253 | - if (!dixRequestPrivate(vncXkbScreenPrivateKey, sizeof(InputDevice*))) | |
254 | - FatalError("Failed to register TigerVNC XKB screen key\n"); | |
255 | -#else | |
256 | - if (!dixRegisterPrivateKey(vncXkbScreenPrivateKey, PRIVATE_SCREEN, | |
257 | - sizeof(InputDevice*))) | |
258 | - FatalError("Failed to register TigerVNC XKB screen key\n"); | |
259 | -#endif | |
260 | - | |
261 | - for (int scr = 0; scr < screenInfo.numScreens; scr++) | |
262 | - vncXkbScreenPrivate(screenInfo.screens[scr]) = this; | |
263 | - | |
264 | /* | |
265 | * Not ideal since these callbacks do not stack, but it's the only | |
266 | * decent way we can reliably catch events for both the slave and | |
267 | @@ -633,10 +609,9 @@ void InputDevice::vncXkbProcessDeviceEve | |
268 | InternalEvent *event, | |
269 | DeviceIntPtr dev) | |
270 | { | |
271 | - InputDevice *self = vncXkbScreenPrivate(screenInfo.screens[screenNum]); | |
272 | unsigned int backupctrls; | |
273 | ||
274 | - if (event->device_event.sourceid == self->keyboardDev->id) { | |
275 | + if (event->device_event.sourceid == singleton.keyboardDev->id) { | |
276 | XkbControlsPtr ctrls; | |
277 | ||
278 | /* | |
279 | @@ -658,7 +633,7 @@ void InputDevice::vncXkbProcessDeviceEve | |
280 | ||
281 | dev->c_public.processInputProc(event, dev); | |
282 | ||
283 | - if (event->device_event.sourceid == self->keyboardDev->id) { | |
284 | + if (event->device_event.sourceid == singleton.keyboardDev->id) { | |
285 | XkbControlsPtr ctrls; | |
286 | ||
287 | ctrls = dev->key->xkbInfo->desc->ctrls; | |
288 | diff -up tigervnc-1.3.0/unix/xserver/hw/vnc/xf86vncModule.cc.inputreset tigervnc-1.3.0/unix/xserver/hw/vnc/xf86vncModule.cc | |
289 | --- tigervnc-1.3.0/unix/xserver/hw/vnc/xf86vncModule.cc.inputreset 2013-07-01 13:41:24.000000000 +0100 | |
290 | +++ tigervnc-1.3.0/unix/xserver/hw/vnc/xf86vncModule.cc 2014-07-14 13:08:01.487660972 +0100 | |
291 | @@ -112,9 +112,9 @@ static void vncExtensionInitWithParams(I | |
292 | i.param->setParam(val); | |
293 | } | |
294 | } | |
295 | - | |
296 | - vncExtensionInit(); | |
297 | } | |
298 | + | |
299 | + vncExtensionInit(); | |
300 | } | |
301 | } | |
302 | ||
303 | diff -up tigervnc-1.3.0/unix/xserver/hw/vnc/XserverDesktop.cc.inputreset tigervnc-1.3.0/unix/xserver/hw/vnc/XserverDesktop.cc | |
304 | --- tigervnc-1.3.0/unix/xserver/hw/vnc/XserverDesktop.cc.inputreset 2014-07-14 13:07:53.140619132 +0100 | |
305 | +++ tigervnc-1.3.0/unix/xserver/hw/vnc/XserverDesktop.cc 2014-07-14 13:08:01.486660967 +0100 | |
306 | @@ -157,15 +157,12 @@ XserverDesktop::XserverDesktop(ScreenPtr | |
307 | ||
308 | if (httpListener) | |
309 | httpServer = new FileHTTPServer(this); | |
310 | - | |
311 | - inputDevice = new InputDevice(server); | |
312 | } | |
313 | ||
314 | XserverDesktop::~XserverDesktop() | |
315 | { | |
316 | if (!directFbptr) | |
317 | delete [] data; | |
318 | - delete inputDevice; | |
319 | delete httpServer; | |
320 | delete server; | |
321 | } | |
322 | @@ -583,7 +580,7 @@ void XserverDesktop::blockHandler(fd_set | |
323 | // so we abuse the fact that this routine will be called first thing | |
324 | // once the dix is done initialising. | |
325 | // [1] Technically Xvnc has InitInput(), but libvnc.so has nothing. | |
326 | - inputDevice->InitInputDevice(); | |
327 | + vncInputDevice->InitInputDevice(); | |
328 | ||
329 | try { | |
330 | int nextTimeout; | |
331 | @@ -691,7 +688,11 @@ void XserverDesktop::wakeupHandler(fd_se | |
332 | } | |
333 | } | |
334 | ||
335 | - inputDevice->PointerSync(); | |
336 | + // We are responsible for propagating mouse movement between clients | |
337 | + if (!oldCursorPos.equals(vncInputDevice->getPointerPos())) { | |
338 | + oldCursorPos = vncInputDevice->getPointerPos(); | |
339 | + server->setCursorPos(oldCursorPos); | |
340 | + } | |
341 | } | |
342 | ||
343 | // Then let the timers do some processing. Rescheduling is done in | |
344 | @@ -818,8 +819,8 @@ void XserverDesktop::approveConnection(v | |
345 | ||
346 | void XserverDesktop::pointerEvent(const Point& pos, int buttonMask) | |
347 | { | |
348 | - inputDevice->PointerMove(pos); | |
349 | - inputDevice->PointerButtonAction(buttonMask); | |
350 | + vncInputDevice->PointerMove(pos); | |
351 | + vncInputDevice->PointerButtonAction(buttonMask); | |
352 | } | |
353 | ||
354 | void XserverDesktop::clientCutText(const char* str, int len) | |
355 | @@ -1136,7 +1137,7 @@ void XserverDesktop::lookup(int index, i | |
356 | void XserverDesktop::keyEvent(rdr::U32 keysym, bool down) | |
357 | { | |
358 | if (down) | |
359 | - inputDevice->KeyboardPress(keysym); | |
360 | + vncInputDevice->KeyboardPress(keysym); | |
361 | else | |
362 | - inputDevice->KeyboardRelease(keysym); | |
363 | + vncInputDevice->KeyboardRelease(keysym); | |
364 | } | |
365 | diff -up tigervnc-1.3.0/unix/xserver/hw/vnc/XserverDesktop.h.inputreset tigervnc-1.3.0/unix/xserver/hw/vnc/XserverDesktop.h | |
366 | --- tigervnc-1.3.0/unix/xserver/hw/vnc/XserverDesktop.h.inputreset 2013-07-01 13:41:24.000000000 +0100 | |
367 | +++ tigervnc-1.3.0/unix/xserver/hw/vnc/XserverDesktop.h 2014-07-14 13:08:01.486660967 +0100 | |
368 | @@ -133,7 +133,6 @@ private: | |
369 | #endif | |
370 | ||
371 | ScreenPtr pScreen; | |
372 | - InputDevice *inputDevice; | |
373 | rfb::VNCServerST* server; | |
374 | rfb::HTTPServer* httpServer; | |
375 | network::TcpListener* listener; | |
376 | @@ -153,5 +152,7 @@ private: | |
377 | typedef std::map<RROutputPtr, rdr::U32> OutputIdMap; | |
378 | OutputIdMap outputIdMap; | |
379 | #endif | |
380 | + | |
381 | + rfb::Point oldCursorPos; | |
382 | }; | |
383 | #endif |