From 23b98db00401a75397da16ad52555a604e34e853 Mon Sep 17 00:00:00 2001 From: Brendan William Date: Fri, 16 Jun 2023 19:43:23 -0700 Subject: [PATCH] core: Never automatically switch focus in strict focus mode With window_is_terminal gone, "strict" and "smart" focus mode have no behavioural difference. Let's broaden the scope of strict focus mode, such that windows never automatically focus unless they are an ancestor to the transient. Part-of: --- src/core/window.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/core/window.c b/src/core/window.c index a8e17c467..038aaa907 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -2006,6 +2006,20 @@ window_state_on_map (MetaWindow *window, return; } + /* When strict focus mode is enabled, prevent new windows from taking + * focus unless they are ancestors to the transient. + */ + if (*takes_focus && + meta_prefs_get_focus_new_windows () == G_DESKTOP_FOCUS_NEW_WINDOWS_STRICT && + !meta_window_is_ancestor_of_transient (window->display->focus_window, + window)) + { + meta_topic (META_DEBUG_FOCUS, + "new window is not an ancestor to transient; not taking focus."); + *takes_focus = FALSE; + *places_on_top = FALSE; + } + switch (window->type) { case META_WINDOW_UTILITY: