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

Merge pull request #103961 from bruvzg/win_pos_sync

Sync `display/window/size/initial_position_type` and `Window::WINDOW_INITIAL_POSITION_` enum.
This commit is contained in:
Thaddeus Crews
2025-03-18 14:42:33 -05:00
3 changed files with 9 additions and 8 deletions

View File

@@ -1497,9 +1497,10 @@ ProjectSettings::ProjectSettings() {
GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "display/window/size/mode", PROPERTY_HINT_ENUM, "Windowed,Minimized,Maximized,Fullscreen,Exclusive Fullscreen"), 0); GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "display/window/size/mode", PROPERTY_HINT_ENUM, "Windowed,Minimized,Maximized,Fullscreen,Exclusive Fullscreen"), 0);
// Keep the enum values in sync with the `DisplayServer::SCREEN_` enum. // Keep the enum values in sync with the `Window::WINDOW_INITIAL_POSITION_` enum.
GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "display/window/size/initial_position_type", PROPERTY_HINT_ENUM, "Absolute,Center of Primary Screen,Center of Other Screen,Center of Screen With Mouse Pointer,Center of Screen With Keyboard Focus"), 1); GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "display/window/size/initial_position_type", PROPERTY_HINT_ENUM, "Absolute:0,Center of Primary Screen:1,Center of Other Screen:3,Center of Screen With Mouse Pointer:4,Center of Screen With Keyboard Focus:5"), 1);
GLOBAL_DEF_BASIC(PropertyInfo(Variant::VECTOR2I, "display/window/size/initial_position"), Vector2i()); GLOBAL_DEF_BASIC(PropertyInfo(Variant::VECTOR2I, "display/window/size/initial_position"), Vector2i());
// Keep the enum values in sync with the `DisplayServer::SCREEN_` enum.
GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "display/window/size/initial_screen", PROPERTY_HINT_RANGE, "0,64,1,or_greater"), 0); GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "display/window/size/initial_screen", PROPERTY_HINT_RANGE, "0,64,1,or_greater"), 0);
GLOBAL_DEF_BASIC("display/window/size/resizable", true); GLOBAL_DEF_BASIC("display/window/size/resizable", true);

View File

@@ -2483,27 +2483,27 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} }
window_mode = (DisplayServer::WindowMode)(GLOBAL_GET("display/window/size/mode").operator int()); window_mode = (DisplayServer::WindowMode)(GLOBAL_GET("display/window/size/mode").operator int());
int initial_position_type = GLOBAL_GET("display/window/size/initial_position_type").operator int(); int initial_position_type = GLOBAL_GET("display/window/size/initial_position_type").operator int();
if (initial_position_type == 0) { // Absolute. if (initial_position_type == Window::WINDOW_INITIAL_POSITION_ABSOLUTE) { // Absolute.
if (!init_use_custom_pos) { if (!init_use_custom_pos) {
init_custom_pos = GLOBAL_GET("display/window/size/initial_position").operator Vector2i(); init_custom_pos = GLOBAL_GET("display/window/size/initial_position").operator Vector2i();
init_use_custom_pos = true; init_use_custom_pos = true;
} }
} else if (initial_position_type == 1) { // Center of Primary Screen. } else if (initial_position_type == Window::WINDOW_INITIAL_POSITION_CENTER_PRIMARY_SCREEN || initial_position_type == Window::WINDOW_INITIAL_POSITION_CENTER_MAIN_WINDOW_SCREEN) { // Center of Primary Screen.
if (!init_use_custom_screen) { if (!init_use_custom_screen) {
init_screen = DisplayServer::SCREEN_PRIMARY; init_screen = DisplayServer::SCREEN_PRIMARY;
init_use_custom_screen = true; init_use_custom_screen = true;
} }
} else if (initial_position_type == 2) { // Center of Other Screen. } else if (initial_position_type == Window::WINDOW_INITIAL_POSITION_CENTER_OTHER_SCREEN) { // Center of Other Screen.
if (!init_use_custom_screen) { if (!init_use_custom_screen) {
init_screen = GLOBAL_GET("display/window/size/initial_screen").operator int(); init_screen = GLOBAL_GET("display/window/size/initial_screen").operator int();
init_use_custom_screen = true; init_use_custom_screen = true;
} }
} else if (initial_position_type == 3) { // Center of Screen With Mouse Pointer. } else if (initial_position_type == Window::WINDOW_INITIAL_POSITION_CENTER_SCREEN_WITH_MOUSE_FOCUS) { // Center of Screen With Mouse Pointer.
if (!init_use_custom_screen) { if (!init_use_custom_screen) {
init_screen = DisplayServer::SCREEN_WITH_MOUSE_FOCUS; init_screen = DisplayServer::SCREEN_WITH_MOUSE_FOCUS;
init_use_custom_screen = true; init_use_custom_screen = true;
} }
} else if (initial_position_type == 4) { // Center of Screen With Keyboard Focus. } else if (initial_position_type == Window::WINDOW_INITIAL_POSITION_CENTER_SCREEN_WITH_KEYBOARD_FOCUS) { // Center of Screen With Keyboard Focus.
if (!init_use_custom_screen) { if (!init_use_custom_screen) {
init_screen = DisplayServer::SCREEN_WITH_KEYBOARD_FOCUS; init_screen = DisplayServer::SCREEN_WITH_KEYBOARD_FOCUS;
init_use_custom_screen = true; init_use_custom_screen = true;

View File

@@ -102,7 +102,7 @@ public:
DEFAULT_WINDOW_SIZE = 100, DEFAULT_WINDOW_SIZE = 100,
}; };
// Keep synced with enum hint for `initial_position` property. // Keep synced with enum hint for `initial_position` property and `display/window/size/initial_position_type` project setting.
enum WindowInitialPosition { enum WindowInitialPosition {
WINDOW_INITIAL_POSITION_ABSOLUTE, WINDOW_INITIAL_POSITION_ABSOLUTE,
WINDOW_INITIAL_POSITION_CENTER_PRIMARY_SCREEN, WINDOW_INITIAL_POSITION_CENTER_PRIMARY_SCREEN,