cocoa: Implement SDL_WINDOW_ALWAYS_ON_TOP support (thanks, Gabriel!).

Fixes Bugzilla #4809.
This commit is contained in:
Ryan C. Gordon 2019-10-15 00:59:10 -04:00
parent ec04110d8e
commit d5e378d198
1 changed files with 13 additions and 1 deletions

View File

@ -805,7 +805,11 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
*/ */
SetWindowStyle(window, GetWindowWindowedStyle(window)); SetWindowStyle(window, GetWindowWindowedStyle(window));
if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) {
[nswindow setLevel:NSFloatingWindowLevel];
} else {
[nswindow setLevel:kCGNormalWindowLevel]; [nswindow setLevel:kCGNormalWindowLevel];
}
if (pendingWindowOperation == PENDING_OPERATION_ENTER_FULLSCREEN) { if (pendingWindowOperation == PENDING_OPERATION_ENTER_FULLSCREEN) {
pendingWindowOperation = PENDING_OPERATION_NONE; pendingWindowOperation = PENDING_OPERATION_NONE;
@ -1485,6 +1489,10 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
} }
} }
if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) {
[nswindow setLevel:NSFloatingWindowLevel];
}
/* Create a default view for this window */ /* Create a default view for this window */
rect = [nswindow contentRectForFrameRect:[nswindow frame]]; rect = [nswindow contentRectForFrameRect:[nswindow frame]];
SDLView *contentView = [[SDLView alloc] initWithFrame:rect]; SDLView *contentView = [[SDLView alloc] initWithFrame:rect];
@ -1831,6 +1839,8 @@ Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
if (SDL_ShouldAllowTopmost() && fullscreen) { if (SDL_ShouldAllowTopmost() && fullscreen) {
/* OpenGL is rendering to the window, so make it visible! */ /* OpenGL is rendering to the window, so make it visible! */
[nswindow setLevel:CGShieldingWindowLevel()]; [nswindow setLevel:CGShieldingWindowLevel()];
} else if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) {
[nswindow setLevel:NSFloatingWindowLevel];
} else { } else {
[nswindow setLevel:kCGNormalWindowLevel]; [nswindow setLevel:kCGNormalWindowLevel];
} }
@ -1924,6 +1934,8 @@ Cocoa_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
/* OpenGL is rendering to the window, so make it visible! */ /* OpenGL is rendering to the window, so make it visible! */
/* Doing this in 10.11 while in a Space breaks things (bug #3152) */ /* Doing this in 10.11 while in a Space breaks things (bug #3152) */
[data->nswindow setLevel:CGShieldingWindowLevel()]; [data->nswindow setLevel:CGShieldingWindowLevel()];
} else if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) {
[data->nswindow setLevel:NSFloatingWindowLevel];
} else { } else {
[data->nswindow setLevel:kCGNormalWindowLevel]; [data->nswindow setLevel:kCGNormalWindowLevel];
} }