[PATCH 06/16] dmx: fix up dmxKeyCodeToKeySym for XKB-only.

Peter Hutterer peter.hutterer at who-t.net
Wed Sep 9 23:54:12 PDT 2009


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 hw/dmx/input/dmxevents.c |   34 ++++++++++++++++++----------------
 1 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index 37f8cb3..235c8eb 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -58,6 +58,7 @@
 #include "mi.h"
 #include "exglobals.h"
 
+#include "xkbsrv.h"
 #include "XIstubs.h"
 
 static int  dmxGlobalX, dmxGlobalY; /* Global cursor position */
@@ -600,24 +601,25 @@ void dmxMotion(DevicePtr pDev, int *v, int firstAxes, int axesCount,
 static KeySym dmxKeyCodeToKeySym(DMXLocalInputInfoPtr dmxLocal,
                                  KeyCode keyCode)
 {
-    KeySymsPtr pKeySyms = NULL;
+    KeySym keysym = NoSymbol;
+    int effectiveGroup;
+    XkbSrvInfoPtr xkbi;
 
     if (!dmxLocal || !dmxLocal->pDevice || !dmxLocal->pDevice->key)
-        return NoSymbol;
-    pKeySyms = &dmxLocal->pDevice->key->curKeySyms;
-    if (!pKeySyms)
-        return NoSymbol;
-    
-    if (keyCode > pKeySyms->minKeyCode && keyCode <= pKeySyms->maxKeyCode) {
-        DMXDBG2("dmxKeyCodeToKeySym: Translated keyCode=%d to keySym=0x%04x\n",
-                keyCode,
-                pKeySyms->map[(keyCode - pKeySyms->minKeyCode)
-                              * pKeySyms->mapWidth]);
-               
-        return pKeySyms->map[(keyCode - pKeySyms->minKeyCode)
-                             * pKeySyms->mapWidth];
-    }
-    return NoSymbol;
+        goto out;
+
+    xkbi = dmxLocal->pDevice->key->xkbInfo;
+    effectiveGroup = XkbGetEffectiveGroup(xkbi, &xkbi->state, keyCode);
+
+    if (effectiveGroup == -1)
+        goto out;
+
+    keysym = XkbKeySym(xkbi->desc, keyCode, effectiveGroup);
+    DMXDBG2("dmxKeyCodeToKeySym: Translated keyCode=%d to keySym=0x%04x\n",
+            keyCode, keysym);
+
+out:
+    return keysym;
 }
 
 static KeyCode dmxKeySymToKeyCode(DMXLocalInputInfoPtr dmxLocal, KeySym keySym,
-- 
1.6.3.rc1.2.g0164.dirty



More information about the xorg-devel mailing list