summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_run.cpp18
-rw-r--r--editor/editor_settings.cpp7
-rw-r--r--editor/project_manager.cpp9
3 files changed, 14 insertions, 20 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");
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 5561597c70..8ca98e6f76 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -697,12 +697,13 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
// Window placement
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "run/window_placement/rect", 1, "Top Left,Centered,Custom Position,Force Maximized,Force Fullscreen")
- String screen_hints = "Same as Editor,Previous Monitor,Next Monitor";
+ // Keep the enum values in sync with the `DisplayServer::SCREEN_` enum.
+ String screen_hints = "Same as Editor:-5,Previous Monitor:-4,Next Monitor:-3,Primary Monitor:-2"; // Note: Main Window Screen:-1 is not used for the main window.
for (int i = 0; i < DisplayServer::get_singleton()->get_screen_count(); i++) {
- screen_hints += ",Monitor " + itos(i + 1);
+ screen_hints += ",Monitor " + itos(i + 1) + ":" + itos(i);
}
_initial_set("run/window_placement/rect_custom_position", Vector2());
- EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "run/window_placement/screen", 0, screen_hints)
+ EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "run/window_placement/screen", -5, screen_hints)
// Auto save
_initial_set("run/auto_save/save_before_running", true);
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index f8bea5f6e8..dc755cab41 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -3014,16 +3014,15 @@ ProjectManager::ProjectManager() {
float scale_factor = MAX(1, EDSCALE);
if (scale_factor > 1.0) {
Vector2i window_size = DisplayServer::get_singleton()->window_get_size();
- Vector2i screen_size = DisplayServer::get_singleton()->screen_get_size();
- Vector2i screen_position = DisplayServer::get_singleton()->screen_get_position();
+ Rect2i screen_rect = DisplayServer::get_singleton()->screen_get_usable_rect(DisplayServer::get_singleton()->window_get_current_screen());
window_size *= scale_factor;
DisplayServer::get_singleton()->window_set_size(window_size);
- if (screen_size != Vector2i()) {
+ if (screen_rect.size != Vector2i()) {
Vector2i window_position;
- window_position.x = screen_position.x + (screen_size.x - window_size.x) / 2;
- window_position.y = screen_position.y + (screen_size.y - window_size.y) / 2;
+ window_position.x = screen_rect.position.x + (screen_rect.size.x - window_size.x) / 2;
+ window_position.y = screen_rect.position.y + (screen_rect.size.y - window_size.y) / 2;
DisplayServer::get_singleton()->window_set_position(window_position);
}
}