comparison src/video/quartz/SDL_QuartzVideo.m @ 435:140798e1e7a6

Darrell's fix for Quartz mouse motion
author Sam Lantinga <slouken@libsdl.org>
date Mon, 12 Aug 2002 22:43:58 +0000
parents 19e73568a75c
children 8a43e0cbf02f
comparison
equal deleted inserted replaced
434:ed58b98c0d9d 435:140798e1e7a6
343 /* Release fullscreen resources */ 343 /* Release fullscreen resources */
344 if ( mode_flags & SDL_FULLSCREEN ) { 344 if ( mode_flags & SDL_FULLSCREEN ) {
345 345
346 SDL_QuartzGammaTable gamma_table; 346 SDL_QuartzGammaTable gamma_table;
347 int gamma_error; 347 int gamma_error;
348 348 NSRect screen_rect;
349
349 gamma_error = QZ_FadeGammaOut (this, &gamma_table); 350 gamma_error = QZ_FadeGammaOut (this, &gamma_table);
350 351
351 /* Release the OpenGL context */ 352 /* Release the OpenGL context */
352 /* Do this first to avoid trash on the display before fade */ 353 /* Do this first to avoid trash on the display before fade */
353 if ( mode_flags & SDL_OPENGL ) 354 if ( mode_flags & SDL_OPENGL )
359 /* Restore original screen resolution/bpp */ 360 /* Restore original screen resolution/bpp */
360 CGDisplaySwitchToMode (display_id, save_mode); 361 CGDisplaySwitchToMode (display_id, save_mode);
361 CGDisplayRelease (display_id); 362 CGDisplayRelease (display_id);
362 ShowMenuBar (); 363 ShowMenuBar ();
363 364
365 /*
366 reset the main screen's rectangle, see comment
367 in QZ_SetVideoFullscreen
368 */
369 screen_rect = NSMakeRect(0,0,device_width,device_height);
370 [ [ NSScreen mainScreen ] setFrame:screen_rect ];
371
364 if (! gamma_error) 372 if (! gamma_error)
365 QZ_FadeGammaIn (this, &gamma_table); 373 QZ_FadeGammaIn (this, &gamma_table);
366 } 374 }
367 /* Release window mode resources */ 375 /* Release window mode resources */
368 else { 376 else {
399 static SDL_Surface* QZ_SetVideoFullScreen (_THIS, SDL_Surface *current, int width, 407 static SDL_Surface* QZ_SetVideoFullScreen (_THIS, SDL_Surface *current, int width,
400 int height, int bpp, Uint32 flags) { 408 int height, int bpp, Uint32 flags) {
401 int exact_match; 409 int exact_match;
402 int gamma_error; 410 int gamma_error;
403 SDL_QuartzGammaTable gamma_table; 411 SDL_QuartzGammaTable gamma_table;
404 412 NSRect screen_rect;
413
405 /* See if requested mode exists */ 414 /* See if requested mode exists */
406 mode = CGDisplayBestModeForParameters (display_id, bpp, width, 415 mode = CGDisplayBestModeForParameters (display_id, bpp, width,
407 height, &exact_match); 416 height, &exact_match);
408 417
409 /* Require an exact match to the requested mode */ 418 /* Require an exact match to the requested mode */
481 HideMenuBar (); 490 HideMenuBar ();
482 491
483 /* Fade the display to original gamma */ 492 /* Fade the display to original gamma */
484 if (! gamma_error ) 493 if (! gamma_error )
485 QZ_FadeGammaIn (this, &gamma_table); 494 QZ_FadeGammaIn (this, &gamma_table);
495
496 /*
497 There is a bug in Cocoa where NSScreen doesn't synchronize
498 with CGDirectDisplay, so the main screen's frame is wrong.
499 As a result, coordinate translation produces wrong results.
500 We can hack around this bug by setting the screen rect
501 ourselves. This hack should be removed if/when the bug is fixed.
502 */
503 screen_rect = NSMakeRect(0,0,width,height);
504 [ [ NSScreen mainScreen ] setFrame:screen_rect ];
486 505
487 /* Save the flags to ensure correct tear-down */ 506 /* Save the flags to ensure correct tear-down */
488 mode_flags = current->flags; 507 mode_flags = current->flags;
489 508
490 return current; 509 return current;