Fixed cocoa trying to shuffling windows when going fullscreen on the main display.
authorSam Lantinga <slouken@libsdl.org>
Thu, 10 Feb 2011 22:49:14 -0800
changeset 5248 ff2564c24045
parent 5247 d844537c42fd
child 5249 7a963be087ef
Fixed cocoa trying to shuffling windows when going fullscreen on the main display.
src/video/cocoa/SDL_cocoamodes.m
--- a/src/video/cocoa/SDL_cocoamodes.m	Thu Feb 10 22:37:01 2011 -0800
+++ b/src/video/cocoa/SDL_cocoamodes.m	Thu Feb 10 22:49:14 2011 -0800
@@ -258,14 +258,23 @@
         /* Restoring desktop mode */
         CGDisplaySwitchToMode(displaydata->display, data->moderef);
 
-        CGDisplayRelease(displaydata->display);
+        if (CGDisplayIsMain(displaydata->display)) {
+            CGReleaseAllDisplays();
+        } else {
+            CGDisplayRelease(displaydata->display);
+        }
 
         if (CGDisplayIsMain(displaydata->display)) {
             ShowMenuBar();
         }
     } else {
         /* Put up the blanking window (a window above all other windows) */
-        result = CGDisplayCapture(displaydata->display);
+        if (CGDisplayIsMain(displaydata->display)) {
+            /* If we don't capture all displays, Cocoa tries to rearrange windows... *sigh* */
+            result = CGCaptureAllDisplays();
+        } else {
+            result = CGDisplayCapture(displaydata->display);
+        }
         if (result != kCGErrorSuccess) {
             CG_SetError("CGDisplayCapture()", result);
             goto ERR_NO_CAPTURE;