diff options
| author | Pedro J. Estébanez | 2017-12-27 20:51:19 +0100 |
|---|---|---|
| committer | Pedro J. Estébanez | 2018-01-05 21:31:04 +0100 |
| commit | ee2c31d306e9333b520e0668f26807d876905241 (patch) | |
| tree | 6698c6ea483f669df73f96e04c35244b4cb4a108 /platform/windows | |
| parent | db49f35ab8d2bbcf5b97a58b8a2eff064b942881 (diff) | |
| download | godot-ee2c31d306e9333b520e0668f26807d876905241.tar.gz godot-ee2c31d306e9333b520e0668f26807d876905241.tar.zst godot-ee2c31d306e9333b520e0668f26807d876905241.zip | |
Add new window setting: always on top
Implemented for Windows and Linux.
Diffstat (limited to 'platform/windows')
| -rw-r--r-- | platform/windows/os_windows.cpp | 19 | ||||
| -rw-r--r-- | platform/windows/os_windows.h | 2 |
2 files changed, 21 insertions, 0 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 4f4b225b1..fdf0efc8a 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1068,6 +1068,10 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int } }; + if (video_mode.always_on_top) { + SetWindowPos(hWnd, video_mode.always_on_top ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + } + #if defined(OPENGL_ENABLED) gl_context = memnew(ContextGL_Win(hWnd, true)); gl_context->initialize(); @@ -1601,6 +1605,19 @@ bool OS_Windows::is_window_maximized() const { return maximized; } +void OS_Windows::set_window_always_on_top(bool p_enabled) { + if (video_mode.always_on_top == p_enabled) + return; + + video_mode.always_on_top = p_enabled; + + _update_window_style(); +} + +bool OS_Windows::is_window_always_on_top() const { + return video_mode.always_on_top; +} + void OS_Windows::set_borderless_window(bool p_borderless) { if (video_mode.borderless_window == p_borderless) return; @@ -1625,6 +1642,8 @@ void OS_Windows::_update_window_style(bool repaint) { } } + SetWindowPos(hWnd, video_mode.always_on_top ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + if (repaint) { RECT rect; GetWindowRect(hWnd, &rect); diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index c24e35e92..2f6d5ac60 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -210,6 +210,8 @@ public: virtual bool is_window_minimized() const; virtual void set_window_maximized(bool p_enabled); virtual bool is_window_maximized() const; + virtual void set_window_always_on_top(bool p_enabled); + virtual bool is_window_always_on_top() const; virtual void request_attention(); virtual void set_borderless_window(bool p_borderless); |
