Mercurial > sdl-ios-xcode
comparison src/video/cocoa/SDL_cocoamodes.m @ 1973:81255f93dfcd
Fixed fullscreen modes with Cocoa video driver.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 06 Aug 2006 08:55:37 +0000 |
parents | 5d3724f64f2b |
children | e57a883ffa86 |
comparison
equal
deleted
inserted
replaced
1972:a0e278364188 | 1973:81255f93dfcd |
---|---|
20 slouken@libsdl.org | 20 slouken@libsdl.org |
21 */ | 21 */ |
22 #include "SDL_config.h" | 22 #include "SDL_config.h" |
23 | 23 |
24 #include "SDL_cocoavideo.h" | 24 #include "SDL_cocoavideo.h" |
25 | |
26 /* | |
27 Add methods to get at private members of NSScreen. | |
28 Since there is a bug in Apple's screen switching code | |
29 that does not update this variable when switching | |
30 to fullscreen, we'll set it manually (but only for the | |
31 main screen). | |
32 */ | |
33 @interface NSScreen (NSScreenAccess) | |
34 - (void) setFrame:(NSRect)frame; | |
35 @end | |
36 | |
37 @implementation NSScreen (NSScreenAccess) | |
38 - (void) setFrame:(NSRect)frame; | |
39 { | |
40 _frame = frame; | |
41 } | |
42 @end | |
25 | 43 |
26 static void | 44 static void |
27 CG_SetError(const char *prefix, CGDisplayErr result) | 45 CG_SetError(const char *prefix, CGDisplayErr result) |
28 { | 46 { |
29 const char *error; | 47 const char *error; |
162 display.desktop_mode = mode; | 180 display.desktop_mode = mode; |
163 display.current_mode = mode; | 181 display.current_mode = mode; |
164 display.driverdata = displaydata; | 182 display.driverdata = displaydata; |
165 SDL_AddVideoDisplay(&display); | 183 SDL_AddVideoDisplay(&display); |
166 } | 184 } |
185 SDL_stack_free(displays); | |
167 } | 186 } |
168 | 187 |
169 static void | 188 static void |
170 AddDisplayMode(const void *moderef, void *context) | 189 AddDisplayMode(const void *moderef, void *context) |
171 { | 190 { |
218 if (result != kCGErrorSuccess) { | 237 if (result != kCGErrorSuccess) { |
219 CG_SetError("CGDisplaySwitchToMode()", result); | 238 CG_SetError("CGDisplaySwitchToMode()", result); |
220 goto ERR_NO_SWITCH; | 239 goto ERR_NO_SWITCH; |
221 } | 240 } |
222 | 241 |
242 /* Hide the menu bar so it doesn't intercept events */ | |
243 HideMenuBar(); | |
244 | |
223 /* Fade in again (asynchronously) */ | 245 /* Fade in again (asynchronously) */ |
224 if (fade_token != kCGDisplayFadeReservationInvalidToken) { | 246 if (fade_token != kCGDisplayFadeReservationInvalidToken) { |
225 CGDisplayFade(fade_token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE); | 247 CGDisplayFade(fade_token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE); |
226 CGReleaseDisplayFadeReservation(fade_token); | 248 CGReleaseDisplayFadeReservation(fade_token); |
227 } | 249 } |
250 | |
251 /* | |
252 There is a bug in Cocoa where NSScreen doesn't synchronize | |
253 with CGDirectDisplay, so the main screen's frame is wrong. | |
254 As a result, coordinate translation produces incorrect results. | |
255 We can hack around this bug by setting the screen rect | |
256 ourselves. This hack should be removed if/when the bug is fixed. | |
257 */ | |
258 [[NSScreen mainScreen] setFrame:NSMakeRect(0,0,mode->w,mode->h)]; | |
259 | |
228 return 0; | 260 return 0; |
229 | 261 |
230 /* Since the blanking window covers *all* windows (even force quit) correct recovery is crucial */ | 262 /* Since the blanking window covers *all* windows (even force quit) correct recovery is crucial */ |
231 ERR_NO_SWITCH: | 263 ERR_NO_SWITCH: |
232 CGDisplayRelease(displaydata->display); | 264 CGDisplayRelease(displaydata->display); |
251 _this->current_display = i; | 283 _this->current_display = i; |
252 Cocoa_SetDisplayMode(_this, &display->desktop_mode); | 284 Cocoa_SetDisplayMode(_this, &display->desktop_mode); |
253 } | 285 } |
254 } | 286 } |
255 CGReleaseAllDisplays(); | 287 CGReleaseAllDisplays(); |
288 ShowMenuBar(); | |
289 | |
256 _this->current_display = saved_display; | 290 _this->current_display = saved_display; |
257 } | 291 } |
258 | 292 |
259 /* vi: set ts=4 sw=4 expandtab: */ | 293 /* vi: set ts=4 sw=4 expandtab: */ |