1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

[DisplayServer] Decouple show_window(MAIN_WINDOW_ID) from DisplayServer constructor, update project manager size/position after DS init.

This commit is contained in:
Pāvels Nadtočajevs
2025-01-23 22:41:37 +02:00
parent fdbf6ecc9f
commit f6891b0305
9 changed files with 74 additions and 23 deletions

View File

@@ -228,6 +228,12 @@ 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;
#ifdef TOOLS_ENABLED
static bool init_display_scale_found = false;
static int init_display_scale = 0;
static float init_custom_scale = 1.0;
static bool init_expand_to_title = false;
#endif
static bool use_custom_res = true;
static bool force_res = false;
@@ -2874,8 +2880,14 @@ Error Main::setup2(bool p_show_boot_logo) {
restore_editor_window_layout = value.operator int() == EditorSettings::InitialScreen::INITIAL_SCREEN_AUTO;
}
}
if (!prefer_wayland_found && assign == "run/platforms/linuxbsd/prefer_wayland") {
if (assign == "interface/editor/expand_to_title") {
init_expand_to_title = value;
} else if (assign == "interface/editor/display_scale") {
init_display_scale = value;
init_display_scale_found = true;
} else if (assign == "interface/editor/custom_display_scale") {
init_custom_scale = value;
} else if (!prefer_wayland_found && assign == "run/platforms/linuxbsd/prefer_wayland") {
prefer_wayland = value;
prefer_wayland_found = true;
}
@@ -3031,6 +3043,12 @@ Error Main::setup2(bool p_show_boot_logo) {
window_flags = DisplayServer::WINDOW_FLAG_BORDERLESS_BIT;
}
#ifdef TOOLS_ENABLED
if ((project_manager || editor) && init_expand_to_title) {
window_flags |= DisplayServer::WINDOW_FLAG_EXTEND_TO_TITLE_BIT;
}
#endif
// rendering_driver now held in static global String in main and initialized in setup()
Error err;
display_server = DisplayServer::create(display_driver_idx, rendering_driver, window_mode, window_vsync_mode, window_flags, window_position, window_size, init_screen, context, init_embed_parent_window_id, err);
@@ -3083,6 +3101,48 @@ Error Main::setup2(bool p_show_boot_logo) {
return err;
}
#ifdef TOOLS_ENABLED
if (project_manager && init_display_scale_found) {
float ui_scale = init_custom_scale;
switch (init_display_scale) {
case 0:
ui_scale = EditorSettings::get_auto_display_scale();
break;
case 1:
ui_scale = 0.75;
break;
case 2:
ui_scale = 1.0;
break;
case 3:
ui_scale = 1.25;
break;
case 4:
ui_scale = 1.5;
break;
case 5:
ui_scale = 1.75;
break;
case 6:
ui_scale = 2.0;
break;
default:
break;
}
if (!(force_res || use_custom_res)) {
display_server->window_set_size(window_size * ui_scale, DisplayServer::MAIN_WINDOW_ID);
}
if (display_server->has_feature(DisplayServer::FEATURE_SUBWINDOWS)) { // Note: add "&& !display_server->has_feature(DisplayServer::FEATURE_SELF_FITTING_WINDOWS)" when Wayland multi-window support is merged.
Size2 real_size = DisplayServer::get_singleton()->window_get_size();
Rect2i scr_rect = display_server->screen_get_usable_rect(init_screen);
display_server->window_set_position(scr_rect.position + (scr_rect.size - real_size) / 2, DisplayServer::MAIN_WINDOW_ID);
}
}
#endif
if (display_server->has_feature(DisplayServer::FEATURE_SUBWINDOWS)) {
display_server->show_window(DisplayServer::MAIN_WINDOW_ID);
}
if (display_server->has_feature(DisplayServer::FEATURE_ORIENTATION)) {
display_server->screen_set_orientation(window_orientation);
}
@@ -4350,7 +4410,7 @@ int Main::start() {
translation_server->get_editor_domain()->set_pseudolocalization_enabled(true);
}
ProjectManager *pmanager = memnew(ProjectManager(force_res || use_custom_res));
ProjectManager *pmanager = memnew(ProjectManager);
ProgressDialog *progress_dialog = memnew(ProgressDialog);
pmanager->add_child(progress_dialog);