Restore the desktop mode when requested
authorSam Lantinga <slouken@libsdl.org>
Wed, 02 Dec 2009 07:55:23 +0000
changeset 3513 b66c9e8090d4
parent 3512 5ffbbfb78987
child 3514 f0b7bc1fe12d
Restore the desktop mode when requested
src/video/cocoa/SDL_cocoamodes.m
--- a/src/video/cocoa/SDL_cocoamodes.m	Wed Dec 02 07:42:10 2009 +0000
+++ b/src/video/cocoa/SDL_cocoamodes.m	Wed Dec 02 07:55:23 2009 +0000
@@ -247,16 +247,25 @@
         goto ERR_NO_CAPTURE;
     }
 
-    /* Do the physical switch */
-    result = CGDisplaySwitchToMode(displaydata->display, data->moderef);
-    if (result != kCGErrorSuccess) {
-        CG_SetError("CGDisplaySwitchToMode()", result);
-        goto ERR_NO_SWITCH;
-    }
+    if (data == display->desktop_mode.driverdata) {
+        /* Restoring desktop mode */
+        CGDisplayRelease(displaydata->display);
 
-    /* Hide the menu bar so it doesn't intercept events */
-    if (CGDisplayIsMain(displaydata->display)) {
-        HideMenuBar();
+        if (CGDisplayIsMain(displaydata->display)) {
+            ShowMenuBar();
+        }
+    } else {
+        /* Do the physical switch */
+        result = CGDisplaySwitchToMode(displaydata->display, data->moderef);
+        if (result != kCGErrorSuccess) {
+            CG_SetError("CGDisplaySwitchToMode()", result);
+            goto ERR_NO_SWITCH;
+        }
+
+        /* Hide the menu bar so it doesn't intercept events */
+        if (CGDisplayIsMain(displaydata->display)) {
+            HideMenuBar();
+        }
     }
 
     /* Fade in again (asynchronously) */