Skip to content

Commit

Permalink
Fix displaying of embedded Window
Browse files Browse the repository at this point in the history
Fix Rect of texture to take window and stretch transform into account.

There is no need for `viewport_attach_to_screen` for embedded windows,
since their display is handled via `Viewport::_sub_window_update`.
  • Loading branch information
Sauermann committed Dec 17, 2024
1 parent 4364ed6 commit 0eff41d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion scene/main/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion scene/main/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 0eff41d

Please sign in to comment.