From 5de44898d9d86378e1ebfecc4d69e314268c40a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sat, 16 Sep 2023 18:28:19 +0200 Subject: [PATCH] shell/app: Adapt to focus changes in mutter meta_window_raise_and_make_recent() now only works as advertised for windows on the active workspace. That results in the following unexpected behavior: 1. open two windows of an app (say: terminal) 2. open another app, maximize the window for best effect 3. switch to another workspace 4. super+tab to the first app: both windows are raised 5. close the window; instead of moving focus to the 2nd app window, both windows disappear because focus is moved to the app from 2 This was fixed with new mutter API on the main branch, but for the stable branch it is easier to work around the issue. Part-of: --- src/shell-app.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/shell-app.c b/src/shell-app.c index c164e4eeb..6edb66d36 100644 --- a/src/shell-app.c +++ b/src/shell-app.c @@ -449,20 +449,6 @@ shell_app_activate_window (ShellApp *app, return; } - /* Now raise all the other windows for the app that are on - * the same workspace, in reverse order to preserve the stacking. - */ - windows_reversed = g_slist_copy (windows); - windows_reversed = g_slist_reverse (windows_reversed); - for (iter = windows_reversed; iter; iter = iter->next) - { - MetaWindow *other_window = iter->data; - - if (other_window != window && meta_window_get_workspace (other_window) == workspace) - meta_window_raise_and_make_recent (other_window); - } - g_slist_free (windows_reversed); - /* If we have a transient that the user's interacted with more recently than * the window, pick that. */ @@ -474,10 +460,23 @@ shell_app_activate_window (ShellApp *app, window = most_recent_transient; + /* First activate the window, so that we are on the correct + * workspace when raising other windows + */ if (active != workspace) meta_workspace_activate_with_focus (workspace, window, timestamp); else meta_window_activate (window, timestamp); + + /* Now raise all the windows for the app in reverse order to + * preserve the stacking. This only has an effect for windows + * on the current workspace + */ + windows_reversed = g_slist_copy (windows); + windows_reversed = g_slist_reverse (windows_reversed); + for (iter = windows_reversed; iter; iter = iter->next) + meta_window_raise_and_make_recent (META_WINDOW (iter->data)); + g_slist_free (windows_reversed); } }