src/video/cocoa/SDL_cocoawindow.m
changeset 7534 f0f5143b27cf
parent 7507 885b4aab4190
child 7535 c515121a3df7
--- a/src/video/cocoa/SDL_cocoawindow.m	Sat Jul 27 14:22:52 2013 +0200
+++ b/src/video/cocoa/SDL_cocoawindow.m	Mon Jul 22 20:55:07 2013 -0400
@@ -131,6 +131,7 @@
     NSNotificationCenter *center;
     NSWindow *window = _data->nswindow;
     NSView *view = [window contentView];
+    NSArray *windows = nil;
 
     center = [NSNotificationCenter defaultCenter];
 
@@ -155,6 +156,14 @@
     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