Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Cocoa: Make the next-highest window gain focus when a window is closing.
Browse files Browse the repository at this point in the history
(if the closed window wasn't the foreground, this is effectively a no-op.)
  • Loading branch information
icculus committed Jul 23, 2013
1 parent ef3be01 commit 5c27dc7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -131,6 +131,7 @@ - (void)close
NSNotificationCenter *center;
NSWindow *window = _data->nswindow;
NSView *view = [window contentView];
NSArray *windows = nil;

center = [NSNotificationCenter defaultCenter];

Expand All @@ -155,6 +156,14 @@ - (void)close
if ([view nextResponder] == self) {
[view setNextResponder:nil];
}

/* Make the next window in the z-order Key. If we weren't the foreground
when closed, this is a no-op. */
windows = [NSApp orderedWindows];
if ([windows count] > 0) {
NSWindow *win = (NSWindow *) [windows objectAtIndex:0];
[win makeKeyAndOrderFront:self];
}
}

- (BOOL)windowShouldClose:(id)sender
Expand Down

0 comments on commit 5c27dc7

Please sign in to comment.