diff --git a/src/core/window.c b/src/core/window.c index 46d44ea4b..28dda785e 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -4575,14 +4575,38 @@ meta_window_make_most_recent (MetaWindow *window) for (l = workspace_manager->workspaces; l != NULL; l = l->next) { MetaWorkspace *workspace = l->data; - GList *link; + GList *self, *link; - link = g_list_find (workspace->mru_list, window); - if (!link) + self = g_list_find (workspace->mru_list, window); + if (!self) continue; - workspace->mru_list = g_list_delete_link (workspace->mru_list, link); - workspace->mru_list = g_list_prepend (workspace->mru_list, window); + /* + * Move to the front of the MRU list if the window is on the + * active workspace or was explicitly made sticky + */ + if (workspace == workspace_manager->active_workspace || + window->on_all_workspaces_requested) + { + workspace->mru_list = g_list_delete_link (workspace->mru_list, self); + workspace->mru_list = g_list_prepend (workspace->mru_list, window); + continue; + } + + /* Otherwise move it before other sticky windows */ + for (link = workspace->mru_list; link; link = link->next) + { + MetaWindow *mru_window = link->data; + + if (mru_window->workspace == NULL) + break; + } + + if (link == self) + continue; + + workspace->mru_list = g_list_delete_link (workspace->mru_list, self); + workspace->mru_list = g_list_insert_before (workspace->mru_list, link, window); } }