diff options
Diffstat (limited to 'hw/xnest/Keyboard.c')
-rw-r--r-- | hw/xnest/Keyboard.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/hw/xnest/Keyboard.c b/hw/xnest/Keyboard.c index f786819a5..a65b0ffcd 100644 --- a/hw/xnest/Keyboard.c +++ b/hw/xnest/Keyboard.c @@ -31,6 +31,7 @@ is" without express or implied warranty. #include "Screen.h" #include "Keyboard.h" #include "Args.h" +#include "Events.h" #ifdef XKB #include <X11/extensions/XKB.h> @@ -83,6 +84,8 @@ extern Status XkbGetControls( #endif +DeviceIntPtr xnestKeyboardDevice = NULL; + void xnestBell(int volume, DeviceIntPtr pDev, pointer ctrl, int cls) { @@ -282,3 +285,49 @@ LegalModifier(unsigned int key, DevicePtr pDev) { return TRUE; } + +void +xnestUpdateModifierState(unsigned int state) +{ + DeviceIntPtr pDev = xnestKeyboardDevice; + KeyClassPtr keyc = pDev->key; + int i; + CARD8 mask; + + if (keyc->state == state) + return; + + for (i = 0, mask = 1; i < 8; i++, mask <<= 1) { + int key; + + /* Modifier is down, but shouldn't be + */ + if ((keyc->state & mask) && !(state & mask)) { + int count = keyc->modifierKeyCount[i]; + + for (key = 0; key < MAP_LENGTH; key++) + if (keyc->modifierMap[key] & mask) { + int bit; + BYTE *kptr; + + kptr = &keyc->down[key >> 3]; + bit = 1 << (key & 7); + + if (*kptr & bit) + xnestQueueKeyEvent(KeyRelease, key); + + if (--count == 0) + break; + } + } + + /* Modifier shoud be down, but isn't + */ + if (!(keyc->state & mask) && (state & mask)) + for (key = 0; key < MAP_LENGTH; key++) + if (keyc->modifierMap[key] & mask) { + xnestQueueKeyEvent(KeyPress, key); + break; + } + } +} |