src/video/cocoa/SDL_cocoamodes.m
changeset 6105 3b06b03d74f4
parent 6104 e49364c8a253
child 6138 4c64952a58fb
equal deleted inserted replaced
6104:e49364c8a253 6105:3b06b03d74f4
    24 
    24 
    25 #include "SDL_cocoavideo.h"
    25 #include "SDL_cocoavideo.h"
    26 
    26 
    27 /* we need this for ShowMenuBar() and HideMenuBar(). */
    27 /* we need this for ShowMenuBar() and HideMenuBar(). */
    28 #include <Carbon/Carbon.h>
    28 #include <Carbon/Carbon.h>
       
    29 
       
    30 static inline void Cocoa_ToggleMenuBar(const BOOL show)
       
    31 {
       
    32     /* !!! FIXME: keep an eye on this.
       
    33      * ShowMenuBar/HideMenuBar is officially unavailable for 64-bit binaries.
       
    34      *  It happens to work, as of 10.7, but we're going to see if
       
    35      *  we can just simply do without it on newer OSes...
       
    36      */
       
    37 #if (MAC_OS_X_VERSION_MIN_REQUIRED < 1070) && !defined(__LP64__)
       
    38     if (show)
       
    39         ShowMenuBar();
       
    40     else
       
    41         HideMenuBar();
       
    42 #endif
       
    43 }
       
    44 
    29 
    45 
    30 /* !!! FIXME: clean out the pre-10.6 code when it makes sense to do so. */
    46 /* !!! FIXME: clean out the pre-10.6 code when it makes sense to do so. */
    31 #define FORCE_OLD_API 0 || (MAC_OS_X_VERSION_MAX_ALLOWED < 1060)
    47 #define FORCE_OLD_API 0 || (MAC_OS_X_VERSION_MAX_ALLOWED < 1060)
    32 
    48 
    33 #if FORCE_OLD_API
    49 #if FORCE_OLD_API
   382         } else {
   398         } else {
   383             CGDisplayRelease(displaydata->display);
   399             CGDisplayRelease(displaydata->display);
   384         }
   400         }
   385 
   401 
   386         if (CGDisplayIsMain(displaydata->display)) {
   402         if (CGDisplayIsMain(displaydata->display)) {
   387             ShowMenuBar();
   403             Cocoa_ToggleMenuBar(YES);
   388         }
   404         }
   389     } else {
   405     } else {
   390         /* Put up the blanking window (a window above all other windows) */
   406         /* Put up the blanking window (a window above all other windows) */
   391         if (CGDisplayIsMain(displaydata->display)) {
   407         if (CGDisplayIsMain(displaydata->display)) {
   392             /* If we don't capture all displays, Cocoa tries to rearrange windows... *sigh* */
   408             /* If we don't capture all displays, Cocoa tries to rearrange windows... *sigh* */
   406             goto ERR_NO_SWITCH;
   422             goto ERR_NO_SWITCH;
   407         }
   423         }
   408 
   424 
   409         /* Hide the menu bar so it doesn't intercept events */
   425         /* Hide the menu bar so it doesn't intercept events */
   410         if (CGDisplayIsMain(displaydata->display)) {
   426         if (CGDisplayIsMain(displaydata->display)) {
   411             HideMenuBar();
   427             Cocoa_ToggleMenuBar(NO);
   412         }
   428         }
   413     }
   429     }
   414 
   430 
   415     /* Fade in again (asynchronously) */
   431     /* Fade in again (asynchronously) */
   416     if (fade_token != kCGDisplayFadeReservationInvalidToken) {
   432     if (fade_token != kCGDisplayFadeReservationInvalidToken) {
   451             mode = (SDL_DisplayModeData*) display->display_modes[j].driverdata;
   467             mode = (SDL_DisplayModeData*) display->display_modes[j].driverdata;
   452             Cocoa_ReleaseDisplayMode(_this, mode->moderef);
   468             Cocoa_ReleaseDisplayMode(_this, mode->moderef);
   453         }
   469         }
   454 
   470 
   455     }
   471     }
   456     ShowMenuBar();
   472     Cocoa_ToggleMenuBar(YES);
   457 }
   473 }
   458 
   474 
   459 #endif /* SDL_VIDEO_DRIVER_COCOA */
   475 #endif /* SDL_VIDEO_DRIVER_COCOA */
   460 
   476 
   461 /* vi: set ts=4 sw=4 expandtab: */
   477 /* vi: set ts=4 sw=4 expandtab: */