src/video/cocoa/SDL_cocoawindow.m
changeset 7085 152cc7ddfa57
parent 7084 9d43403e9fc5
child 7087 5639ac726076
--- a/src/video/cocoa/SDL_cocoawindow.m	Mon Apr 22 12:07:13 2013 -0700
+++ b/src/video/cocoa/SDL_cocoawindow.m	Mon Apr 22 12:07:16 2013 -0700
@@ -591,6 +591,11 @@
         SDL_SetKeyboardFocus(data->window);
     }
 
+    /* Prevents the window's "window device" from being destroyed when it is
+     * hidden. See http://www.mikeash.com/pyblog/nsopenglcontext-and-one-shot.html
+     */
+    [nswindow setOneShot:NO];
+
     /* All done! */
     [pool release];
     window->driverdata = data;
@@ -633,7 +638,7 @@
             rect.origin.y -= screenRect.origin.y;
         }
     }
-    nswindow = [[SDLWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:YES screen:screen];
+    nswindow = [[SDLWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:NO screen:screen];
 
     // Create a default view for this window
     rect = [nswindow contentRectForFrameRect:[nswindow frame]];
@@ -856,8 +861,10 @@
     }
 
     [data->listener close];
-    data->nswindow = [[SDLWindow alloc] initWithContentRect:[[nswindow contentView] frame] styleMask:style backing:NSBackingStoreBuffered defer:YES screen:[nswindow screen]];
+    data->nswindow = [[SDLWindow alloc] initWithContentRect:[[nswindow contentView] frame] styleMask:style backing:NSBackingStoreBuffered defer:NO screen:[nswindow screen]];
     [data->nswindow setContentView:[nswindow contentView]];
+    /* See comment in SetupWindowData. */
+    [data->nswindow setOneShot:NO];
     [data->listener listen:data];
 
     [nswindow close];