Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix project manager window size when EDSCALE is not 1.0. #101576

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions editor/project_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void ProjectManager::_build_icon_type_cache(Ref<Theme> p_theme) {

// Main layout.

void ProjectManager::_update_size_limits() {
void ProjectManager::_update_size_limits(bool p_custom_res) {
const Size2 minimum_size = Size2(720, 450) * EDSCALE;
const Size2 default_size = Size2(DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT) * EDSCALE;

Expand All @@ -159,20 +159,21 @@ void ProjectManager::_update_size_limits() {
// Calling Window methods this early doesn't sync properties with DS.
w->set_min_size(minimum_size);
DisplayServer::get_singleton()->window_set_min_size(minimum_size);
if (DisplayServer::get_singleton()->window_get_size() == default_size) {
if (!p_custom_res) {
// Only set window size if it currently matches the default, which is defined in `main/main.cpp`.
// This allows CLI arguments to override the window size.
w->set_size(default_size);
DisplayServer::get_singleton()->window_set_size(default_size);
}
}
Size2 real_size = DisplayServer::get_singleton()->window_get_size();

Rect2i screen_rect = DisplayServer::get_singleton()->screen_get_usable_rect(DisplayServer::get_singleton()->window_get_current_screen());
if (screen_rect.size != Vector2i()) {
// Center the window on the screen.
Vector2i window_position;
window_position.x = screen_rect.position.x + (screen_rect.size.x - default_size.x) / 2;
window_position.y = screen_rect.position.y + (screen_rect.size.y - default_size.y) / 2;
window_position.x = screen_rect.position.x + (screen_rect.size.x - real_size.x) / 2;
window_position.y = screen_rect.position.y + (screen_rect.size.y - real_size.y) / 2;
DisplayServer::get_singleton()->window_set_position(window_position);

// Limit popup menus to prevent unusably long lists.
Expand Down Expand Up @@ -1152,7 +1153,7 @@ void ProjectManager::_titlebar_resized() {

// Object methods.

ProjectManager::ProjectManager() {
ProjectManager::ProjectManager(bool p_custom_res) {
singleton = this;

set_translation_domain("godot.editor");
Expand Down Expand Up @@ -1740,7 +1741,7 @@ ProjectManager::ProjectManager() {
title_bar->connect(SceneStringName(item_rect_changed), callable_mp(this, &ProjectManager::_titlebar_resized));
}

_update_size_limits();
_update_size_limits(p_custom_res);
}

ProjectManager::~ProjectManager() {
Expand Down
4 changes: 2 additions & 2 deletions editor/project_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ProjectManager : public Control {

Ref<Theme> theme;

void _update_size_limits();
void _update_size_limits(bool p_custom_res);
void _update_theme(bool p_skip_creation = false);
void _titlebar_resized();

Expand Down Expand Up @@ -262,7 +262,7 @@ class ProjectManager : public Control {

void add_new_tag(const String &p_tag);

ProjectManager();
ProjectManager(bool p_custom_res);
~ProjectManager();
};

Expand Down
6 changes: 3 additions & 3 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ static bool init_use_custom_pos = false;
static bool init_use_custom_screen = false;
static Vector2 init_custom_pos;
static int64_t init_embed_parent_window_id = 0;
static bool use_custom_res = true;
static bool force_res = false;

// Debug

Expand Down Expand Up @@ -1019,8 +1021,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
String remotefs_pass;

Vector<String> breakpoints;
bool use_custom_res = true;
bool force_res = false;
bool delta_smoothing_override = false;

String default_renderer = "";
Expand Down Expand Up @@ -4318,7 +4318,7 @@ int Main::start() {
translation_server->get_editor_domain()->set_pseudolocalization_enabled(true);
}

ProjectManager *pmanager = memnew(ProjectManager);
ProjectManager *pmanager = memnew(ProjectManager(force_res || use_custom_res));
ProgressDialog *progress_dialog = memnew(ProgressDialog);
pmanager->add_child(progress_dialog);

Expand Down