diff options
author | Zephaniah E. Hull <warp@aehallh.com> | 2006-02-27 13:22:35 +0000 |
---|---|---|
committer | Zephaniah E. Hull <warp@aehallh.com> | 2006-02-27 13:22:35 +0000 |
commit | 9972f2b1c77eefe5fb6a2ba7baacaf6b273228a8 (patch) | |
tree | 7e0fd3b5a134fda32eb8d4ceaa86bceee629a2be /src | |
parent | 94cb4aa1f8caf1ba141ab0839c9eb0b2b5357470 (diff) |
Don't leave keys in the down state when we get turned off. (VT switching,
getting unplugged, that sort of stuff.)
Diffstat (limited to 'src')
-rw-r--r-- | src/evdev_key.c | 29 |
1 files changed, 29 insertions, 0 deletions
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; } |