From 06551dfa3a3683d3442389f2cc7cdbe3c57034b2 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Tue, 3 Jan 2023 09:25:45 +0200 Subject: [PATCH] Set main window min. size via Window object instead of DisplayServer to preserve it during window updates. --- editor/editor_node.cpp | 5 ++++- editor/project_manager.cpp | 5 ++++- main/main.cpp | 4 ---- scene/main/scene_tree.cpp | 1 + 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 01e605880c0..b50db347420 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -6113,7 +6113,10 @@ EditorNode::EditorNode() { } // Define a minimum window size to prevent UI elements from overlapping or being cut off. - DisplayServer::get_singleton()->window_set_min_size(Size2(1024, 600) * EDSCALE); + Window *w = Object::cast_to(SceneTree::get_singleton()->get_root()); + if (w) { + w->set_min_size(Size2(1024, 600) * EDSCALE); + } FileDialog::set_default_show_hidden_files(EDITOR_GET("filesystem/file_dialog/show_hidden_files")); EditorFileDialog::set_default_show_hidden_files(EDITOR_GET("filesystem/file_dialog/show_hidden_files")); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 0d93c8a95e3..0a05b05e632 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -3008,7 +3008,10 @@ ProjectManager::ProjectManager() { SceneTree::get_singleton()->get_root()->connect("files_dropped", callable_mp(this, &ProjectManager::_files_dropped)); // Define a minimum window size to prevent UI elements from overlapping or being cut off. - DisplayServer::get_singleton()->window_set_min_size(Size2(520, 350) * EDSCALE); + Window *w = Object::cast_to(SceneTree::get_singleton()->get_root()); + if (w) { + w->set_min_size(Size2(520, 350) * EDSCALE); + } // Resize the bootsplash window based on Editor display scale EDSCALE. float scale_factor = MAX(1, EDSCALE); diff --git a/main/main.cpp b/main/main.cpp index 7e1fd38e148..92734e9208a 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -2902,10 +2902,6 @@ bool Main::start() { DisplayServer::get_singleton()->window_set_title(appname); #endif - // Define a very small minimum window size to prevent bugs such as GH-37242. - // It can still be overridden by the user in a script. - DisplayServer::get_singleton()->window_set_min_size(Size2i(64, 64)); - bool snap_controls = GLOBAL_GET("gui/common/snap_controls_to_pixels"); sml->get_root()->set_snap_controls_to_pixels(snap_controls); diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index e61cca0a0f4..cc2031695ab 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -1397,6 +1397,7 @@ SceneTree::SceneTree() { // Create with mainloop. root = memnew(Window); + root->set_min_size(Size2i(64, 64)); // Define a very small minimum window size to prevent bugs such as GH-37242. root->set_process_mode(Node::PROCESS_MODE_PAUSABLE); root->set_name("root"); root->set_title(GLOBAL_GET("application/config/name"));