diff options
Diffstat (limited to 'scene/main/window.cpp')
-rw-r--r-- | scene/main/window.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/scene/main/window.cpp b/scene/main/window.cpp index 26aa06e1a4..b82b215e54 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -776,6 +776,9 @@ void Window::set_visible(bool p_visible) { } else { if (visible) { embedder = embedder_vp; + if (initial_position != WINDOW_INITIAL_POSITION_ABSOLUTE) { + position = (embedder->get_visible_rect().size - size) / 2; + } embedder->_sub_window_register(this); RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE); } else { @@ -1163,6 +1166,9 @@ void Window::_notification(int p_what) { if (embedded) { // Create as embedded. if (embedder) { + if (initial_position != WINDOW_INITIAL_POSITION_ABSOLUTE) { + position = (embedder->get_visible_rect().size - size) / 2; + } embedder->_sub_window_register(this); RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE); _update_window_size(); @@ -1768,7 +1774,7 @@ Rect2i Window::get_usable_parent_rect() const { } else { const Window *w = is_visible() ? this : get_parent_visible_window(); //find a parent that can contain us - ERR_FAIL_COND_V(!w, Rect2()); + ERR_FAIL_NULL_V(w, Rect2()); parent_rect = DisplayServer::get_singleton()->screen_get_usable_rect(DisplayServer::get_singleton()->window_get_current_screen(w->get_window_id())); } @@ -2329,9 +2335,9 @@ Rect2i Window::get_parent_rect() const { if (is_embedded()) { //viewport Node *n = get_parent(); - ERR_FAIL_COND_V(!n, Rect2i()); + ERR_FAIL_NULL_V(n, Rect2i()); Viewport *p = n->get_viewport(); - ERR_FAIL_COND_V(!p, Rect2i()); + ERR_FAIL_NULL_V(p, Rect2i()); return p->get_visible_rect(); } else { @@ -2475,6 +2481,14 @@ Transform2D Window::get_popup_base_transform() const { return popup_base_transform; } +bool Window::is_directly_attached_to_screen() const { + if (get_embedder()) { + return get_embedder()->is_directly_attached_to_screen(); + } + // Distinguish between the case that this is a native Window and not inside the tree. + return is_inside_tree(); +} + void Window::_bind_methods() { ClassDB::bind_method(D_METHOD("set_title", "title"), &Window::set_title); ClassDB::bind_method(D_METHOD("get_title"), &Window::get_title); |