| 284 | } |
| 285 | |
| 286 | void WindowWrapper::enable_window_on_screen(int p_screen, bool p_auto_scale) { |
| 287 | int current_screen = Object::cast_to<Window>(get_viewport())->get_current_screen(); |
| 288 | int screen = p_screen < 0 ? current_screen : p_screen; |
| 289 | |
| 290 | bool auto_scale = p_auto_scale && !EDITOR_GET("interface/multi_window/maximize_window"); |
| 291 | |
| 292 | if (auto_scale && current_screen != screen) { |
| 293 | Rect2 control_rect = _get_default_window_rect(); |
| 294 | |
| 295 | Rect2i source_screen_rect = DisplayServer::get_singleton()->screen_get_usable_rect(current_screen); |
| 296 | Rect2i dest_screen_rect = DisplayServer::get_singleton()->screen_get_usable_rect(screen); |
| 297 | |
| 298 | // Adjust the window rect size in case the resolution changes. |
| 299 | Vector2 screen_ratio = Vector2(source_screen_rect.size) / Vector2(dest_screen_rect.size); |
| 300 | |
| 301 | // The screen positioning may change, so remove the original screen position. |
| 302 | control_rect.position -= source_screen_rect.position; |
| 303 | control_rect = Rect2i(control_rect.position * screen_ratio, control_rect.size * screen_ratio); |
| 304 | control_rect.position += dest_screen_rect.position; |
| 305 | |
| 306 | restore_window(control_rect, p_screen); |
| 307 | } else { |
| 308 | window->set_current_screen(p_screen); |
| 309 | set_window_enabled(true); |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | void WindowWrapper::set_window_title(const String &p_title) { |
| 314 | if (!is_window_available()) { |
nothing calls this directly
no test coverage detected