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) { if (wd.resize_disabled) {
[wd.window_object setStyleMask:[wd.window_object styleMask] & ~NSWindowStyleMaskResizable]; [wd.window_object setStyleMask:[wd.window_object styleMask] & ~NSWindowStyleMaskResizable];
} }
if (wd.on_top) {
[wd.window_object setLevel:NSFloatingWindowLevel];
}
} }
- (void)windowDidChangeBackingProperties:(NSNotification *)notification { - (void)windowDidChangeBackingProperties:(NSNotification *)notification {
@ -2437,7 +2441,7 @@ void DisplayServerOSX::_update_window(WindowData p_wd) {
[p_wd.window_object setHidesOnDeactivate:YES]; [p_wd.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
if (p_wd.on_top) { if (p_wd.on_top && !p_wd.fullscreen) {
[p_wd.window_object setLevel:NSFloatingWindowLevel]; [p_wd.window_object setLevel:NSFloatingWindowLevel];
} else { } else {
[p_wd.window_object setLevel:NSNormalWindowLevel]; [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]; [wd.window_object deminiaturize:nil];
} break; } break;
case WINDOW_MODE_FULLSCREEN: { case WINDOW_MODE_FULLSCREEN: {
[wd.window_object setLevel:NSNormalWindowLevel];
if (wd.layered_window) { if (wd.layered_window) {
_set_window_per_pixel_transparency_enabled(true, p_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; } break;
case WINDOW_FLAG_ALWAYS_ON_TOP: { case WINDOW_FLAG_ALWAYS_ON_TOP: {
wd.on_top = p_enabled; wd.on_top = p_enabled;
if (wd.fullscreen) {
return;
}
if (p_enabled) { if (p_enabled) {
[wd.window_object setLevel:NSFloatingWindowLevel]; [wd.window_object setLevel:NSFloatingWindowLevel];
} else { } else {
@ -2940,7 +2948,11 @@ bool DisplayServerOSX::window_get_flag(WindowFlags p_flag, WindowID p_window) co
return [wd.window_object styleMask] == NSWindowStyleMaskBorderless; return [wd.window_object styleMask] == NSWindowStyleMaskBorderless;
} break; } break;
case WINDOW_FLAG_ALWAYS_ON_TOP: { 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; } break;
case WINDOW_FLAG_TRANSPARENT: { case WINDOW_FLAG_TRANSPARENT: {
return wd.layered_window; return wd.layered_window;