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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2959>
This commit is contained in:
Florian Müllner 2023-09-16 18:28:19 +02:00
parent 92780927cd
commit 5de44898d9

View file

@ -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);
}
}