changeset 3513:b66c9e8090d4

Restore the desktop mode when requested
author Sam Lantinga <slouken@libsdl.org>
date Wed, 02 Dec 2009 07:55:23 +0000
parents 5ffbbfb78987
children f0b7bc1fe12d
files src/video/cocoa/SDL_cocoamodes.m
diffstat 1 files changed, 18 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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) */