workspace: Focus on existing focused window if possible
If we have an existing focused window that may have focus, default focus will leave the focus there. An unmanaging window for example must not have focus and default focus will continue to select another window in this case. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3258>
This commit is contained in:
parent
87907674f5
commit
8a1388c930
@ -1310,15 +1310,42 @@ meta_workspace_get_name (MetaWorkspace *workspace)
|
||||
return meta_prefs_get_workspace_name (meta_workspace_index (workspace));
|
||||
}
|
||||
|
||||
static MetaWindow *
|
||||
workspace_find_focused_window (MetaWorkspace *workspace)
|
||||
{
|
||||
GList *l;
|
||||
|
||||
for (l = workspace->windows; l != NULL; l = l->next)
|
||||
{
|
||||
MetaWindow *win = l->data;
|
||||
|
||||
if (meta_window_has_focus (win))
|
||||
return win;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
meta_workspace_focus_default_window (MetaWorkspace *workspace,
|
||||
MetaWindow *not_this_one,
|
||||
guint32 timestamp)
|
||||
{
|
||||
MetaWindow *window = NULL;
|
||||
MetaWindow *current_focus_window = NULL;
|
||||
|
||||
if (timestamp == META_CURRENT_TIME)
|
||||
meta_warning ("META_CURRENT_TIME used to choose focus window; "
|
||||
"focus window may not be correct.");
|
||||
|
||||
current_focus_window = workspace_find_focused_window (workspace);
|
||||
|
||||
if (current_focus_window)
|
||||
{
|
||||
focus_ancestor_or_mru_window (workspace, not_this_one, timestamp);
|
||||
return;
|
||||
}
|
||||
|
||||
if (meta_prefs_get_focus_mode () == G_DESKTOP_FOCUS_MODE_CLICK ||
|
||||
!workspace->display->mouse_mode)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user