# HG changeset patch # User Sam Lantinga # Date 1293928889 28800 # Node ID de89a6f73c061ef6163e071d75e8b5bf2a8851ab # Parent 2af0032520d8e736050898e1fb2e4694f22222ac Fixed restoring the desktop resolution when toggling fullscreen mode diff -r 2af0032520d8 -r de89a6f73c06 src/video/cocoa/SDL_cocoamodes.m --- a/src/video/cocoa/SDL_cocoamodes.m Fri Dec 31 16:51:03 2010 -0800 +++ b/src/video/cocoa/SDL_cocoamodes.m Sat Jan 01 16:41:29 2011 -0800 @@ -248,27 +248,29 @@ SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata; CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken; CGError result; - + /* Fade to black to hide resolution-switching flicker */ if (CGAcquireDisplayFadeReservation(5, &fade_token) == kCGErrorSuccess) { CGDisplayFade(fade_token, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, TRUE); } - /* Put up the blanking window (a window above all other windows) */ - result = CGDisplayCapture(displaydata->display); - if (result != kCGErrorSuccess) { - CG_SetError("CGDisplayCapture()", result); - goto ERR_NO_CAPTURE; - } - if (data == display->desktop_mode.driverdata) { /* Restoring desktop mode */ + CGDisplaySwitchToMode(displaydata->display, data->moderef); + 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 (result != kCGErrorSuccess) { + CG_SetError("CGDisplayCapture()", result); + goto ERR_NO_CAPTURE; + } + /* Do the physical switch */ result = CGDisplaySwitchToMode(displaydata->display, data->moderef); if (result != kCGErrorSuccess) { @@ -326,7 +328,6 @@ Cocoa_SetDisplayMode(_this, display, &display->desktop_mode); } } - CGReleaseAllDisplays(); ShowMenuBar(); }