summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Dreßler <verdre@v0yd.nl>2022-11-06 12:38:35 +0100
committerRobert Mader <robert.mader@posteo.de>2022-12-03 09:37:38 +0000
commitdece0ab14dcdc45eb449bf6b1bba40a659610303 (patch)
tree96fa04dbe24c7c8284227df00ea0ed8f4737cc64
parentdb3e5aa88c882b71ecd1348e90e787928ba2055e (diff)
downloadmutter-dece0ab14dcdc45eb449bf6b1bba40a659610303.tar.gz
window: Avoid focusing during workspace changes
We can land inside meta_window_focus() in the middle of changing the window workspace, because some signal handler of MetaWorkspace's "window-removed" signal triggers a focus. This can cause a crash in `g_assert (link)` when updating the MRU list because we still think we're on the old workspace when actually we are already removed from this workspaces MRU list. To avoid crashes like this, bail out of meta_window_focus() when we're in the middle of a workspace change. Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5368 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2691> (cherry picked from commit 1816f21e216d9e8f8fdadddaaad23ae8b3a5a17a)
-rw-r--r--src/core/window-private.h2
-rw-r--r--src/core/window.c12
2 files changed, 14 insertions, 0 deletions
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 61e80085d..35ebd925a 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -563,6 +563,8 @@ struct _MetaWindow
/* if TRUE, the we have the new form of sync request counter which
* also handles application frames */
guint extended_sync_request_counter : 1;
+
+ guint in_workspace_change : 1;
};
struct _MetaWindowClass
diff --git a/src/core/window.c b/src/core/window.c
index c2dc672bb..6b88f8ca6 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -4539,6 +4539,14 @@ meta_window_focus (MetaWindow *window,
"Setting input focus to window %s, input: %d focusable: %d",
window->desc, window->input, meta_window_is_focusable (window));
+ if (window->in_workspace_change)
+ {
+ meta_topic (META_DEBUG_FOCUS,
+ "Window %s is currently changing workspaces, not focusing it after all",
+ window->desc);
+ return;
+ }
+
if (window->display->grab_window &&
window->display->grab_window != window &&
window->display->grab_window->all_keys_grabbed &&
@@ -4630,6 +4638,8 @@ set_workspace_state (MetaWindow *window,
!window->constructing)
return;
+ window->in_workspace_change = TRUE;
+
if (window->workspace)
meta_workspace_remove_window (window->workspace, window);
else if (window->on_all_workspaces)
@@ -4657,6 +4667,8 @@ set_workspace_state (MetaWindow *window,
}
}
+ window->in_workspace_change = FALSE;
+
if (!window->constructing)
meta_window_update_appears_focused (window);