Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed restoring the desktop resolution when toggling fullscreen mode
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jan 2, 2011
1 parent f103186 commit 3a667c2
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/video/cocoa/SDL_cocoamodes.m
Expand Up @@ -248,27 +248,29 @@ - (void) setFrame:(NSRect)frame;
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) {
Expand Down Expand Up @@ -326,7 +328,6 @@ - (void) setFrame:(NSRect)frame;
Cocoa_SetDisplayMode(_this, display, &display->desktop_mode);
}
}
CGReleaseAllDisplays();
ShowMenuBar();
}

Expand Down

0 comments on commit 3a667c2

Please sign in to comment.