Skip to content

Commit 237bd0a

Browse files
authored
Merge pull request #80117 from Sauermann/fix-actually-store-safe-rect
Actually store safe-rect in embedder
2 parents 79f6ac5 + 1e9d241 commit 237bd0a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

scene/main/viewport.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -3637,8 +3637,7 @@ void Viewport::subwindow_set_popup_safe_rect(Window *p_window, const Rect2i &p_r
36373637
int index = _sub_window_find(p_window);
36383638
ERR_FAIL_COND(index == -1);
36393639

3640-
SubWindow sw = gui.sub_windows[index];
3641-
sw.parent_safe_rect = p_rect;
3640+
gui.sub_windows.write[index].parent_safe_rect = p_rect;
36423641
}
36433642

36443643
Rect2i Viewport::subwindow_get_popup_safe_rect(Window *p_window) const {

tests/scene/test_viewport.h

+15
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,21 @@ TEST_CASE("[SceneTree][Viewport] Control mouse cursor shape") {
756756
}
757757
}
758758

759+
TEST_CASE("[SceneTree][Viewport] Embedded Windows") {
760+
Window *root = SceneTree::get_singleton()->get_root();
761+
Window *w = memnew(Window);
762+
763+
SUBCASE("[Viewport] Safe-rect of embedded Window") {
764+
root->add_child(w);
765+
root->subwindow_set_popup_safe_rect(w, Rect2i(10, 10, 10, 10));
766+
CHECK_EQ(root->subwindow_get_popup_safe_rect(w), Rect2i(10, 10, 10, 10));
767+
root->remove_child(w);
768+
CHECK_EQ(root->subwindow_get_popup_safe_rect(w), Rect2i());
769+
}
770+
771+
memdelete(w);
772+
}
773+
759774
} // namespace TestViewport
760775

761776
#endif // TEST_VIEWPORT_H

0 commit comments

Comments
 (0)