diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-08-29 08:19:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-29 08:19:50 +0200 |
commit | c08e84af0d52fa9bce1145ba2c22c7452b7d8997 (patch) | |
tree | f9c75de89758adce230fecbb690bca4da932e147 /platform | |
parent | f647292df56aa3da126e16306ad2f863643c8bb3 (diff) | |
parent | 93af2993f042b02ce75032affd13ed7c21e70a6f (diff) |
Merge pull request #64943 from MatthewZelriche/FixUnMappedAncestor
Diffstat (limited to 'platform')
-rw-r--r-- | platform/linuxbsd/display_server_x11.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index 63998e2fde..cacb9d2a27 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -1522,11 +1522,15 @@ void DisplayServerX11::window_set_transient(WindowID p_window, WindowID p_parent XSetTransientForHint(x11_display, wd_window.x11_window, None); + XWindowAttributes xwa; + XSync(x11_display, False); + XGetWindowAttributes(x11_display, wd_parent.x11_window, &xwa); + // Set focus to parent sub window to avoid losing all focus when closing a nested sub-menu. // RevertToPointerRoot is used to make sure we don't lose all focus in case // a subwindow and its parent are both destroyed. if (!wd_window.no_focus && !wd_window.is_popup && wd_window.focused) { - if (!wd_parent.no_focus && !wd_window.is_popup) { + if ((xwa.map_state == IsViewable) && !wd_parent.no_focus && !wd_window.is_popup) { XSetInputFocus(x11_display, wd_parent.x11_window, RevertToPointerRoot, CurrentTime); } } @@ -3646,10 +3650,14 @@ void DisplayServerX11::process_events() { const WindowData &wd = windows[window_id]; + XWindowAttributes xwa; + XSync(x11_display, False); + XGetWindowAttributes(x11_display, wd.x11_window, &xwa); + // Set focus when menu window is started. // RevertToPointerRoot is used to make sure we don't lose all focus in case // a subwindow and its parent are both destroyed. - if (!wd.no_focus && !wd.is_popup) { + if ((xwa.map_state == IsViewable) && !wd.no_focus && !wd.is_popup) { XSetInputFocus(x11_display, wd.x11_window, RevertToPointerRoot, CurrentTime); } } break; |