diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-07 13:21:36 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-07 13:21:36 +0100 |
commit | d642274f75fb8ca6d3b9d4c314269e6f559051c7 (patch) | |
tree | 7dbf61077d234d636dfd33f85007bcc06f66fb69 /editor/editor_run.cpp | |
parent | 3579d7a9f74e3f1eda88826897feb4b866d75ec9 (diff) | |
parent | 2718a7b7d39962100e59b8616077603034d77f8e (diff) |
Merge pull request #70939 from bruvzg/win_screen_2
Add support for the custom initial screen for the main window, fix primary screen detection.
Diffstat (limited to 'editor/editor_run.cpp')
-rw-r--r-- | editor/editor_run.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index 853b685851..4bcd91376a 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -93,30 +93,24 @@ Error EditorRun::run(const String &p_scene, const String &p_write_movie) { } int screen = EDITOR_GET("run/window_placement/screen"); - if (screen == 0) { + if (screen == -5) { // Same as editor screen = DisplayServer::get_singleton()->window_get_current_screen(); - } else if (screen == 1) { + } else if (screen == -4) { // Previous monitor (wrap to the other end if needed) screen = Math::wrapi( DisplayServer::get_singleton()->window_get_current_screen() - 1, 0, DisplayServer::get_singleton()->get_screen_count()); - } else if (screen == 2) { + } else if (screen == -3) { // Next monitor (wrap to the other end if needed) screen = Math::wrapi( DisplayServer::get_singleton()->window_get_current_screen() + 1, 0, DisplayServer::get_singleton()->get_screen_count()); - } else { - // Fixed monitor ID - // There are 3 special options, so decrement the option ID by 3 to get the monitor ID - screen -= 3; } - Rect2 screen_rect; - screen_rect.position = DisplayServer::get_singleton()->screen_get_position(screen); - screen_rect.size = DisplayServer::get_singleton()->screen_get_size(screen); + Rect2 screen_rect = DisplayServer::get_singleton()->screen_get_usable_rect(screen); int window_placement = EDITOR_GET("run/window_placement/rect"); if (screen_rect != Rect2()) { @@ -169,13 +163,13 @@ Error EditorRun::run(const String &p_scene, const String &p_write_movie) { args.push_back(itos(pos.x) + "," + itos(pos.y)); } break; case 3: { // force maximized - Vector2 pos = screen_rect.position; + Vector2 pos = screen_rect.position + screen_rect.size / 2; args.push_back("--position"); args.push_back(itos(pos.x) + "," + itos(pos.y)); args.push_back("--maximized"); } break; case 4: { // force fullscreen - Vector2 pos = screen_rect.position; + Vector2 pos = screen_rect.position + screen_rect.size / 2; args.push_back("--position"); args.push_back(itos(pos.x) + "," + itos(pos.y)); args.push_back("--fullscreen"); |