cocoa: Implement SDL_WINDOW_ALWAYS_ON_TOP support (thanks, Gabriel!). Fixes Bugzilla #4809.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index c7760cb..81d4c6c 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -805,7 +805,11 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
*/
SetWindowStyle(window, GetWindowWindowedStyle(window));
- [nswindow setLevel:kCGNormalWindowLevel];
+ if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) {
+ [nswindow setLevel:NSFloatingWindowLevel];
+ } else {
+ [nswindow setLevel:kCGNormalWindowLevel];
+ }
if (pendingWindowOperation == PENDING_OPERATION_ENTER_FULLSCREEN) {
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 */
rect = [nswindow contentRectForFrameRect:[nswindow frame]];
SDLView *contentView = [[SDLView alloc] initWithFrame:rect];
@@ -1831,6 +1839,8 @@ Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
if (SDL_ShouldAllowTopmost() && fullscreen) {
/* OpenGL is rendering to the window, so make it visible! */
[nswindow setLevel:CGShieldingWindowLevel()];
+ } else if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) {
+ [nswindow setLevel:NSFloatingWindowLevel];
} else {
[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! */
/* Doing this in 10.11 while in a Space breaks things (bug #3152) */
[data->nswindow setLevel:CGShieldingWindowLevel()];
+ } else if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) {
+ [data->nswindow setLevel:NSFloatingWindowLevel];
} else {
[data->nswindow setLevel:kCGNormalWindowLevel];
}