summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaverio Miroddi <[email protected]>2026-04-28 19:41:11 +0200
committerVictor Kareh <[email protected]>2026-05-27 16:02:51 -0400
commit61a931b17f7694dcd49a0657d8746fbdac3e4e91 (patch)
tree05c46655e89bf6894d497cc8314b55a5f400b701
parent220296b67ec2355128a6f98dfc6252d093465c0c (diff)
downloadmarco-61a931b17f7694dcd49a0657d8746fbdac3e4e91.tar.bz2
marco-61a931b17f7694dcd49a0657d8746fbdac3e4e91.tar.xz
window: focus modal dialogs whose ancestor is focused
Fixes #784. Commit 6ea23df ("window: do not unfocus on new window") imported the Metacity bf17c79 / Mutter 998d921d behavior for GNOME Bugzilla #773210: when a new transient maps without taking focus, keep focus on the parent so GTK popup and completion windows and VLC fullscreen controls do not steal keyboard focus. That blanket change also affected modal dialogs whose parent already has focus. Electron and GTK file chooser dialogs can reach meta_window_show() with takes_focus_on_map false because their _NET_WM_USER_TIME is missing or stale. Since 6ea23df, such dialogs are mapped above the parent but keyboard focus stays on the parent, so typing goes to the wrong window. Keep the bf17c79-equivalent behavior for non-modal transients, but when the new window is a META_WINDOW_MODAL_DIALOG whose ancestor is the current focus window, force takes_focus_on_map so the blocking dialog receives keyboard focus immediately.
-rw-r--r--src/core/window.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/core/window.c b/src/core/window.c
index 75e48f04..37a76238 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -2158,6 +2158,14 @@ meta_window_show (MetaWindow *window)
if (!window->placed)
window->denied_focus_and_not_transient = TRUE;
}
+ else if (window->type == META_WINDOW_MODAL_DIALOG)
+ {
+ /* Keep the non-modal transient behavior from 6ea23df for GTK
+ * popups and VLC controls, but focus modal dialogs that block
+ * the focused ancestor.
+ */
+ takes_focus_on_map = TRUE;
+ }
}
if (!window->placed)