mirror of
https://github.com/godotengine/godot.git
synced 2024-11-10 22:23:07 +00:00
Merge pull request #61336 from KoBeWi/where_are_you_going
Force window position if spawned outside screen
This commit is contained in:
commit
6fcf2a2862
@ -1251,6 +1251,15 @@ 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))) {
|
||||
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);
|
||||
}
|
||||
|
||||
_post_popup();
|
||||
notification(NOTIFICATION_POST_POPUP);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user