From deae8aa7b1e5291257fc60c46275299589913c04 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 13 Jul 2022 16:13:48 +0200 Subject: [PATCH] core/window: Update workspace MRU list earlier We want to use the workspace MRU list to decide the default focus but Globally Active Input clients don't call meta_window_set_focused_internal and therefore don't update the MRU list. Move the update to meta_window_focus instead. Part-of: --- src/core/window.c | 57 +++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/src/core/window.c b/src/core/window.c index 895aa7070..0e27145e0 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -4576,6 +4576,34 @@ 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 + * 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 + * workspace. + */ + if (workspace_manager->active_workspace && + meta_window_located_on_workspace (window, + workspace_manager->active_workspace)) + { + GList *link; + + link = g_list_find (workspace_manager->active_workspace->mru_list, + window); + g_assert (link); + + workspace_manager->active_workspace->mru_list = + g_list_remove_link (workspace_manager->active_workspace->mru_list, + link); + g_list_free (link); + + workspace_manager->active_workspace->mru_list = + g_list_prepend (workspace_manager->active_workspace->mru_list, + window); + } + backend = meta_get_backend (); stage = CLUTTER_STAGE (meta_backend_get_stage (backend)); @@ -5130,41 +5158,12 @@ void meta_window_set_focused_internal (MetaWindow *window, gboolean focused) { - MetaWorkspaceManager *workspace_manager = window->display->workspace_manager; - if (focused) { window->has_focus = TRUE; if (window->override_redirect) return; - /* 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 - * 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 - * workspace. - */ - if (workspace_manager->active_workspace && - meta_window_located_on_workspace (window, - workspace_manager->active_workspace)) - { - GList* link; - link = g_list_find (workspace_manager->active_workspace->mru_list, - window); - g_assert (link); - - workspace_manager->active_workspace->mru_list = - g_list_remove_link (workspace_manager->active_workspace->mru_list, - link); - g_list_free (link); - - workspace_manager->active_workspace->mru_list = - g_list_prepend (workspace_manager->active_workspace->mru_list, - window); - } - if (window->frame) meta_frame_queue_draw (window->frame);