[mutter/gnome-3-30] window-x11: Focus a window in the active workspace as take-focus fallback



commit c05fe4ae98e3e0558b0a5bd76adbb254d5a2527f
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Wed Jul 17 01:13:48 2019 +0200

    window-x11: Focus a window in the active workspace as take-focus fallback
    
    Starting with commit 2db94e2e we try to focus a fallback default focus window
    if no take-focus window candidate gets the input focus when we request it and
    we limit the focus candidates to the current window's workspace.
    
    However, if the window is unmanaging, the workspace might be unset, and we could
    end up in deferencing a NULL pointer causing a crash.
    
    So, in case the window's workspace is unset, just use the currently active
    workspace for the display.
    
    Closes https://gitlab.gnome.org/GNOME/mutter/issues/687
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/688
    
    (cherry picked from commit 5ca0ef078d39548edda1a97e9066d44aa8f38108)

 src/x11/window-x11.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c
index f323429b0..6acdbfc5e 100644
--- a/src/x11/window-x11.c
+++ b/src/x11/window-x11.c
@@ -846,15 +846,22 @@ meta_window_x11_maybe_focus_delayed (MetaWindow *window,
 }
 
 static void
-maybe_focus_default_window (MetaWorkspace *workspace,
-                            MetaWindow    *not_this_one,
-                            guint32        timestamp)
+maybe_focus_default_window (MetaDisplay *display,
+                            MetaWindow  *not_this_one,
+                            guint32      timestamp)
 {
+  MetaWorkspace *workspace;
+  MetaStack *stack = display->stack;
   MetaStack *stack = workspace->display->stack;
   g_autoptr (GList) focusable_windows = NULL;
   g_autoptr (GQueue) focus_candidates = NULL;
   GList *l;
 
+  if (not_this_one && not_this_one->workspace)
+    workspace = not_this_one->workspace;
+  else
+    workspace = display->workspace_manager->active_workspace;
+
    /* Go through all the focusable windows and try to focus them
     * in order, waiting for a delay. The first one that replies to
     * the request (in case of take focus windows) changing the display
@@ -949,7 +956,7 @@ meta_window_x11_focus (MetaWindow *window,
 
                   meta_x11_display_focus_the_no_focus_window (x11_display,
                                                               timestamp);
-                  maybe_focus_default_window (window->workspace, window,
+                  maybe_focus_default_window (window->display, window,
                                               timestamp);
                 }
             }


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