From 2e564bce568441fd23369b14f63e30dee4279f4f Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 9 Apr 2013 15:07:12 +0000 Subject: [PATCH] Handle init of old and new keyboards the same way. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@5071 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- unix/xserver/hw/vnc/Input.cc | 47 +++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/unix/xserver/hw/vnc/Input.cc b/unix/xserver/hw/vnc/Input.cc index 7a75c703..80490e6a 100644 --- a/unix/xserver/hw/vnc/Input.cc +++ b/unix/xserver/hw/vnc/Input.cc @@ -130,21 +130,6 @@ static void enqueueEvents(DeviceIntPtr dev, int n) InputDevice::InputDevice(rfb::VNCServerST *_server) : server(_server), initialized(false), oldButtonMask(0) { -#if XORG < 17 - pointerDev = AddInputDevice( -#if XORG >= 16 - serverClient, -#endif - pointerProc, TRUE); - RegisterPointerDevice(pointerDev); - - keyboardDev = AddInputDevice( -#if XORG >= 16 - serverClient, -#endif - keyboardProc, TRUE); - RegisterKeyboardDevice(keyboardDev); -#endif #if XORG < 111 initEventq(); #endif @@ -285,14 +270,36 @@ static int pointerProc(DeviceIntPtr pDevice, int onoff) void InputDevice::InitInputDevice(void) { -#if XORG >= 17 - int ret; - - if (!initialized) + if (initialized) return; initialized = true; +#if XORG < 17 + pointerDev = AddInputDevice( +#if XORG >= 16 + serverClient, +#endif + pointerProc, TRUE); + RegisterPointerDevice(pointerDev); + + keyboardDev = AddInputDevice( +#if XORG >= 16 + serverClient, +#endif + keyboardProc, TRUE); + RegisterKeyboardDevice(keyboardDev); + + if (ActivateDevice(pointerDev) != Success || + ActivateDevice(keyboardDev) != Success) + FatalError("Failed to activate TigerVNC devices\n"); + + if (!EnableDevice(pointerDev) || + !EnableDevice(keyboardDev)) + FatalError("Failed to enable TigerVNC devices\n"); +#else /* < 17 */ + int ret; + ret = AllocDevicePair(serverClient, "TigerVNC", &pointerDev, &keyboardDev, pointerProc, keyboardProc, FALSE); @@ -307,7 +314,7 @@ void InputDevice::InitInputDevice(void) if (!EnableDevice(pointerDev, TRUE) || !EnableDevice(keyboardDev, TRUE)) FatalError("Failed to activate TigerVNC devices\n"); -#endif +#endif /* 17 */ } static inline void pressKey(DeviceIntPtr dev, int kc, bool down, const char *msg) -- 2.39.5