mirror of
https://github.com/brl/mutter.git
synced 2024-11-30 03:50:47 -05:00
workspace: Focus only ancestors that are focusable
When destroying a window that has a parent, we initially try to focus one of
its ancestors. However if no ancestor can be focused, then we should instead
focus the default focus window instead of trying to request focus for a window
that can't get focus anyways.
Fixes https://gitlab.gnome.org/GNOME/mutter/issues/308
(cherry picked from commit eccc791f3b
)
This commit is contained in:
parent
d792a320be
commit
b95700dabc
@ -86,6 +86,12 @@ typedef struct _MetaWorkspaceLogicalMonitorData
|
|||||||
MetaRectangle logical_monitor_work_area;
|
MetaRectangle logical_monitor_work_area;
|
||||||
} MetaWorkspaceLogicalMonitorData;
|
} MetaWorkspaceLogicalMonitorData;
|
||||||
|
|
||||||
|
typedef struct _MetaWorkspaceFocusableAncestorData
|
||||||
|
{
|
||||||
|
MetaWorkspace *workspace;
|
||||||
|
MetaWindow *out_window;
|
||||||
|
} MetaWorkspaceFocusableAncestorData;
|
||||||
|
|
||||||
static MetaWorkspaceLogicalMonitorData *
|
static MetaWorkspaceLogicalMonitorData *
|
||||||
meta_workspace_get_logical_monitor_data (MetaWorkspace *workspace,
|
meta_workspace_get_logical_monitor_data (MetaWorkspace *workspace,
|
||||||
MetaLogicalMonitor *logical_monitor)
|
MetaLogicalMonitor *logical_monitor)
|
||||||
@ -1327,13 +1333,20 @@ meta_workspace_focus_default_window (MetaWorkspace *workspace,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
record_ancestor (MetaWindow *window,
|
find_focusable_ancestor (MetaWindow *window,
|
||||||
void *data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
MetaWindow **result = data;
|
MetaWorkspaceFocusableAncestorData *data = user_data;
|
||||||
|
|
||||||
*result = window;
|
if (!window->unmanaging && (window->input || window->take_focus) &&
|
||||||
return FALSE; /* quit with the first ancestor we find */
|
meta_window_located_on_workspace (window, data->workspace) &&
|
||||||
|
meta_window_showing_on_its_workspace (window))
|
||||||
|
{
|
||||||
|
data->out_window = window;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Focus ancestor of not_this_one if there is one */
|
/* Focus ancestor of not_this_one if there is one */
|
||||||
@ -1355,11 +1368,15 @@ focus_ancestor_or_top_window (MetaWorkspace *workspace,
|
|||||||
if (not_this_one)
|
if (not_this_one)
|
||||||
{
|
{
|
||||||
MetaWindow *ancestor;
|
MetaWindow *ancestor;
|
||||||
ancestor = NULL;
|
MetaWorkspaceFocusableAncestorData data;
|
||||||
meta_window_foreach_ancestor (not_this_one, record_ancestor, &ancestor);
|
|
||||||
if (ancestor != NULL &&
|
data = (MetaWorkspaceFocusableAncestorData) {
|
||||||
meta_window_located_on_workspace (ancestor, workspace) &&
|
.workspace = workspace,
|
||||||
meta_window_showing_on_its_workspace (ancestor))
|
};
|
||||||
|
meta_window_foreach_ancestor (not_this_one, find_focusable_ancestor, &data);
|
||||||
|
ancestor = data.out_window;
|
||||||
|
|
||||||
|
if (ancestor)
|
||||||
{
|
{
|
||||||
meta_topic (META_DEBUG_FOCUS,
|
meta_topic (META_DEBUG_FOCUS,
|
||||||
"Focusing %s, ancestor of %s\n",
|
"Focusing %s, ancestor of %s\n",
|
||||||
|
Loading…
Reference in New Issue
Block a user