summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-10-04 11:19:50 +0200
committerRémi Verschelde <rverschelde@gmail.com>2022-10-04 11:19:50 +0200
commit1c6e8f7e6236b0606342fb5bb415f53b366c0bc6 (patch)
treec264298c2cf2f1bbce0a98670b1de1ba9ea5dcb5
parentb7c68b343df374596ce3bf87a30a714d4881b7b9 (diff)
parent2237df62734c28c9a1dc3f8c50bf969bd743a126 (diff)
Merge pull request #66712 from Cykyrios/fix-invalid-popup-position
Fix invalid popup position for embedded popups
-rw-r--r--scene/main/window.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
index 64869b2936..f7099f3765 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -1264,12 +1264,16 @@ void Window::popup(const Rect2i &p_screen_rect) {
set_transient(true);
set_visible(true);
- int screen_id = DisplayServer::get_singleton()->window_get_current_screen(get_window_id());
- Rect2i screen_rect = DisplayServer::get_singleton()->screen_get_usable_rect(screen_id);
- if (screen_rect != Rect2i() && !screen_rect.intersects(Rect2i(position, size))) {
+ Rect2i parent_rect;
+ if (is_embedded()) {
+ parent_rect = _get_embedder()->get_visible_rect();
+ } else {
+ int screen_id = DisplayServer::get_singleton()->window_get_current_screen(get_window_id());
+ parent_rect = DisplayServer::get_singleton()->screen_get_usable_rect(screen_id);
+ }
+ if (parent_rect != Rect2i() && !parent_rect.intersects(Rect2i(position, size))) {
ERR_PRINT(vformat("Window %d spawned at invalid position: %s.", get_window_id(), position));
- // Window appeared on unavailable screen area, so force it to the center.
- set_position(screen_rect.size / 2 - size / 2);
+ set_position((parent_rect.size - size) / 2);
}
_post_popup();