aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Tkac <atkac@redhat.com>2010-04-14 09:24:06 +0000
committerAdam Tkac <atkac@redhat.com>2010-04-14 09:24:06 +0000
commit10f5e0b4afa2c50b2959423c1ece67b76cb90a61 (patch)
treed8b572af2ddb9e0d7f34943704f14a73d1b41afa
parent470c38ceba51fe12ed1b720aa5353943d3c3a54e (diff)
downloadtigervnc-10f5e0b4afa2c50b2959423c1ece67b76cb90a61.tar.gz
tigervnc-10f5e0b4afa2c50b2959423c1ece67b76cb90a61.zip
[Development] Use AllocDevicePair instead of AddDevice/RegisterDevice functions
and initialize TigerVNC input devices after core devices initialization. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4025 3789f03b-4d11-0410-bbf8-ca57d06f2519
-rw-r--r--unix/xserver/hw/vnc/Input.cc37
-rw-r--r--unix/xserver/hw/vnc/Input.h10
2 files changed, 46 insertions, 1 deletions
diff --git a/unix/xserver/hw/vnc/Input.cc b/unix/xserver/hw/vnc/Input.cc
index 3b60a5f1..d1087633 100644
--- a/unix/xserver/hw/vnc/Input.cc
+++ b/unix/xserver/hw/vnc/Input.cc
@@ -119,6 +119,7 @@ static void enqueueEvents(DeviceIntPtr dev, int n)
InputDevice::InputDevice(rfb::VNCServerST *_server)
: server(_server), oldButtonMask(0)
{
+#if XORG < 17
pointerDev = AddInputDevice(
#if XORG >= 16
serverClient,
@@ -132,7 +133,7 @@ InputDevice::InputDevice(rfb::VNCServerST *_server)
#endif
keyboardProc, TRUE);
RegisterKeyboardDevice(keyboardDev);
-
+#endif
initEventq();
}
@@ -140,6 +141,8 @@ void InputDevice::PointerButtonAction(int buttonMask)
{
int i, n;
+ initInputDevice();
+
for (i = 0; i < BUTTONS; i++) {
if ((buttonMask ^ oldButtonMask) & (1 << i)) {
int action = (buttonMask & (1<<i)) ?
@@ -161,6 +164,8 @@ void InputDevice::PointerMove(const rfb::Point &pos)
if (pos.equals(cursorPos))
return;
+ initInputDevice();
+
valuators[0] = pos.x;
valuators[1] = pos.y;
n = GetPointerEvents(eventq, pointerDev, MotionNotify, 0, POINTER_ABSOLUTE, 0,
@@ -238,6 +243,34 @@ static int pointerProc(DeviceIntPtr pDevice, int onoff)
return Success;
}
+void InputDevice::initInputDevice(void)
+{
+#if XORG >= 17
+ int ret;
+ static int initialized = 0;
+
+ if (initialized != 0)
+ return;
+
+ initialized = 1;
+
+ ret = AllocDevicePair(serverClient, "TigerVNC", &pointerDev,
+ &keyboardDev, pointerProc, keyboardProc,
+ FALSE);
+
+ if (ret != Success)
+ FatalError("Failed to initialize TigerVNC input devices\n");
+
+ if (ActivateDevice(pointerDev, TRUE) != Success ||
+ ActivateDevice(keyboardDev, TRUE) != Success)
+ FatalError("Failed to activate TigerVNC devices\n");
+
+ if (!EnableDevice(pointerDev, TRUE) ||
+ !EnableDevice(keyboardDev, TRUE))
+ FatalError("Failed to activate TigerVNC devices\n");
+#endif
+}
+
#define IS_PRESSED(keyc, keycode) \
((keyc)->down[(keycode) >> 3] & (1 << ((keycode) & 7)))
@@ -463,6 +496,8 @@ void InputDevice::keyEvent(rdr::U32 keysym, bool down)
unsigned int i, n;
int j, k, action, state, maxKeysPerMod;
+ initInputDevice();
+
/*
* Since we are checking the current state to determine if we need
* to fake modifiers, we must make sure that everything put on the
diff --git a/unix/xserver/hw/vnc/Input.h b/unix/xserver/hw/vnc/Input.h
index 89870852..dbc78f88 100644
--- a/unix/xserver/hw/vnc/Input.h
+++ b/unix/xserver/hw/vnc/Input.h
@@ -56,6 +56,16 @@ public:
void KeyboardPress(rdr::U32 keysym) { keyEvent(keysym, true); }
void KeyboardRelease(rdr::U32 keysym) { keyEvent(keysym, false); }
private:
+ /*
+ * Init input device. This cannot be done in the constructor
+ * because constructor is called during X server extensions
+ * initialization. Devices must be initialized after core
+ * pointer/keyboard initialization which is actually after extesions
+ * initialization. Check InitExtensions(), InitCoreDevices() and
+ * InitInput() calls in dix/main.c
+ */
+ void initInputDevice(void);
+
void keyEvent(rdr::U32 keysym, bool down);
rfb::VNCServerST *server;