From 2b1cfad5916e302fb4fd195cb86c76373a4b0ba4 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Sat, 15 Aug 2020 17:50:04 +0300 Subject: [PATCH] [macOS] Fix "on top" not set on init, and reseting on window update. --- platform/osx/os_osx.h | 1 + platform/osx/os_osx.mm | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index 5037460808c..8187ca0b8e4 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -127,6 +127,7 @@ public: bool zoomed; bool resizable; bool window_focused; + bool on_top; Size2 window_size; Rect2 restore_rect; diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index bfa7194a1a2..142a9ec3f62 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1682,6 +1682,11 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a [window_object makeKeyAndOrderFront:nil]; + on_top = p_desired.always_on_top; + if (p_desired.always_on_top) { + [window_object setLevel:NSFloatingWindowLevel]; + } + if (p_desired.fullscreen) zoomed = true; @@ -2501,7 +2506,11 @@ void OS_OSX::_update_window() { [window_object setHidesOnDeactivate:YES]; } else { // Reset these when our window is not a borderless window that covers up the screen - [window_object setLevel:NSNormalWindowLevel]; + if (on_top) { + [window_object setLevel:NSFloatingWindowLevel]; + } else { + [window_object setLevel:NSNormalWindowLevel]; + } [window_object setHidesOnDeactivate:NO]; } } @@ -2736,6 +2745,8 @@ void OS_OSX::move_window_to_foreground() { } void OS_OSX::set_window_always_on_top(bool p_enabled) { + on_top = p_enabled; + if (is_window_always_on_top() == p_enabled) return; @@ -3320,6 +3331,7 @@ OS_OSX::OS_OSX() { zoomed = false; resizable = false; window_focused = true; + on_top = false; Vector loggers; loggers.push_back(memnew(OSXTerminalLogger));