diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | src/evdev_key.c | 29 |
2 files changed, 36 insertions, 1 deletions
@@ -1,4 +1,10 @@ -2006-02-27 Zephaniah E. Hull,,, <warp@aehallh.com> +2006-02-27 Zephaniah E. Hull <warp@aehallh.com> + + * src/evdev_key.c: (EvdevKeyOff): + Don't leave keys in the down state when we get turned off. + (VT switching, getting unplugged, that sort of stuff.) + +2006-02-27 Zephaniah E. Hull <warp@aehallh.com> * src/evdev.c: (EvdevReadInput): Better error reporting if the read fails. diff --git a/src/evdev_key.c b/src/evdev_key.c index 6e80602..e9d4518 100644 --- a/src/evdev_key.c +++ b/src/evdev_key.c @@ -405,6 +405,35 @@ EvdevKeyOn (DeviceIntPtr device) int EvdevKeyOff (DeviceIntPtr device) { + unsigned int i; + KeyClassRec *keyc = device->key; + KeySym *map = keyc->curKeySyms.map; + + /* + * A bit of a hack, vaguely stolen from xf86-input-keyboard. + * + * Don't leave any keys in the down state if we are getting turned + * off, as they are likely to be released before we are turned back + * on. + * (For example, if the user switches VTs, or if we are unplugged.) + */ + for (i = keyc->curKeySyms.minKeyCode, map = keyc->curKeySyms.map; + i < keyc->curKeySyms.maxKeyCode; + i++, map += keyc->curKeySyms.mapWidth) + if ((keyc->down[i >> 3] & (1 << (i & 7)))) + { + switch (*map) { + /* Don't release the lock keys */ + case XK_Caps_Lock: + case XK_Shift_Lock: + case XK_Num_Lock: + case XK_Scroll_Lock: + case XK_Kana_Lock: + break; + default: + xf86PostKeyboardEvent(device, i, 0); + } + } return Success; } |