From 5c27dc74b7421ff9afd54201c2e2dfccaab1a44b Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 22 Jul 2013 20:55:07 -0400 Subject: [PATCH] Cocoa: Make the next-highest window gain focus when a window is closing. (if the closed window wasn't the foreground, this is effectively a no-op.) --- src/video/cocoa/SDL_cocoawindow.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index d94c56744..427409c72 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -131,6 +131,7 @@ - (void)close NSNotificationCenter *center; NSWindow *window = _data->nswindow; NSView *view = [window contentView]; + NSArray *windows = nil; center = [NSNotificationCenter defaultCenter]; @@ -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