Merge pull request #41286 from bruvzg/macos_on_top_3

[macOS] Fix "on top" not set on init, and resetting on window update.
This commit is contained in:
Rémi Verschelde 2020-08-15 17:59:12 +02:00 committed by GitHub
commit 72d12289bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -127,6 +127,7 @@ public:
bool zoomed; bool zoomed;
bool resizable; bool resizable;
bool window_focused; bool window_focused;
bool on_top;
Size2 window_size; Size2 window_size;
Rect2 restore_rect; Rect2 restore_rect;

View File

@ -1682,6 +1682,11 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
[window_object makeKeyAndOrderFront:nil]; [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) if (p_desired.fullscreen)
zoomed = true; zoomed = true;
@ -2501,7 +2506,11 @@ void OS_OSX::_update_window() {
[window_object setHidesOnDeactivate:YES]; [window_object setHidesOnDeactivate:YES];
} else { } else {
// Reset these when our window is not a borderless window that covers up the screen // 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]; [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) { void OS_OSX::set_window_always_on_top(bool p_enabled) {
on_top = p_enabled;
if (is_window_always_on_top() == p_enabled) if (is_window_always_on_top() == p_enabled)
return; return;
@ -3320,6 +3331,7 @@ OS_OSX::OS_OSX() {
zoomed = false; zoomed = false;
resizable = false; resizable = false;
window_focused = true; window_focused = true;
on_top = false;
Vector<Logger *> loggers; Vector<Logger *> loggers;
loggers.push_back(memnew(OSXTerminalLogger)); loggers.push_back(memnew(OSXTerminalLogger));