Merge pull request #58383 from bruvzg/no_inv_window_placement
This commit is contained in:
commit
a19d7d8f8d
|
@ -98,67 +98,79 @@ Error EditorRun::run(const String &p_scene) {
|
||||||
screen_rect.position = DisplayServer::get_singleton()->screen_get_position(screen);
|
screen_rect.position = DisplayServer::get_singleton()->screen_get_position(screen);
|
||||||
screen_rect.size = DisplayServer::get_singleton()->screen_get_size(screen);
|
screen_rect.size = DisplayServer::get_singleton()->screen_get_size(screen);
|
||||||
|
|
||||||
Size2 window_size;
|
|
||||||
window_size.x = ProjectSettings::get_singleton()->get("display/window/size/viewport_width");
|
|
||||||
window_size.y = ProjectSettings::get_singleton()->get("display/window/size/viewport_height");
|
|
||||||
|
|
||||||
Size2 desired_size;
|
|
||||||
desired_size.x = ProjectSettings::get_singleton()->get("display/window/size/window_width_override");
|
|
||||||
desired_size.y = ProjectSettings::get_singleton()->get("display/window/size/window_height_override");
|
|
||||||
if (desired_size.x > 0 && desired_size.y > 0) {
|
|
||||||
window_size = desired_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
int window_placement = EditorSettings::get_singleton()->get("run/window_placement/rect");
|
int window_placement = EditorSettings::get_singleton()->get("run/window_placement/rect");
|
||||||
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_HIDPI)) {
|
if (screen_rect != Rect2()) {
|
||||||
bool hidpi_proj = ProjectSettings::get_singleton()->get("display/window/dpi/allow_hidpi");
|
Size2 window_size;
|
||||||
int display_scale = 1;
|
window_size.x = ProjectSettings::get_singleton()->get("display/window/size/viewport_width");
|
||||||
|
window_size.y = ProjectSettings::get_singleton()->get("display/window/size/viewport_height");
|
||||||
|
|
||||||
if (OS::get_singleton()->is_hidpi_allowed()) {
|
Size2 desired_size;
|
||||||
if (hidpi_proj) {
|
desired_size.x = ProjectSettings::get_singleton()->get("display/window/size/window_width_override");
|
||||||
display_scale = 1; // Both editor and project runs in hiDPI mode, do not scale.
|
desired_size.y = ProjectSettings::get_singleton()->get("display/window/size/window_height_override");
|
||||||
} else {
|
if (desired_size.x > 0 && desired_size.y > 0) {
|
||||||
display_scale = DisplayServer::get_singleton()->screen_get_max_scale(); // Editor is in hiDPI mode, project is not, scale down.
|
window_size = desired_size;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (hidpi_proj) {
|
|
||||||
display_scale = (1.f / DisplayServer::get_singleton()->screen_get_max_scale()); // Editor is not in hiDPI mode, project is, scale up.
|
|
||||||
} else {
|
|
||||||
display_scale = 1; // Both editor and project runs in lowDPI mode, do not scale.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
screen_rect.position /= display_scale;
|
|
||||||
screen_rect.size /= display_scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (window_placement) {
|
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_HIDPI)) {
|
||||||
case 0: { // top left
|
bool hidpi_proj = ProjectSettings::get_singleton()->get("display/window/dpi/allow_hidpi");
|
||||||
args.push_back("--position");
|
int display_scale = 1;
|
||||||
args.push_back(itos(screen_rect.position.x) + "," + itos(screen_rect.position.y));
|
|
||||||
} break;
|
if (OS::get_singleton()->is_hidpi_allowed()) {
|
||||||
case 1: { // centered
|
if (hidpi_proj) {
|
||||||
Vector2 pos = (screen_rect.position) + ((screen_rect.size - window_size) / 2).floor();
|
display_scale = 1; // Both editor and project runs in hiDPI mode, do not scale.
|
||||||
args.push_back("--position");
|
} else {
|
||||||
args.push_back(itos(pos.x) + "," + itos(pos.y));
|
display_scale = DisplayServer::get_singleton()->screen_get_max_scale(); // Editor is in hiDPI mode, project is not, scale down.
|
||||||
} break;
|
}
|
||||||
case 2: { // custom pos
|
} else {
|
||||||
Vector2 pos = EditorSettings::get_singleton()->get("run/window_placement/rect_custom_position");
|
if (hidpi_proj) {
|
||||||
pos += screen_rect.position;
|
display_scale = (1.f / DisplayServer::get_singleton()->screen_get_max_scale()); // Editor is not in hiDPI mode, project is, scale up.
|
||||||
args.push_back("--position");
|
} else {
|
||||||
args.push_back(itos(pos.x) + "," + itos(pos.y));
|
display_scale = 1; // Both editor and project runs in lowDPI mode, do not scale.
|
||||||
} break;
|
}
|
||||||
case 3: { // force maximized
|
}
|
||||||
Vector2 pos = screen_rect.position;
|
screen_rect.position /= display_scale;
|
||||||
args.push_back("--position");
|
screen_rect.size /= display_scale;
|
||||||
args.push_back(itos(pos.x) + "," + itos(pos.y));
|
}
|
||||||
args.push_back("--maximized");
|
|
||||||
} break;
|
switch (window_placement) {
|
||||||
case 4: { // force fullscreen
|
case 0: { // top left
|
||||||
Vector2 pos = screen_rect.position;
|
args.push_back("--position");
|
||||||
args.push_back("--position");
|
args.push_back(itos(screen_rect.position.x) + "," + itos(screen_rect.position.y));
|
||||||
args.push_back(itos(pos.x) + "," + itos(pos.y));
|
} break;
|
||||||
args.push_back("--fullscreen");
|
case 1: { // centered
|
||||||
} break;
|
Vector2 pos = (screen_rect.position) + ((screen_rect.size - window_size) / 2).floor();
|
||||||
|
args.push_back("--position");
|
||||||
|
args.push_back(itos(pos.x) + "," + itos(pos.y));
|
||||||
|
} break;
|
||||||
|
case 2: { // custom pos
|
||||||
|
Vector2 pos = EditorSettings::get_singleton()->get("run/window_placement/rect_custom_position");
|
||||||
|
pos += screen_rect.position;
|
||||||
|
args.push_back("--position");
|
||||||
|
args.push_back(itos(pos.x) + "," + itos(pos.y));
|
||||||
|
} break;
|
||||||
|
case 3: { // force maximized
|
||||||
|
Vector2 pos = screen_rect.position;
|
||||||
|
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;
|
||||||
|
args.push_back("--position");
|
||||||
|
args.push_back(itos(pos.x) + "," + itos(pos.y));
|
||||||
|
args.push_back("--fullscreen");
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Unable to get screen info, skip setting position.
|
||||||
|
switch (window_placement) {
|
||||||
|
case 3: { // force maximized
|
||||||
|
args.push_back("--maximized");
|
||||||
|
} break;
|
||||||
|
case 4: { // force fullscreen
|
||||||
|
args.push_back("--fullscreen");
|
||||||
|
} break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> breakpoints;
|
List<String> breakpoints;
|
||||||
|
|
|
@ -1365,6 +1365,12 @@ float EditorSettings::get_auto_display_scale() const {
|
||||||
return DisplayServer::get_singleton()->screen_get_max_scale();
|
return DisplayServer::get_singleton()->screen_get_max_scale();
|
||||||
#else
|
#else
|
||||||
const int screen = DisplayServer::get_singleton()->window_get_current_screen();
|
const int screen = DisplayServer::get_singleton()->window_get_current_screen();
|
||||||
|
|
||||||
|
if (DisplayServer::get_singleton()->screen_get_size(screen) == Vector2i()) {
|
||||||
|
// Invalid screen size, skip.
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
// Use the smallest dimension to use a correct display scale on portrait displays.
|
// Use the smallest dimension to use a correct display scale on portrait displays.
|
||||||
const int smallest_dimension = MIN(DisplayServer::get_singleton()->screen_get_size(screen).x, DisplayServer::get_singleton()->screen_get_size(screen).y);
|
const int smallest_dimension = MIN(DisplayServer::get_singleton()->screen_get_size(screen).x, DisplayServer::get_singleton()->screen_get_size(screen).y);
|
||||||
if (DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && smallest_dimension >= 1400) {
|
if (DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && smallest_dimension >= 1400) {
|
||||||
|
|
|
@ -2877,17 +2877,15 @@ ProjectManager::ProjectManager() {
|
||||||
Vector2i screen_size = DisplayServer::get_singleton()->screen_get_size();
|
Vector2i screen_size = DisplayServer::get_singleton()->screen_get_size();
|
||||||
Vector2i screen_position = DisplayServer::get_singleton()->screen_get_position();
|
Vector2i screen_position = DisplayServer::get_singleton()->screen_get_position();
|
||||||
|
|
||||||
// Consider the editor display scale.
|
window_size *= scale_factor;
|
||||||
window_size.x = round((float)window_size.x * scale_factor);
|
|
||||||
window_size.y = round((float)window_size.y * scale_factor);
|
|
||||||
|
|
||||||
// Make the window centered on the screen.
|
|
||||||
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;
|
|
||||||
|
|
||||||
DisplayServer::get_singleton()->window_set_size(window_size);
|
DisplayServer::get_singleton()->window_set_size(window_size);
|
||||||
DisplayServer::get_singleton()->window_set_position(window_position);
|
if (screen_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;
|
||||||
|
DisplayServer::get_singleton()->window_set_position(window_position);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OS::get_singleton()->set_low_processor_usage_mode(true);
|
OS::get_singleton()->set_low_processor_usage_mode(true);
|
||||||
|
|
|
@ -1045,7 +1045,9 @@ void Window::popup_centered_clamped(const Size2i &p_size, float p_fallback_ratio
|
||||||
|
|
||||||
Rect2i popup_rect;
|
Rect2i popup_rect;
|
||||||
popup_rect.size = Vector2i(MIN(size_ratio.x, p_size.x), MIN(size_ratio.y, p_size.y));
|
popup_rect.size = Vector2i(MIN(size_ratio.x, p_size.x), MIN(size_ratio.y, p_size.y));
|
||||||
popup_rect.position = parent_rect.position + (parent_rect.size - popup_rect.size) / 2;
|
if (parent_rect != Rect2()) {
|
||||||
|
popup_rect.position = parent_rect.position + (parent_rect.size - popup_rect.size) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
popup(popup_rect);
|
popup(popup_rect);
|
||||||
}
|
}
|
||||||
|
@ -1069,7 +1071,10 @@ void Window::popup_centered(const Size2i &p_minsize) {
|
||||||
Size2 contents_minsize = _get_contents_minimum_size();
|
Size2 contents_minsize = _get_contents_minimum_size();
|
||||||
popup_rect.size.x = MAX(p_minsize.x, contents_minsize.x);
|
popup_rect.size.x = MAX(p_minsize.x, contents_minsize.x);
|
||||||
popup_rect.size.y = MAX(p_minsize.y, contents_minsize.y);
|
popup_rect.size.y = MAX(p_minsize.y, contents_minsize.y);
|
||||||
popup_rect.position = parent_rect.position + (parent_rect.size - popup_rect.size) / 2;
|
|
||||||
|
if (parent_rect != Rect2()) {
|
||||||
|
popup_rect.position = parent_rect.position + (parent_rect.size - popup_rect.size) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
popup(popup_rect);
|
popup(popup_rect);
|
||||||
}
|
}
|
||||||
|
@ -1091,8 +1096,10 @@ void Window::popup_centered_ratio(float p_ratio) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect2i popup_rect;
|
Rect2i popup_rect;
|
||||||
popup_rect.size = parent_rect.size * p_ratio;
|
if (parent_rect != Rect2()) {
|
||||||
popup_rect.position = parent_rect.position + (parent_rect.size - popup_rect.size) / 2;
|
popup_rect.size = parent_rect.size * p_ratio;
|
||||||
|
popup_rect.position = parent_rect.position + (parent_rect.size - popup_rect.size) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
popup(popup_rect);
|
popup(popup_rect);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue