diff options
author | Sebastian Wick <sebastian.wick@redhat.com> | 2022-12-07 18:19:39 +0100 |
---|---|---|
committer | Robert Mader <robert.mader@collabora.com> | 2023-01-06 13:50:41 +0100 |
commit | d5dd42694d64b4cc8fac65aeb937471af8bdf27b (patch) | |
tree | 9a1fd0a850d326a8061011e75ff02118fe2694e8 | |
parent | 5594986e05a4f6a24eee059a4369af17d81850b6 (diff) | |
download | mutter-d5dd42694d64b4cc8fac65aeb937471af8bdf27b.tar.gz |
workspace: Focus the default window only if no window is focused
This might happen when the workspace is not switched and
focus_default_window is called or when 'workspace on primary display
only' is enabled, a secondary display exists and the workspace is
switched.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2747>
(cherry picked from commit 058981dc12b294b84040147eab247ac72da3011c)
-rw-r--r-- | src/core/workspace.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/core/workspace.c b/src/core/workspace.c index 03b177e55..c1360a4c4 100644 --- a/src/core/workspace.c +++ b/src/core/workspace.c @@ -1316,15 +1316,40 @@ meta_workspace_get_name (MetaWorkspace *workspace) return meta_prefs_get_workspace_name (meta_workspace_index (workspace)); } +static MetaWindow * +get_focused_workspace_window (MetaWorkspace *workspace) +{ + g_autoptr (GList) windows = NULL; + GList *l; + + windows = meta_workspace_list_windows (workspace); + + for (l = windows; l != NULL; l = l->next) + { + MetaWindow *window = l->data; + + if (meta_window_has_focus (window)) + return window; + } + + return NULL; +} + void meta_workspace_focus_default_window (MetaWorkspace *workspace, MetaWindow *not_this_one, guint32 timestamp) { + MetaWindow *focus; + if (timestamp == META_CURRENT_TIME) meta_warning ("META_CURRENT_TIME used to choose focus window; " "focus window may not be correct."); + focus = get_focused_workspace_window (workspace); + if (focus != NULL && focus != not_this_one) + return; + if (meta_prefs_get_focus_mode () == G_DESKTOP_FOCUS_MODE_CLICK || !workspace->display->mouse_mode) { |