summaryrefslogtreecommitdiff
path: root/dix/getevents.c
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2007-04-08 14:02:02 +0300
committerDaniel Stone <daniels@endtroducing.fooishbar.org>2007-04-10 23:58:20 +0300
commite92743bc9839c36914a44f3e5bc8cd85773ac794 (patch)
treef47ce72f29dfe237f5092b168094dddf8ba827df /dix/getevents.c
parente49f836d6fa2768cd6d2a6d0227b5dbf516013dc (diff)
getevents: Copy modifier state from extended to core devices
Make core events carry the same modifier state as the extended events, so that holding down Ctrl on keyboard A and pressing Q on keyboard B won't cause your app to quit.
Diffstat (limited to 'dix/getevents.c')
-rw-r--r--dix/getevents.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/dix/getevents.c b/dix/getevents.c
index 62f3bcb7f..6969f782f 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -714,6 +714,7 @@ _X_EXPORT void
SwitchCoreKeyboard(DeviceIntPtr pDev)
{
KeyClassPtr ckeyc = inputInfo.keyboard->key;
+ int i = 0;
if (inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr != pDev) {
memcpy(ckeyc->modifierMap, pDev->key->modifierMap, MAP_LENGTH);
@@ -728,6 +729,25 @@ SwitchCoreKeyboard(DeviceIntPtr pDev)
ckeyc->curKeySyms.maxKeyCode = pDev->key->curKeySyms.maxKeyCode;
SetKeySymsMap(&ckeyc->curKeySyms, &pDev->key->curKeySyms);
+ /*
+ * Copy state from the extended keyboard to core. If you omit this,
+ * holding Ctrl on keyboard one, and pressing Q on keyboard two, will
+ * cause your app to quit. This feels wrong to me, hence the below
+ * code.
+ *
+ * XXX: If you synthesise core modifier events, the state will get
+ * clobbered here. You'll have to work out something sensible
+ * to fix that. Good luck.
+ */
+
+#define KEYBOARD_MASK (ShiftMask | LockMask | ControlMask | Mod1Mask | \
+ Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask)
+ ckeyc->state &= ~(KEYBOARD_MASK);
+ ckeyc->state |= (pDev->key->state & KEYBOARD_MASK);
+#undef KEYBOARD_MASK
+ for (i = 0; i < 8; i++)
+ ckeyc->modifierKeyCount[i] = pDev->key->modifierKeyCount[i];
+
#ifdef XKB
if (!noXkbExtension && pDev->key->xkbInfo && pDev->key->xkbInfo->desc) {
if (!XkbCopyKeymap(pDev->key->xkbInfo->desc, ckeyc->xkbInfo->desc,