Merge pull request #59535 from floppyhammer/fix-project-manager-window-size

Fix project manager window size not applying display scale correctly
This commit is contained in:
Rémi Verschelde 2022-03-27 10:36:49 +02:00 committed by GitHub
commit c0f707d2ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2873,10 +2873,16 @@ ProjectManager::ProjectManager() {
Vector2i window_size = DisplayServer::get_singleton()->window_get_size(); Vector2i window_size = DisplayServer::get_singleton()->window_get_size();
Vector2i screen_size = DisplayServer::get_singleton()->screen_get_size(); Vector2i screen_size = DisplayServer::get_singleton()->screen_get_size();
Vector2i screen_position = DisplayServer::get_singleton()->screen_get_position(); Vector2i screen_position = DisplayServer::get_singleton()->screen_get_position();
window_size *= scale_factor;
// Consider the editor display scale.
window_size.x = round((float)window_size.x * scale_factor);
window_size.y = round((float)window_size.y * scale_factor);
// Make the window centered on the screen.
Vector2i window_position; Vector2i window_position;
window_position.x = screen_position.x + (screen_size.x - window_size.x) / 2; window_position.x = screen_position.x + (screen_size.x - window_size.x) / 2;
window_position.y = screen_position.y + (screen_size.y - window_size.y) / 2; window_position.y = screen_position.y + (screen_size.y - window_size.y) / 2;
DisplayServer::get_singleton()->window_set_size(window_size); DisplayServer::get_singleton()->window_set_size(window_size);
DisplayServer::get_singleton()->window_set_position(window_position); DisplayServer::get_singleton()->window_set_position(window_position);
} }