comparison src/video/cocoa/SDL_cocoamodes.m @ 3513:b66c9e8090d4

Restore the desktop mode when requested
author Sam Lantinga <slouken@libsdl.org>
date Wed, 02 Dec 2009 07:55:23 +0000
parents 58cbfa81317a
children 455a6c47d2c6
comparison
equal deleted inserted replaced
3512:5ffbbfb78987 3513:b66c9e8090d4
245 if (result != kCGErrorSuccess) { 245 if (result != kCGErrorSuccess) {
246 CG_SetError("CGDisplayCapture()", result); 246 CG_SetError("CGDisplayCapture()", result);
247 goto ERR_NO_CAPTURE; 247 goto ERR_NO_CAPTURE;
248 } 248 }
249 249
250 /* Do the physical switch */ 250 if (data == display->desktop_mode.driverdata) {
251 result = CGDisplaySwitchToMode(displaydata->display, data->moderef); 251 /* Restoring desktop mode */
252 if (result != kCGErrorSuccess) { 252 CGDisplayRelease(displaydata->display);
253 CG_SetError("CGDisplaySwitchToMode()", result); 253
254 goto ERR_NO_SWITCH; 254 if (CGDisplayIsMain(displaydata->display)) {
255 } 255 ShowMenuBar();
256 256 }
257 /* Hide the menu bar so it doesn't intercept events */ 257 } else {
258 if (CGDisplayIsMain(displaydata->display)) { 258 /* Do the physical switch */
259 HideMenuBar(); 259 result = CGDisplaySwitchToMode(displaydata->display, data->moderef);
260 if (result != kCGErrorSuccess) {
261 CG_SetError("CGDisplaySwitchToMode()", result);
262 goto ERR_NO_SWITCH;
263 }
264
265 /* Hide the menu bar so it doesn't intercept events */
266 if (CGDisplayIsMain(displaydata->display)) {
267 HideMenuBar();
268 }
260 } 269 }
261 270
262 /* Fade in again (asynchronously) */ 271 /* Fade in again (asynchronously) */
263 if (fade_token != kCGDisplayFadeReservationInvalidToken) { 272 if (fade_token != kCGDisplayFadeReservationInvalidToken) {
264 CGDisplayFade(fade_token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE); 273 CGDisplayFade(fade_token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE);