xwayland: Process queued events before making wayland mods effective

Since xwayland's initial commit we have had a check to not process
wayland modifier events while one of our surfaces has keyboard focus
since the normal xkb event processing keeps our internal modifier
state up to date and if we use the modifiers we get from the
compositor we mess up that state.

This was slightly changed in commit
10e9116b3f to allow the xkb group to be
set from the wayland event while we have focus in case the compositor
triggers a group switch.

There's a better solution to the original problem though. Processing
queued events before overriding the xkb state with the compositor's
allows those events to be sent properly modified to X clients while
any further events will be modified with the wayland modifiers as
intended.

This allows us to fully take in the wayland modifiers, including
depressed ones, which fixes an issue where we wouldn't be aware of
already pressed modifiers on enter.

Signed-off-by: Rui Matos <tiagomatos@gmail.com>
Tested-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Rui Matos 2016-06-26 19:48:23 +02:00 committed by Peter Hutterer
parent deae9c7e84
commit 589f42e983

View File

@ -494,6 +494,8 @@ keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard,
xkbStateNotify sn;
CARD16 changed;
mieqProcessInputEvents();
for (dev = inputInfo.devices; dev; dev = dev->next) {
if (dev != xwl_seat->keyboard &&
dev != GetMaster(xwl_seat->keyboard, MASTER_KEYBOARD))
@ -502,12 +504,11 @@ keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard,
old_state = dev->key->xkbInfo->state;
new_state = &dev->key->xkbInfo->state;
if (!xwl_seat->keyboard_focus) {
new_state->locked_mods = mods_locked & XkbAllModifiersMask;
XkbLatchModifiers(dev, XkbAllModifiersMask,
mods_latched & XkbAllModifiersMask);
}
new_state->locked_group = group & XkbAllGroupsMask;
new_state->base_mods = mods_depressed & XkbAllModifiersMask;
new_state->locked_mods = mods_locked & XkbAllModifiersMask;
XkbLatchModifiers(dev, XkbAllModifiersMask,
mods_latched & XkbAllModifiersMask);
XkbComputeDerivedState(dev->key->xkbInfo);