diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 4b89167ce99a..81bc4af674eb 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -348,7 +348,13 @@ void Viewport::_sub_window_update(Window *p_window) { close_icon->draw(sw.canvas_item, r.position + Vector2(r.size.width - close_h_ofs, -close_v_ofs)); } - RS::get_singleton()->canvas_item_add_texture_rect(sw.canvas_item, r, sw.window->get_texture()->get_rid()); + const Transform2D xform = sw.window->window_transform * sw.window->stretch_transform; + Rect2 vr = xform.xform(sw.window->get_visible_rect()); + vr.position += p_window->get_position(); + if (vr != r) { + RS::get_singleton()->canvas_item_add_rect(sw.canvas_item, r, Color()); + } + RS::get_singleton()->canvas_item_add_texture_rect(sw.canvas_item, vr, sw.window->get_texture()->get_rid()); } void Viewport::_sub_window_grab_focus(Window *p_window) { diff --git a/scene/main/window.cpp b/scene/main/window.cpp index 71fac3df9918..154d4d199d8a 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -1239,7 +1239,7 @@ void Window::_update_viewport_size() { if (window_id != DisplayServer::INVALID_WINDOW_ID) { RenderingServer::get_singleton()->viewport_attach_to_screen(get_viewport_rid(), attach_to_screen_rect, window_id); - } else { + } else if (!is_embedded()) { RenderingServer::get_singleton()->viewport_attach_to_screen(get_viewport_rid(), Rect2i(), DisplayServer::INVALID_WINDOW_ID); }