summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2022-02-21 10:17:28 +0200
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2022-04-20 11:10:33 +0300
commitdefcd0c57e8b90177639963e958ea91be4c511bc (patch)
treefc461370784c8f8241758f1936609b63b010dac1 /scene
parentf4b0c7a1ea8d86c1dfd96478ca12ad1360903d9d (diff)
Avoid setting sub-window or started project window positions, if it's impossible to get screen rect.
Diffstat (limited to 'scene')
-rw-r--r--scene/main/window.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
index 8b1a4680d2..6feccb7eec 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -1045,7 +1045,9 @@ void Window::popup_centered_clamped(const Size2i &p_size, float p_fallback_ratio
Rect2i popup_rect;
popup_rect.size = Vector2i(MIN(size_ratio.x, p_size.x), MIN(size_ratio.y, p_size.y));
- popup_rect.position = parent_rect.position + (parent_rect.size - popup_rect.size) / 2;
+ if (parent_rect != Rect2()) {
+ popup_rect.position = parent_rect.position + (parent_rect.size - popup_rect.size) / 2;
+ }
popup(popup_rect);
}
@@ -1069,7 +1071,10 @@ void Window::popup_centered(const Size2i &p_minsize) {
Size2 contents_minsize = _get_contents_minimum_size();
popup_rect.size.x = MAX(p_minsize.x, contents_minsize.x);
popup_rect.size.y = MAX(p_minsize.y, contents_minsize.y);
- popup_rect.position = parent_rect.position + (parent_rect.size - popup_rect.size) / 2;
+
+ if (parent_rect != Rect2()) {
+ popup_rect.position = parent_rect.position + (parent_rect.size - popup_rect.size) / 2;
+ }
popup(popup_rect);
}
@@ -1091,8 +1096,10 @@ void Window::popup_centered_ratio(float p_ratio) {
}
Rect2i popup_rect;
- popup_rect.size = parent_rect.size * p_ratio;
- popup_rect.position = parent_rect.position + (parent_rect.size - popup_rect.size) / 2;
+ if (parent_rect != Rect2()) {
+ popup_rect.size = parent_rect.size * p_ratio;
+ popup_rect.position = parent_rect.position + (parent_rect.size - popup_rect.size) / 2;
+ }
popup(popup_rect);
}