Revision: 4236
http://tigervnc.svn.sourceforge.net/tigervnc/?rev=4236&view=rev
Author: atkac
Date: 2011-01-17 10:54:51 +0000 (Mon, 17 Jan 2011)
Log Message:
-----------
[Bugfix] Fix "Alt key gets stuck in Xvnc" issue.
Reference:
http://www.mail-archive.com/[email protected]/msg00196.html
Modified Paths:
--------------
trunk/unix/xserver/hw/vnc/Input.cc
Modified: trunk/unix/xserver/hw/vnc/Input.cc
===================================================================
--- trunk/unix/xserver/hw/vnc/Input.cc 2011-01-17 10:45:46 UTC (rev 4235)
+++ trunk/unix/xserver/hw/vnc/Input.cc 2011-01-17 10:54:51 UTC (rev 4236)
@@ -520,6 +520,49 @@
#define FREE_MAPS
#endif
+#if XORG >= 17
+/*
+ * Modifier keysyms must be handled differently. Instead of finding
+ * the right row and collumn in the keymap, directly press/release
+ * the keycode which is mapped as modifier with the same keysym.
+ *
+ * This will avoid issues when there are multiple modifier keysyms
+ * in the keymap but only some of them are mapped as modifiers in
+ * the modmap.
+ *
+ * Returns keycode of the modifier key.
+ */
+
+static inline int isModifier(KeySymsPtr keymap, KeyCode *modmap,
+ int maxKeysPerMod, rdr::U32 keysym)
+{
+ KeySym *map = keymap->map;
+ KeyCode minKeyCode = keymap->minKeyCode;
+ int mapWidth = keymap->mapWidth;
+ int i, j, k;
+
+ /* Find modifier index in the modmap */
+ for (i = 0; i < 8; i++) {
+ for (k = 0; k < maxKeysPerMod; k++) {
+ int index = i * maxKeysPerMod + k;
+ int keycode = modmap[index];
+
+ if (keycode == 0)
+ continue;
+
+ for (j = 0; j < mapWidth; j++) {
+ if (map[(keycode - minKeyCode) * mapWidth + j]
+ == keysym) {
+ return keycode;
+ }
+ }
+ }
+ }
+
+ return -1; /* Not a modifier */
+}
+#endif
+
void InputDevice::keyEvent(rdr::U32 keysym, bool down)
{
#if XORG < 17
@@ -618,7 +661,26 @@
}
ModeSwitchFound:
+ int kc;
int col = 0;
+
+#if XORG >= 17
+ if ((kc = isModifier(keymap, modmap, maxKeysPerMod, keysym)) != -1) {
+ /*
+ * It is a modifier key event.
+ *
+ * Don't do any auto-repeat because the X server will translate
+ * each press into a release followed by a press.
+ */
+ if (IS_PRESSED(keyc, kc) && down) {
+ FREE_MAPS;
+ return;
+ }
+
+ goto press;
+ }
+#endif
+
if (maxKeysPerMod != 0) {
if ((state & (1 << ShiftMapIndex)) != 0)
col |= 1;
@@ -627,7 +689,7 @@
col |= 2;
}
- int kc = KeysymToKeycode(keymap, keysym, &col);
+ kc = KeysymToKeycode(keymap, keysym, &col);
/*
* Sort out the "shifted Tab" mess. If we are sent a shifted Tab,
@@ -704,6 +766,7 @@
return;
}
+#if XORG < 17
/*
* See if it's a modifier key. If so, then don't do any auto-repeat,
* because the X server will translate each press into a release
@@ -718,6 +781,7 @@
}
}
}
+#endif
if (maxKeysPerMod != 0) {
ModifierState shift(keyboardDev, ShiftMapIndex);
@@ -739,8 +803,10 @@
* pressKey call, otherwise fake modifier keypress can be lost.
*/
pressKey(keyboardDev, kc, down, "keycode");
- } else
+ } else {
+press:
pressKey(keyboardDev, kc, down, "keycode");
+ }
FREE_MAPS;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Tigervnc-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tigervnc-commits