diff options
| author | Pedro J. Estébanez | 2018-01-30 20:39:53 +0100 |
|---|---|---|
| committer | Hein-Pieter van Braam | 2018-04-14 19:04:13 +0200 |
| commit | 4f0b5f730748951af7f03ec2d2ba70397dfe27ac (patch) | |
| tree | fff818be136c8c64dc0401d3e31505a75d0b30ff | |
| parent | 1c25e5049023acb0540f4bb7716cf77560136f1c (diff) | |
| download | godot-4f0b5f730748951af7f03ec2d2ba70397dfe27ac.tar.gz godot-4f0b5f730748951af7f03ec2d2ba70397dfe27ac.tar.zst godot-4f0b5f730748951af7f03ec2d2ba70397dfe27ac.zip | |
Implement always-on-top for MacOS
Courtesy of @bruvzg.
(cherry picked from commit 2e8c7824c0f2946f6bf33fe0a20eabb779a91763)
| -rw-r--r-- | platform/osx/os_osx.h | 2 | ||||
| -rw-r--r-- | platform/osx/os_osx.mm | 14 |
2 files changed, 16 insertions, 0 deletions
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index 0199bf0fc..579f27036 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -222,6 +222,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 String get_joy_guid(int p_device) const; diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 318216789..d57ba4d73 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1976,6 +1976,20 @@ void OS_OSX::move_window_to_foreground() { [window_object orderFrontRegardless]; } +void OS_OSX::set_window_always_on_top(bool p_enabled) { + if (is_window_always_on_top() == p_enabled) + return; + + if (p_enabled) + [window_object setLevel:NSFloatingWindowLevel]; + else + [window_object setLevel:NSNormalWindowLevel]; +} + +bool OS_OSX::is_window_always_on_top() const { + return [window_object level] == NSFloatingWindowLevel; +} + void OS_OSX::request_attention() { [NSApp requestUserAttention:NSCriticalRequest]; |
