comparison src/video/cocoa/SDL_cocoamodes.m @ 5281:15a71bec4a55

merged
author Eric Wing <ewing . public |-at-| gmail . com>
date Sat, 12 Feb 2011 19:16:09 -0800
parents b530ef003506
children
comparison
equal deleted inserted replaced
5219:adfcdd311ae0 5281:15a71bec4a55
1 /* 1 /*
2 SDL - Simple DirectMedia Layer 2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2010 Sam Lantinga 3 Copyright (C) 1997-2011 Sam Lantinga
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public 6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version. 8 version 2.1 of the License, or (at your option) any later version.
256 256
257 if (data == display->desktop_mode.driverdata) { 257 if (data == display->desktop_mode.driverdata) {
258 /* Restoring desktop mode */ 258 /* Restoring desktop mode */
259 CGDisplaySwitchToMode(displaydata->display, data->moderef); 259 CGDisplaySwitchToMode(displaydata->display, data->moderef);
260 260
261 CGDisplayRelease(displaydata->display); 261 if (CGDisplayIsMain(displaydata->display)) {
262 CGReleaseAllDisplays();
263 } else {
264 CGDisplayRelease(displaydata->display);
265 }
262 266
263 if (CGDisplayIsMain(displaydata->display)) { 267 if (CGDisplayIsMain(displaydata->display)) {
264 ShowMenuBar(); 268 ShowMenuBar();
265 } 269 }
266 } else { 270 } else {
267 /* Put up the blanking window (a window above all other windows) */ 271 /* Put up the blanking window (a window above all other windows) */
268 result = CGDisplayCapture(displaydata->display); 272 if (CGDisplayIsMain(displaydata->display)) {
273 /* If we don't capture all displays, Cocoa tries to rearrange windows... *sigh* */
274 result = CGCaptureAllDisplays();
275 } else {
276 result = CGDisplayCapture(displaydata->display);
277 }
269 if (result != kCGErrorSuccess) { 278 if (result != kCGErrorSuccess) {
270 CG_SetError("CGDisplayCapture()", result); 279 CG_SetError("CGDisplayCapture()", result);
271 goto ERR_NO_CAPTURE; 280 goto ERR_NO_CAPTURE;
272 } 281 }
273 282
287 /* Fade in again (asynchronously) */ 296 /* Fade in again (asynchronously) */
288 if (fade_token != kCGDisplayFadeReservationInvalidToken) { 297 if (fade_token != kCGDisplayFadeReservationInvalidToken) {
289 CGDisplayFade(fade_token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE); 298 CGDisplayFade(fade_token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE);
290 CGReleaseDisplayFadeReservation(fade_token); 299 CGReleaseDisplayFadeReservation(fade_token);
291 } 300 }
292
293 [[NSApp mainWindow] makeKeyAndOrderFront: nil];
294
295 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
296 /*
297 There is a bug in Cocoa where NSScreen doesn't synchronize
298 with CGDirectDisplay, so the main screen's frame is wrong.
299 As a result, coordinate translation produces incorrect results.
300 We can hack around this bug by setting the screen rect
301 ourselves. This hack should be removed if/when the bug is fixed.
302 */
303 [[NSScreen mainScreen] setFrame:NSMakeRect(0,0,mode->w,mode->h)];
304 #endif
305 301
306 return 0; 302 return 0;
307 303
308 /* Since the blanking window covers *all* windows (even force quit) correct recovery is crucial */ 304 /* Since the blanking window covers *all* windows (even force quit) correct recovery is crucial */
309 ERR_NO_SWITCH: 305 ERR_NO_SWITCH: