Skip to content

Commit

Permalink
Merge pull request #80117 from Sauermann/fix-actually-store-safe-rect
Browse files Browse the repository at this point in the history
Actually store safe-rect in embedder
  • Loading branch information
YuriSizov authored Aug 2, 2023
2 parents 79f6ac5 + 1e9d241 commit 237bd0a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 1 addition & 2 deletions scene/main/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3637,8 +3637,7 @@ void Viewport::subwindow_set_popup_safe_rect(Window *p_window, const Rect2i &p_r
int index = _sub_window_find(p_window);
ERR_FAIL_COND(index == -1);

SubWindow sw = gui.sub_windows[index];
sw.parent_safe_rect = p_rect;
gui.sub_windows.write[index].parent_safe_rect = p_rect;
}

Rect2i Viewport::subwindow_get_popup_safe_rect(Window *p_window) const {
Expand Down
15 changes: 15 additions & 0 deletions tests/scene/test_viewport.h
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,21 @@ TEST_CASE("[SceneTree][Viewport] Control mouse cursor shape") {
}
}

TEST_CASE("[SceneTree][Viewport] Embedded Windows") {
Window *root = SceneTree::get_singleton()->get_root();
Window *w = memnew(Window);

SUBCASE("[Viewport] Safe-rect of embedded Window") {
root->add_child(w);
root->subwindow_set_popup_safe_rect(w, Rect2i(10, 10, 10, 10));
CHECK_EQ(root->subwindow_get_popup_safe_rect(w), Rect2i(10, 10, 10, 10));
root->remove_child(w);
CHECK_EQ(root->subwindow_get_popup_safe_rect(w), Rect2i());
}

memdelete(w);
}

} // namespace TestViewport

#endif // TEST_VIEWPORT_H

0 comments on commit 237bd0a

Please sign in to comment.