summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaverio Miroddi <[email protected]>2026-04-28 19:41:11 +0200
committerVictor Kareh <[email protected]>2026-05-15 16:19:10 -0400
commit2dfcf261932e2524d299d09d658b7ab1c81fc61b (patch)
tree24873bb82dd5d81f5ea239b4d7e247ca7a89f1e6
parent1e14943558bdfea72b139ed78851bd53e9fab111 (diff)
downloadmarco-focus-modal-dialogs.tar.bz2
marco-focus-modal-dialogs.tar.xz
window: focus modal dialogs whose ancestor is focusedfocus-modal-dialogs
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 cdf7ab3b..7d82a32d 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)