From 5904ef2ccd6056b187ca76f104c21e2d686bfc1d Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 5 Aug 2009 10:40:20 +1000 Subject: [PATCH] xnest: restore xnestUpdateModifierState The meat of xnestUpdateModifierState was ifdef'd out in 6ef46c40e62def4841a4cff4e0b443516a2ed782. This resulted in stuck modifiers when a modifier key release event wasn't sent to Xnest (e.g. Alt-Tab away). See X.Org Bug 3664 for the original bug report. Signed-off-by: Peter Hutterer --- hw/xnest/Keyboard.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/hw/xnest/Keyboard.c b/hw/xnest/Keyboard.c index 191bec780..1835c7071 100644 --- a/hw/xnest/Keyboard.c +++ b/hw/xnest/Keyboard.c @@ -206,29 +206,19 @@ LegalModifier(unsigned int key, DeviceIntPtr pDev) void xnestUpdateModifierState(unsigned int state) { -#if 0 DeviceIntPtr pDev = xnestKeyboardDevice; KeyClassPtr keyc = pDev->key; int i; CARD8 mask; + int xkb_state; if (!pDev) return; -/* This is pretty broken. - * - * What should happen is that focus out should do as a VT switch does in - * traditional servers: fake releases for all keys (and buttons too, come - * to think of it) currently down. Then, on focus in, get the state from - * the host, and fake keypresses for everything currently down. - * - * So I'm leaving this broken for a little while. Sorry, folks. - * - * -daniels - */ + xkb_state = XkbStateFieldFromRec(&pDev->key->xkbInfo->state); state = state & 0xff; - if (keyc->state == state) + if (xkb_state == state) return; for (i = 0, mask = 1; i < 8; i++, mask <<= 1) { @@ -236,7 +226,7 @@ xnestUpdateModifierState(unsigned int state) /* Modifier is down, but shouldn't be */ - if ((keyc->state & mask) && !(state & mask)) { + if ((xkb_state & mask) && !(state & mask)) { int count = keyc->modifierKeyCount[i]; for (key = 0; key < MAP_LENGTH; key++) @@ -257,12 +247,11 @@ xnestUpdateModifierState(unsigned int state) /* Modifier shoud be down, but isn't */ - if (!(keyc->state & mask) && (state & mask)) + if (!(xkb_state & mask) && (state & mask)) for (key = 0; key < MAP_LENGTH; key++) if (keyc->xkbInfo->desc->map->modmap[key] & mask) { xnestQueueKeyEvent(KeyPress, key); break; } } -#endif }