diff options
| author | Marcelo Fernandez | 2018-02-12 14:17:29 -0300 |
|---|---|---|
| committer | Hein-Pieter van Braam | 2018-02-19 22:14:05 +0100 |
| commit | 150423203bcdf8a3ecacf6c73c1684c52990c8b4 (patch) | |
| tree | ac9de4656e4d65d82560a88470e4e105fad82684 /core/os/os.cpp | |
| parent | ef60123938695772fa518a777b19c8bee5e29382 (diff) | |
| download | godot-150423203bcdf8a3ecacf6c73c1684c52990c8b4.tar.gz godot-150423203bcdf8a3ecacf6c73c1684c52990c8b4.tar.zst godot-150423203bcdf8a3ecacf6c73c1684c52990c8b4.zip | |
Added OS::center_window to center the window precisely on desktop platforms
(cherry picked from commit ea1d726a4603fdd6bd4dfa6c1fa3128cfb2915c7)
Diffstat (limited to 'core/os/os.cpp')
| -rw-r--r-- | core/os/os.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/core/os/os.cpp b/core/os/os.cpp index c6e5de703..422acf95d 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -616,6 +616,17 @@ bool OS::has_feature(const String &p_feature) { return false; } +void OS::center_window() { + + if (is_window_fullscreen()) return; + + Size2 scr = get_screen_size(get_current_screen()); + Size2 wnd = get_real_window_size(); + int x = scr.width / 2 - wnd.width / 2; + int y = scr.height / 2 - wnd.height / 2; + set_window_position(Vector2(x, y)); +} + OS::OS() { void *volatile stack_bottom; |
