Fixed restoring the desktop resolution when toggling fullscreen mode
authorSam Lantinga <slouken@libsdl.org>
Sat, 01 Jan 2011 16:41:29 -0800
changeset 4939de89a6f73c06
parent 4938 2af0032520d8
child 4940 77f079051f60
Fixed restoring the desktop resolution when toggling fullscreen mode
src/video/cocoa/SDL_cocoamodes.m
     1.1 --- a/src/video/cocoa/SDL_cocoamodes.m	Fri Dec 31 16:51:03 2010 -0800
     1.2 +++ b/src/video/cocoa/SDL_cocoamodes.m	Sat Jan 01 16:41:29 2011 -0800
     1.3 @@ -248,27 +248,29 @@
     1.4      SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
     1.5      CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken;
     1.6      CGError result;
     1.7 -    
     1.8 +
     1.9      /* Fade to black to hide resolution-switching flicker */
    1.10      if (CGAcquireDisplayFadeReservation(5, &fade_token) == kCGErrorSuccess) {
    1.11          CGDisplayFade(fade_token, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, TRUE);
    1.12      }
    1.13  
    1.14 -    /* Put up the blanking window (a window above all other windows) */
    1.15 -    result = CGDisplayCapture(displaydata->display);
    1.16 -    if (result != kCGErrorSuccess) {
    1.17 -        CG_SetError("CGDisplayCapture()", result);
    1.18 -        goto ERR_NO_CAPTURE;
    1.19 -    }
    1.20 -
    1.21      if (data == display->desktop_mode.driverdata) {
    1.22          /* Restoring desktop mode */
    1.23 +        CGDisplaySwitchToMode(displaydata->display, data->moderef);
    1.24 +
    1.25          CGDisplayRelease(displaydata->display);
    1.26  
    1.27          if (CGDisplayIsMain(displaydata->display)) {
    1.28              ShowMenuBar();
    1.29          }
    1.30      } else {
    1.31 +        /* Put up the blanking window (a window above all other windows) */
    1.32 +        result = CGDisplayCapture(displaydata->display);
    1.33 +        if (result != kCGErrorSuccess) {
    1.34 +            CG_SetError("CGDisplayCapture()", result);
    1.35 +            goto ERR_NO_CAPTURE;
    1.36 +        }
    1.37 +
    1.38          /* Do the physical switch */
    1.39          result = CGDisplaySwitchToMode(displaydata->display, data->moderef);
    1.40          if (result != kCGErrorSuccess) {
    1.41 @@ -326,7 +328,6 @@
    1.42              Cocoa_SetDisplayMode(_this, display, &display->desktop_mode);
    1.43          }
    1.44      }
    1.45 -    CGReleaseAllDisplays();
    1.46      ShowMenuBar();
    1.47  }
    1.48