summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorClay John <claynjohn@gmail.com>2022-10-27 10:02:44 -0700
committerGitHub <noreply@github.com>2022-10-27 10:02:44 -0700
commit8fd92ed867a9fddf427d5999b872488c09582c41 (patch)
tree2a196d36a833939fef5d967253437b36d15d56d4 /scene
parente1caa8797baf55d8f3fbb0b64313c4255228b809 (diff)
parentf5a808192b263b7227b448492cc65d9145e18afd (diff)
Merge pull request #64710 from MinusKube/window-size-crash
Prevent windows from having a size greater than device limit
Diffstat (limited to 'scene')
-rw-r--r--scene/main/viewport.cpp1
-rw-r--r--scene/main/window.cpp17
2 files changed, 18 insertions, 0 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 1de3caaa97..ad40346c36 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -1263,6 +1263,7 @@ void Viewport::_gui_show_tooltip() {
Point2 tooltip_offset = ProjectSettings::get_singleton()->get("display/mouse_cursor/tooltip_position_offset");
Rect2 r(gui.tooltip_pos + tooltip_offset, gui.tooltip_popup->get_contents_minimum_size());
+ r.size = r.size.min(panel->get_max_size());
Window *window = gui.tooltip_popup->get_parent_visible_window();
Rect2i vr = window->get_usable_parent_rect();
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
index 8fb497113d..ebb11ecee8 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -587,6 +587,18 @@ bool Window::is_visible() const {
}
void Window::_update_window_size() {
+ // Force window to respect size limitations of rendering server
+ RenderingServer *rendering_server = RenderingServer::get_singleton();
+ if (rendering_server) {
+ Size2i max_window_size = rendering_server->get_maximum_viewport_size();
+
+ if (max_window_size != Size2i()) {
+ size = size.min(max_window_size);
+ min_size = min_size.min(max_window_size);
+ max_size = max_size.min(max_window_size);
+ }
+ }
+
Size2i size_limit;
if (wrap_controls) {
size_limit = get_contents_minimum_size();
@@ -1828,6 +1840,11 @@ void Window::_bind_methods() {
}
Window::Window() {
+ RenderingServer *rendering_server = RenderingServer::get_singleton();
+ if (rendering_server) {
+ max_size = rendering_server->get_maximum_viewport_size();
+ }
+
theme_owner = memnew(ThemeOwner);
RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_DISABLED);
}