Skip to content

Commit

Permalink
cocoa: Implement SDL_WINDOW_ALWAYS_ON_TOP support (thanks, Gabriel!).
Browse files Browse the repository at this point in the history
Fixes Bugzilla #4809.
  • Loading branch information
icculus committed Oct 15, 2019
1 parent ec04110 commit d5e378d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -805,7 +805,11 @@ when returning to windowed mode from a space (instead of using a pending
*/
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;
Expand Down Expand Up @@ -1485,6 +1489,10 @@ - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
}
}

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];
Expand Down Expand Up @@ -1831,6 +1839,8 @@ - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
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];
}
Expand Down Expand Up @@ -1924,6 +1934,8 @@ - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
/* 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];
}
Expand Down

0 comments on commit d5e378d

Please sign in to comment.