diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-01 11:07:39 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-01 11:07:39 +0100 |
commit | 707ccc09ab73ef68211e732762c1f4535d6a85a0 (patch) | |
tree | ec7efa70b21b832c13bb0d482fcc968cfe194862 /platform | |
parent | 061b0464014075d779b3679901a61c137746de34 (diff) | |
parent | 700d85bd19268c17961f5853bf4f46a22ce7e19b (diff) |
Merge pull request #72104 from bruvzg/popup-non-popups
Extend special popup window handling to any non-popup child of a popup.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/linuxbsd/x11/display_server_x11.cpp | 17 | ||||
-rw-r--r-- | platform/macos/display_server_macos.mm | 17 | ||||
-rw-r--r-- | platform/windows/display_server_windows.cpp | 19 |
3 files changed, 49 insertions, 4 deletions
diff --git a/platform/linuxbsd/x11/display_server_x11.cpp b/platform/linuxbsd/x11/display_server_x11.cpp index 1c4b8ffc9f..8377e81a53 100644 --- a/platform/linuxbsd/x11/display_server_x11.cpp +++ b/platform/linuxbsd/x11/display_server_x11.cpp @@ -3672,8 +3672,23 @@ Rect2i DisplayServerX11::window_get_popup_safe_rect(WindowID p_window) const { void DisplayServerX11::popup_open(WindowID p_window) { _THREAD_SAFE_METHOD_ + bool has_popup_ancestor = false; + WindowID transient_root = p_window; + while (true) { + WindowID parent = windows[transient_root].transient_parent; + if (parent == INVALID_WINDOW_ID) { + break; + } else { + transient_root = parent; + if (windows[parent].is_popup) { + has_popup_ancestor = true; + break; + } + } + } + WindowData &wd = windows[p_window]; - if (wd.is_popup) { + if (wd.is_popup || has_popup_ancestor) { // Find current popup parent, or root popup if new window is not transient. List<WindowID>::Element *C = nullptr; List<WindowID>::Element *E = popup_list.back(); diff --git a/platform/macos/display_server_macos.mm b/platform/macos/display_server_macos.mm index 2832495693..b1880c2fb6 100644 --- a/platform/macos/display_server_macos.mm +++ b/platform/macos/display_server_macos.mm @@ -3681,8 +3681,23 @@ Rect2i DisplayServerMacOS::window_get_popup_safe_rect(WindowID p_window) const { void DisplayServerMacOS::popup_open(WindowID p_window) { _THREAD_SAFE_METHOD_ + bool has_popup_ancestor = false; + WindowID transient_root = p_window; + while (true) { + WindowID parent = windows[transient_root].transient_parent; + if (parent == INVALID_WINDOW_ID) { + break; + } else { + transient_root = parent; + if (windows[parent].is_popup) { + has_popup_ancestor = true; + break; + } + } + } + WindowData &wd = windows[p_window]; - if (wd.is_popup) { + if (wd.is_popup || has_popup_ancestor) { bool was_empty = popup_list.is_empty(); // Find current popup parent, or root popup if new window is not transient. List<WindowID>::Element *C = nullptr; diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index cc230575c8..777d05584c 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -2360,8 +2360,23 @@ Rect2i DisplayServerWindows::window_get_popup_safe_rect(WindowID p_window) const void DisplayServerWindows::popup_open(WindowID p_window) { _THREAD_SAFE_METHOD_ - const WindowData &wd = windows[p_window]; - if (wd.is_popup) { + bool has_popup_ancestor = false; + WindowID transient_root = p_window; + while (true) { + WindowID parent = windows[transient_root].transient_parent; + if (parent == INVALID_WINDOW_ID) { + break; + } else { + transient_root = parent; + if (windows[parent].is_popup) { + has_popup_ancestor = true; + break; + } + } + } + + WindowData &wd = windows[p_window]; + if (wd.is_popup || has_popup_ancestor) { // Find current popup parent, or root popup if new window is not transient. List<WindowID>::Element *C = nullptr; List<WindowID>::Element *E = popup_list.back(); |