wayland: Clean up xwayland grabs even if surface is gone

If the surface is gone before `meta_xwayland_keyboard_grab_end()` is
called, we would bail out early leaving an empty grab, which will cause
a segfault as soon as a key is pressed later on.

Make sure we clean up the keyboard grab even if the surface is gone.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/255
(cherry picked from commit 252dd52439)
This commit is contained in:
Olivier Fourdan 2018-08-03 10:50:32 +02:00 committed by Ray Strode
parent e00d6c6273
commit 2fb5b65e94

View File

@ -85,6 +85,13 @@ meta_xwayland_keyboard_grab_end (MetaXwaylandKeyboardActiveGrab *active_grab)
{ {
MetaWaylandSeat *seat = active_grab->seat; MetaWaylandSeat *seat = active_grab->seat;
if (seat->keyboard->grab->interface->key == meta_xwayland_keyboard_grab_key)
{
meta_wayland_keyboard_end_grab (active_grab->keyboard_grab.keyboard);
meta_wayland_keyboard_set_focus (active_grab->keyboard_grab.keyboard, NULL);
meta_display_sync_wayland_input_focus (meta_get_display ());
}
if (!active_grab->surface) if (!active_grab->surface)
return; return;
@ -104,13 +111,6 @@ meta_xwayland_keyboard_grab_end (MetaXwaylandKeyboardActiveGrab *active_grab)
active_grab->window_associate_handler = 0; active_grab->window_associate_handler = 0;
} }
if (seat->keyboard->grab->interface->key == meta_xwayland_keyboard_grab_key)
{
meta_wayland_keyboard_end_grab (active_grab->keyboard_grab.keyboard);
meta_wayland_keyboard_set_focus (active_grab->keyboard_grab.keyboard, NULL);
meta_display_sync_wayland_input_focus (meta_get_display ());
}
active_grab->surface = NULL; active_grab->surface = NULL;
} }