Nested X11: use KeymapNotify events to fix key state on FocusIn

If the user Alt-Tabs out of the window, we will be left thinking
the Alt key is still pressed since we don't see a release for it.

Solve this and other related issues for the nested X11 compositor
by selecting for KeymapStateMask which causes a KeymapNotify event
to be sent after each FocusIn, and when we get these events, update
the internal XKB state and send any necessary modifiers events to
clients.

https://bugzilla.gnome.org/show_bug.cgi?id=753948
This commit is contained in:
Owen W. Taylor
2015-08-21 16:25:53 -04:00
parent 1d56d50fcd
commit 614d6bd0f8
5 changed files with 87 additions and 0 deletions

View File

@ -477,6 +477,33 @@ meta_wayland_keyboard_handle_event (MetaWaylandKeyboard *keyboard,
return handled;
}
void
meta_wayland_keyboard_update_key_state (MetaWaylandKeyboard *keyboard,
char *key_vector,
int key_vector_len,
int offset)
{
gboolean mods_changed = FALSE;
for (gint i = offset; i < key_vector_len * 8; i++)
{
gboolean set = (key_vector[i/8] & (1 << (i % 8))) != 0;
/* The 'offset' parameter allows the caller to have the indices
* into key_vector to either be X-style (base 8) or evdev (base 0), or
* something else (unlikely). We subtract 'offset' to convert to evdev
* style, then add 8 to convert the "evdev" style keycode back to
* the X-style that xkbcommon expects.
*/
mods_changed |= xkb_state_update_key (keyboard->xkb_info.state,
i - offset + 8,
set ? XKB_KEY_DOWN : XKB_KEY_UP);
}
if (mods_changed)
notify_modifiers (keyboard);
}
static void
move_resources (struct wl_list *destination, struct wl_list *source)
{