[mutter] wayland: Ensure we don't focus xdg_popups iff they're non-grabbing



commit c98d5448ec54980829d401c05becd5b60adc90d7
Author: Rui Matos <tiagomatos gmail com>
Date:   Mon Dec 12 19:30:36 2016 +0100

    wayland: Ensure we don't focus xdg_popups iff they're non-grabbing
    
    Commit 4295fdb892d4474b68e98aa783b725f99c1a2d3a made us skip focusing
    all xdg_popups instead of just non-grabbing ones as intended. This
    means that when unmanaging a window we might select a xdg_popup window
    to focus (in meta_stack_get_default_focus_window() ) but then since we
    don't actually focus it we go on unmanaging the focused window which
    triggers an assertion, as it should.
    
    To avoid this and still fixing bug 771694 we can make use of the
    MetaWindow->input property for non-grabbing xdg_popup windows since
    their semantics, in this regard, are the same as no input X11 windows.
    
    This way, when unmanaging a focused window while a xdg_popup is up,
    we'll either give focus to the xdg_popup or not select the popup at
    all to be focused if it's non-grabbing.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=775986

 src/wayland/meta-wayland-xdg-shell.c |   11 +++++++++++
 src/wayland/meta-window-wayland.c    |   23 +++++------------------
 2 files changed, 16 insertions(+), 18 deletions(-)
---
diff --git a/src/wayland/meta-wayland-xdg-shell.c b/src/wayland/meta-wayland-xdg-shell.c
index 450acda..6267587 100644
--- a/src/wayland/meta-wayland-xdg-shell.c
+++ b/src/wayland/meta-wayland-xdg-shell.c
@@ -839,6 +839,17 @@ finish_popup_setup (MetaWaylandXdgPopup *xdg_popup)
 
       xdg_popup->popup = popup;
     }
+  else
+    {
+      /* The keyboard focus semantics for non-grabbing zxdg_shell_v6 popups
+       * is pretty undefined. Same applies for subsurfaces, but in practice,
+       * subsurfaces never receive keyboard focus, so it makes sense to
+       * do the same for non-grabbing popups.
+       *
+       * See https://bugzilla.gnome.org/show_bug.cgi?id=771694#c24
+       */
+      window->input = FALSE;
+    }
 }
 
 static void
diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c
index 1527bcf..6d8727a 100644
--- a/src/wayland/meta-window-wayland.c
+++ b/src/wayland/meta-window-wayland.c
@@ -117,24 +117,11 @@ static void
 meta_window_wayland_focus (MetaWindow *window,
                            guint32     timestamp)
 {
-  MetaWaylandSurface *surface = window->surface;
-  MetaWaylandSurfaceRoleShellSurface *shell_surface_role =
-     META_WAYLAND_SURFACE_ROLE_SHELL_SURFACE (surface->role);
-
-  /* The keyboard focus semantics for non-grabbing zxdg_shell_v6 popups
-   * is pretty undefined. Same applies for subsurfaces, but in practice,
-   * subsurfaces never receive keyboard focus, so it makes sense to
-   * do the same for non-grabbing popups.
-   *
-   * See https://bugzilla.gnome.org/show_bug.cgi?id=771694#c24
-   */
-  if (META_IS_WAYLAND_XDG_POPUP (shell_surface_role))
-    return;
-
-  meta_display_set_input_focus_window (window->display,
-                                       window,
-                                       FALSE,
-                                       timestamp);
+  if (window->input)
+    meta_display_set_input_focus_window (window->display,
+                                         window,
+                                         FALSE,
+                                         timestamp);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]