Merge pull request #49016 from bruvzg/macos_on_top_40

[macOS] Allow "on top" windows to enter full-screen mode.
This commit is contained in:
Rémi Verschelde 2021-05-24 11:39:59 +02:00 committed by GitHub
commit 220e4401bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -368,6 +368,10 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) {
if (wd.resize_disabled) {
[wd.window_object setStyleMask:[wd.window_object styleMask] & ~NSWindowStyleMaskResizable];
}
if (wd.on_top) {
[wd.window_object setLevel:NSFloatingWindowLevel];
}
}
- (void)windowDidChangeBackingProperties:(NSNotification *)notification {
@ -2437,7 +2441,7 @@ void DisplayServerOSX::_update_window(WindowData p_wd) {
[p_wd.window_object setHidesOnDeactivate:YES];
} else {
// Reset these when our window is not a borderless window that covers up the screen
if (p_wd.on_top) {
if (p_wd.on_top && !p_wd.fullscreen) {
[p_wd.window_object setLevel:NSFloatingWindowLevel];
} else {
[p_wd.window_object setLevel:NSNormalWindowLevel];
@ -2786,6 +2790,7 @@ void DisplayServerOSX::window_set_mode(WindowMode p_mode, WindowID p_window) {
[wd.window_object deminiaturize:nil];
} break;
case WINDOW_MODE_FULLSCREEN: {
[wd.window_object setLevel:NSNormalWindowLevel];
if (wd.layered_window) {
_set_window_per_pixel_transparency_enabled(true, p_window);
}
@ -2903,6 +2908,9 @@ void DisplayServerOSX::window_set_flag(WindowFlags p_flag, bool p_enabled, Windo
} break;
case WINDOW_FLAG_ALWAYS_ON_TOP: {
wd.on_top = p_enabled;
if (wd.fullscreen) {
return;
}
if (p_enabled) {
[wd.window_object setLevel:NSFloatingWindowLevel];
} else {
@ -2940,7 +2948,11 @@ bool DisplayServerOSX::window_get_flag(WindowFlags p_flag, WindowID p_window) co
return [wd.window_object styleMask] == NSWindowStyleMaskBorderless;
} break;
case WINDOW_FLAG_ALWAYS_ON_TOP: {
return [wd.window_object level] == NSFloatingWindowLevel;
if (wd.fullscreen) {
return wd.on_top;
} else {
return [wd.window_object level] == NSFloatingWindowLevel;
}
} break;
case WINDOW_FLAG_TRANSPARENT: {
return wd.layered_window;