mutter/0003-core-Avoid-focusing-windows-on-map-during-grabs.patch
2023-03-05 13:09:23 -05:00

91 lines
2.8 KiB
Diff

From 6ccd0c2ea3f0628b3ffe8158ec69bee9420e9089 Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Wed, 1 Mar 2023 13:58:13 +0100
Subject: [PATCH 3/3] core: Avoid focusing windows on map during grabs
Normally, mutter implicitly allows a window being shown to take
focus. This is normally desired, except it steals input from
GNOME Shell self. Avoid focusing the just shown window in those
situations.
---
src/core/window.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/core/window.c b/src/core/window.c
index 2ec62c22c..f137e6822 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -1967,60 +1967,69 @@ window_is_terminal (MetaWindow *window)
else if (strcmp (window->res_class, "Terminal") == 0)
return TRUE;
return FALSE;
}
/* This function determines what state the window should have assuming that it
* and the focus_window have no relation
*/
static void
window_state_on_map (MetaWindow *window,
gboolean *takes_focus,
gboolean *places_on_top)
{
gboolean intervening_events;
intervening_events = intervening_user_event_occurred (window);
*takes_focus = !intervening_events;
*places_on_top = *takes_focus;
/* don't initially focus windows that are intended to not accept
* focus
*/
if (!meta_window_is_focusable (window))
{
*takes_focus = FALSE;
return;
}
+ /* Do not focus window on map if input is already taken by the
+ * compositor.
+ */
+ if (!meta_display_windows_are_interactable (window->display))
+ {
+ *takes_focus = FALSE;
+ return;
+ }
+
/* Terminal usage may be different; some users intend to launch
* many apps in quick succession or to just view things in the new
* window while still interacting with the terminal. In that case,
* apps launched from the terminal should not take focus. This
* isn't quite the same as not allowing focus to transfer from
* terminals due to new window map, but the latter is a much easier
* approximation to enforce so we do that.
*/
if (*takes_focus &&
meta_prefs_get_focus_new_windows () == G_DESKTOP_FOCUS_NEW_WINDOWS_STRICT &&
!window->display->allow_terminal_deactivation &&
window_is_terminal (window->display->focus_window) &&
!meta_window_is_ancestor_of_transient (window->display->focus_window,
window))
{
meta_topic (META_DEBUG_FOCUS,
"focus_window is terminal; not focusing new window.");
*takes_focus = FALSE;
*places_on_top = FALSE;
}
switch (window->type)
{
case META_WINDOW_UTILITY:
case META_WINDOW_TOOLBAR:
*takes_focus = FALSE;
*places_on_top = FALSE;
break;
case META_WINDOW_DOCK:
case META_WINDOW_DESKTOP:
--
2.39.2