diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-06-09 11:59:01 +0300 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-06-13 09:56:08 +0300 |
commit | f7269fe878179695869d5a0b49b5a01005dfb5a7 (patch) | |
tree | c6197b0253847879c51038d429bf75b961ec48b8 /scene/main | |
parent | 803d25a20a80de6e3532c6f85a6b54c22c19c305 (diff) |
Single-window mode popups and edited scene windows fixes.
Fix single-window mode popup not closing when OptionBox is clicked.
Fix single-window mode submenus closing when parent menu item, that was used to open it is clicked (using same safe-area logic as platform specific code).
Disallow windows that are part of an edited scene from being set as exclusive or popup to prevent it from locking up the editor.
Diffstat (limited to 'scene/main')
-rw-r--r-- | scene/main/window.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/scene/main/window.cpp b/scene/main/window.cpp index 927ba875d9..1d697a2176 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -165,14 +165,26 @@ void Window::set_flag(Flags p_flag, bool p_enabled) { embedder->_sub_window_update(this); } else if (window_id != DisplayServer::INVALID_WINDOW_ID) { +#ifdef TOOLS_ENABLED + if ((p_flag != FLAG_POPUP) || !(Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_ancestor_of(this))) { + DisplayServer::get_singleton()->window_set_flag(DisplayServer::WindowFlags(p_flag), p_enabled, window_id); + } +#else DisplayServer::get_singleton()->window_set_flag(DisplayServer::WindowFlags(p_flag), p_enabled, window_id); +#endif } } bool Window::get_flag(Flags p_flag) const { ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false); if (window_id != DisplayServer::INVALID_WINDOW_ID) { +#ifdef TOOLS_ENABLED + if ((p_flag != FLAG_POPUP) || !(Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_ancestor_of(this))) { + flags[p_flag] = DisplayServer::get_singleton()->window_get_flag(DisplayServer::WindowFlags(p_flag), window_id); + } +#else flags[p_flag] = DisplayServer::get_singleton()->window_get_flag(DisplayServer::WindowFlags(p_flag), window_id); +#endif } return flags[p_flag]; } @@ -255,7 +267,15 @@ void Window::_make_window() { #endif DisplayServer::get_singleton()->window_set_title(tr_title, window_id); DisplayServer::get_singleton()->window_attach_instance_id(get_instance_id(), window_id); +#ifdef TOOLS_ENABLED + if (!(Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_ancestor_of(this))) { + DisplayServer::get_singleton()->window_set_exclusive(window_id, exclusive); + } else { + DisplayServer::get_singleton()->window_set_exclusive(window_id, false); + } +#else DisplayServer::get_singleton()->window_set_exclusive(window_id, exclusive); +#endif _update_window_size(); @@ -441,6 +461,8 @@ void Window::set_visible(bool p_visible) { ERR_FAIL_COND_MSG(transient_parent->exclusive_child && transient_parent->exclusive_child != this, "Transient parent has another exclusive child."); transient_parent->exclusive_child = this; } +#else + transient_parent->exclusive_child = this; #endif } else { if (transient_parent->exclusive_child == this) { @@ -488,7 +510,13 @@ void Window::_make_transient() { window->transient_children.insert(this); if (is_inside_tree() && is_visible() && exclusive) { if (transient_parent->exclusive_child == nullptr) { +#ifdef TOOLS_ENABLED + if (!(Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_ancestor_of(this))) { + transient_parent->exclusive_child = this; + } +#else transient_parent->exclusive_child = this; +#endif } else if (transient_parent->exclusive_child != this) { ERR_PRINT("Making child transient exclusive, but parent has another exclusive child"); } @@ -531,13 +559,27 @@ void Window::set_exclusive(bool p_exclusive) { exclusive = p_exclusive; if (!embedder && window_id != DisplayServer::INVALID_WINDOW_ID) { +#ifdef TOOLS_ENABLED + if (!(Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_ancestor_of(this))) { + DisplayServer::get_singleton()->window_set_exclusive(window_id, exclusive); + } else { + DisplayServer::get_singleton()->window_set_exclusive(window_id, false); + } +#else DisplayServer::get_singleton()->window_set_exclusive(window_id, exclusive); +#endif } if (transient_parent) { if (p_exclusive && is_inside_tree() && is_visible()) { ERR_FAIL_COND_MSG(transient_parent->exclusive_child && transient_parent->exclusive_child != this, "Transient parent has another exclusive child."); +#ifdef TOOLS_ENABLED + if (!(Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_ancestor_of(this))) { + transient_parent->exclusive_child = this; + } +#else transient_parent->exclusive_child = this; +#endif } else { if (transient_parent->exclusive_child == this) { transient_parent->exclusive_child = nullptr; |