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
8 +class InputDevice *vncInputDevice;
9 +InputDevice InputDevice::singleton;
11 /* Event queue is shared between all devices. */
13 static xEvent *eventq = NULL;
14 @@ -116,11 +119,13 @@ static void enqueueEvents(DeviceIntPtr d
16 #endif /* XORG < 111 */
18 -InputDevice::InputDevice(rfb::VNCServerST *_server)
19 - : server(_server), initialized(false), oldButtonMask(0)
20 +InputDevice::InputDevice()
25 + vncInputDevice = this;
30 @@ -195,16 +200,12 @@ void InputDevice::PointerMove(const rfb:
34 -void InputDevice::PointerSync(void)
35 +const rfb::Point &InputDevice::getPointerPos(void)
37 - if (cursorPos.equals(oldCursorPos))
40 - oldCursorPos = cursorPos;
41 - server->setCursorPos(cursorPos);
45 -static int pointerProc(DeviceIntPtr pDevice, int onoff)
46 +int InputDevice::pointerProc(DeviceIntPtr pDevice, int onoff)
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);
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
65 + singleton.pointerDev = NULL;
71 @@ -269,9 +271,7 @@ static void keyboardBell(int percent, De
75 -extern void GetInitKeyboardMap(KeySymsPtr keysyms, CARD8 *modmap);
77 -static int keyboardProc(DeviceIntPtr pDevice, int onoff)
78 +int InputDevice::keyboardProc(DeviceIntPtr pDevice, int onoff)
82 @@ -298,6 +298,9 @@ static int keyboardProc(DeviceIntPtr pDe
87 + singleton.keyboardDev = NULL;
92 @@ -305,11 +308,9 @@ static int keyboardProc(DeviceIntPtr pDe
94 void InputDevice::InitInputDevice(void)
97 + if ((pointerDev != NULL) || (keyboardDev != NULL))
100 - initialized = true;
103 pointerDev = AddInputDevice(
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
112 -void GetInitKeyboardMap(KeySymsPtr keysyms, CARD8 *modmap)
113 +void InputDevice::GetInitKeyboardMap(KeySymsPtr keysyms, CARD8 *modmap)
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
124 -#include <rfb/VNCServerST.h>
125 +#include <rdr/types.h>
126 +#include <rfb/Rect.h>
130 +/* The Xorg headers define macros that wreak havoc with STL */
134 #include "xorg-version.h"
136 -/* Represents input device (keyboard + pointer) */
138 + * Represents input device (keyboard + pointer)
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).
143 +extern class InputDevice *vncInputDevice;
147 - /* Create new InputDevice instance */
148 - InputDevice(rfb::VNCServerST *_server);
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);
158 - * Send pointer position to clients. If not called then Move() calls
159 - * won't be visible to VNC clients.
161 - void PointerSync(void);
162 + /* Get current known location of the pointer */
163 + const rfb::Point &getPointerPos(void);
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); }
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
186 void InitInputDevice(void);
191 void keyEvent(rdr::U32 keysym, bool down);
193 /* Backend dependent functions below here */
194 @@ -96,22 +104,28 @@ private:
195 KeyCode addKeysym(KeySym keysym, unsigned state);
198 + static int pointerProc(DeviceIntPtr pDevice, int onoff);
199 + static int keyboardProc(DeviceIntPtr pDevice, int onoff);
202 static void vncXkbProcessDeviceEvent(int screenNum,
203 InternalEvent *event,
206 + static void GetInitKeyboardMap(KeySymsPtr keysyms, CARD8 *modmap);
210 - rfb::VNCServerST *server;
212 DeviceIntPtr keyboardDev;
213 DeviceIntPtr pointerDev;
216 - rfb::Point cursorPos, oldCursorPos;
217 + rfb::Point cursorPos;
219 KeySym pressedKeys[256];
222 + static InputDevice singleton;
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" {
234 -static int vncXkbScreenPrivateKeyIndex;
235 -static DevPrivateKey vncXkbScreenPrivateKey = &vncXkbScreenPrivateKeyIndex;
237 -static DevPrivateKeyRec vncXkbPrivateKeyRec;
238 -#define vncXkbScreenPrivateKey (&vncXkbPrivateKeyRec)
241 -#define vncXkbScreenPrivate(pScreen) \
242 - (*(InputDevice**) dixLookupPrivate(&(pScreen)->devPrivates, \
243 - vncXkbScreenPrivateKey))
245 #ifndef KEYBOARD_OR_FLOAT
246 #define KEYBOARD_OR_FLOAT MASTER_KEYBOARD
248 @@ -209,18 +197,6 @@ static unsigned XkbKeyEffectiveGroup(Xkb
250 void InputDevice::PrepareInputDevices(void)
253 - if (!dixRequestPrivate(vncXkbScreenPrivateKey, sizeof(InputDevice*)))
254 - FatalError("Failed to register TigerVNC XKB screen key\n");
256 - if (!dixRegisterPrivateKey(vncXkbScreenPrivateKey, PRIVATE_SCREEN,
257 - sizeof(InputDevice*)))
258 - FatalError("Failed to register TigerVNC XKB screen key\n");
261 - for (int scr = 0; scr < screenInfo.numScreens; scr++)
262 - vncXkbScreenPrivate(screenInfo.screens[scr]) = this;
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,
271 - InputDevice *self = vncXkbScreenPrivate(screenInfo.screens[screenNum]);
272 unsigned int backupctrls;
274 - if (event->device_event.sourceid == self->keyboardDev->id) {
275 + if (event->device_event.sourceid == singleton.keyboardDev->id) {
276 XkbControlsPtr ctrls;
279 @@ -658,7 +633,7 @@ void InputDevice::vncXkbProcessDeviceEve
281 dev->c_public.processInputProc(event, dev);
283 - if (event->device_event.sourceid == self->keyboardDev->id) {
284 + if (event->device_event.sourceid == singleton.keyboardDev->id) {
285 XkbControlsPtr ctrls;
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);
296 - vncExtensionInit();
299 + vncExtensionInit();
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
309 httpServer = new FileHTTPServer(this);
311 - inputDevice = new InputDevice(server);
314 XserverDesktop::~XserverDesktop()
318 - delete inputDevice;
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();
331 @@ -691,7 +688,11 @@ void XserverDesktop::wakeupHandler(fd_se
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);
343 // Then let the timers do some processing. Rescheduling is done in
344 @@ -818,8 +819,8 @@ void XserverDesktop::approveConnection(v
346 void XserverDesktop::pointerEvent(const Point& pos, int buttonMask)
348 - inputDevice->PointerMove(pos);
349 - inputDevice->PointerButtonAction(buttonMask);
350 + vncInputDevice->PointerMove(pos);
351 + vncInputDevice->PointerButtonAction(buttonMask);
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)
359 - inputDevice->KeyboardPress(keysym);
360 + vncInputDevice->KeyboardPress(keysym);
362 - inputDevice->KeyboardRelease(keysym);
363 + vncInputDevice->KeyboardRelease(keysym);
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:
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;
381 + rfb::Point oldCursorPos;