MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / enable_window_on_screen

Method enable_window_on_screen

editor/gui/window_wrapper.cpp:286–311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284}
285
286void 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
313void WindowWrapper::set_window_title(const String &p_title) {
314 if (!is_window_available()) {

Callers

nothing calls this directly

Calls 5

get_current_screenMethod · 0.80
set_current_screenMethod · 0.80
Vector2Function · 0.50
Rect2iClass · 0.50

Tested by

no test coverage detected