From 0d69fabbe6895fdac31e044060ed16bd1f1c344a Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 7 Dec 2022 18:20:49 +0100 Subject: [PATCH] window: Update mru list for every workspace the window is on If the window is on all workspaces we should update the mru list for all those workspaces, otherwise the default focus window for a specific workspace can be unexpected. Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2548 Part-of: --- src/core/window.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/core/window.c b/src/core/window.c index 0a4f8eb5a..f11ea7351 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -4598,9 +4598,9 @@ meta_window_focus (MetaWindow *window, META_WINDOW_GET_CLASS (window)->focus (window, timestamp); - /* Move to the front of the focusing workspace's MRU list. - * We should only be "removing" it from the MRU list if it's - * not already there. Note that it's possible that we might + /* Move to the front of all workspaces' MRU lists the window + * is on. We should only be "removing" it from the MRU list if + * it's already there. Note that it's possible that we might * be processing this FocusIn after we've changed to a * different workspace; we should therefore update the MRU * list only if the window is actually on the active @@ -4610,20 +4610,20 @@ meta_window_focus (MetaWindow *window, meta_window_located_on_workspace (window, workspace_manager->active_workspace)) { - GList *link; + GList *l; - link = g_list_find (workspace_manager->active_workspace->mru_list, - window); - g_assert (link); + for (l = workspace_manager->workspaces; l != NULL; l = l->next) + { + MetaWorkspace *workspace = l->data; + GList *link; - workspace_manager->active_workspace->mru_list = - g_list_remove_link (workspace_manager->active_workspace->mru_list, - link); - g_list_free (link); + link = g_list_find (workspace->mru_list, window); + if (!link) + continue; - workspace_manager->active_workspace->mru_list = - g_list_prepend (workspace_manager->active_workspace->mru_list, - window); + workspace->mru_list = g_list_delete_link (workspace->mru_list, link); + workspace->mru_list = g_list_prepend (workspace->mru_list, window); + } } backend = meta_get_backend ();