From 1b593ced171d02f1d00034f0f733060706bb6d41 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 5 May 2009 16:57:46 +1000 Subject: [PATCH] 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 --- Xi/exevents.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 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; + 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->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; + 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);