From 24c3844246e46ec1c89496e87491f98a67767529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 15 Jul 2016 17:40:51 +0800 Subject: [PATCH] wayland/xdg-shell: Make keyboard focus follow grabbing popup This is the explicitly intended keyboard focus symantics of xdg-shell unstable v6. The semantics are undefined in unstable v5. https://bugzilla.gnome.org/show_bug.cgi?id=769936 --- src/wayland/meta-wayland-popup.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/wayland/meta-wayland-popup.c b/src/wayland/meta-wayland-popup.c index 6c4b78425..e582e6df5 100644 --- a/src/wayland/meta-wayland-popup.c +++ b/src/wayland/meta-wayland-popup.c @@ -242,7 +242,20 @@ meta_wayland_popup_dismiss (MetaWaylandPopup *popup) meta_wayland_popup_destroy (popup); if (wl_list_empty (&popup_grab->all_popups)) - meta_wayland_pointer_end_popup_grab (popup_grab->generic.pointer); + { + meta_wayland_pointer_end_popup_grab (popup_grab->generic.pointer); + } + else + { + MetaWaylandSurface *top_popup_surface; + MetaWaylandSeat *seat; + MetaWaylandKeyboard *keyboard; + + top_popup_surface = meta_wayland_popup_grab_get_top_popup (popup_grab); + seat = meta_wayland_pointer_get_seat (popup_grab->generic.pointer); + keyboard = &seat->keyboard; + meta_wayland_keyboard_set_focus (keyboard, top_popup_surface); + } } MetaWaylandSurface * @@ -258,6 +271,8 @@ meta_wayland_popup_create (MetaWaylandPopupSurface *popup_surface, MetaWaylandSurface *surface = meta_wayland_popup_surface_get_surface (popup_surface); MetaWaylandPopup *popup; + MetaWaylandSeat *seat; + MetaWaylandKeyboard *keyboard; /* Don't allow creating popups if the grab has a different client. */ if (grab->grab_client != wl_resource_get_client (surface->resource)) @@ -269,5 +284,9 @@ meta_wayland_popup_create (MetaWaylandPopupSurface *popup_surface, wl_list_insert (&grab->all_popups, &popup->link); + seat = meta_wayland_pointer_get_seat (grab->generic.pointer); + keyboard = &seat->keyboard; + meta_wayland_keyboard_set_focus (keyboard, surface); + return popup; }