diff options
author | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2022-10-03 20:19:38 +0300 |
---|---|---|
committer | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2022-10-03 20:19:38 +0300 |
commit | 398fa63cff7b791e78c0a7b7e2234b0344959819 (patch) | |
tree | 88944767a32f3ee951f366f85918bad071af1c7c | |
parent | abcbdcce1e67a7c652a21c7578aba69e1bda08c4 (diff) | |
download | metacity-398fa63cff7b791e78c0a7b7e2234b0344959819.tar.gz |
workspace: focus only ancestors that are focusable
Based on mutter commit:
https://gitlab.gnome.org/GNOME/mutter/-/commit/eccc791f3b3451216f957e67fec47a73b65ed2b2
-rw-r--r-- | src/core/workspace.c | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/src/core/workspace.c b/src/core/workspace.c index 19e3a9a8..45306dd6 100644 --- a/src/core/workspace.c +++ b/src/core/workspace.c @@ -969,14 +969,30 @@ meta_workspace_focus_default_window (MetaWorkspace *workspace, } } +typedef struct +{ + MetaWorkspace *workspace; + MetaWindow *ancestor; +} FindFocusableAncestorData; + static gboolean -record_ancestor (MetaWindow *window, - void *data) +find_focusable_ancestor (MetaWindow *window, + gpointer user_data) { - MetaWindow **result = data; + FindFocusableAncestorData *data; - *result = window; - return FALSE; /* quit with the first ancestor we find */ + data = user_data; + + if (!window->unmanaging && + meta_window_is_focusable (window) && + meta_window_located_on_workspace (window, data->workspace) && + meta_window_showing_on_its_workspace (window)) + { + data->ancestor = window; + return FALSE; + } + + return TRUE; } /* Focus ancestor of not_this_one if there is one */ @@ -998,8 +1014,17 @@ focus_ancestor_or_top_window (MetaWorkspace *workspace, if (not_this_one) { MetaWindow *ancestor; - ancestor = NULL; - meta_window_foreach_ancestor (not_this_one, record_ancestor, &ancestor); + FindFocusableAncestorData data; + + data.workspace = workspace; + data.ancestor = NULL; + + meta_window_foreach_ancestor (not_this_one, + find_focusable_ancestor, + &data); + + ancestor = data.ancestor; + if (ancestor != NULL) { meta_topic (META_DEBUG_FOCUS, |