Don't leave keys in the down state when we get turned off. (VT switching,

getting unplugged, that sort of stuff.)
This commit is contained in:
Zephaniah E. Hull
2006-02-27 13:22:35 +00:00
parent 94cb4aa1f8
commit 9972f2b1c7
2 changed files with 36 additions and 1 deletions

View File

@@ -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.

View File

@@ -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;
}