summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2009-05-05 16:57:46 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2009-05-06 14:37:32 +1000
commit1b593ced171d02f1d00034f0f733060706bb6d41 (patch)
tree0f24fbeca3eb56bca0b09467bdd4e5c39e31eb1a
parent35a4b8e7f4526a92d44cb16a783f21030cd1f6df (diff)
Xi: access the prev_state to get group/modifier state for key events.
Key events may change the modifier state, so we need to get the prev_state for those (i.e. without the changes by the event already applied). Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--Xi/exevents.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c
index 07931132e..a01432cf2 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -983,13 +983,20 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
if (kbd && kbd->key)
{
- event->mods.base = kbd->key->xkbInfo->state.base_mods;
- event->mods.latched = kbd->key->xkbInfo->state.latched_mods;
- event->mods.locked = kbd->key->xkbInfo->state.locked_mods;
-
- event->group.base = kbd->key->xkbInfo->state.base_group;
- event->group.latched = kbd->key->xkbInfo->state.latched_group;
- event->group.locked = kbd->key->xkbInfo->state.locked_group;
+ XkbStatePtr state;
+ /* we need the state before the event happens */
+ if (event->type == ET_KeyPress || event->type == ET_KeyRelease)
+ state = &kbd->key->xkbInfo->prev_state;
+ else
+ state = &kbd->key->xkbInfo->state;
+
+ event->mods.base = state->base_mods;
+ event->mods.latched = state->latched_mods;
+ event->mods.locked = state->locked_mods;
+
+ event->group.base = state->base_group;
+ event->group.latched = state->latched_group;
+ event->group.locked = state->locked_group;
}
ret = UpdateDeviceState(device, event);