mirror of
https://github.com/godotengine/godot.git
synced 2024-11-23 12:43:43 +00:00
Fix invalid popup position for embedded popups
This commit is contained in:
parent
e69b7083d4
commit
2237df6273
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user