Skip to content
Permalink
Browse files

Make SDL-1.2 Quartz target to work on Lion when built with the 10.4u …

…SDK.

sigh.
  • Loading branch information
icculus committed Sep 16, 2011
1 parent 75c93a1 commit 9fbe67bd156df0da4a5a6b0d1c06a1c03f513cd5
Showing with 20 additions and 12 deletions.
  1. +2 −0 src/video/quartz/SDL_QuartzVideo.h
  2. +18 −12 src/video/quartz/SDL_QuartzVideo.m
@@ -86,6 +86,7 @@ CGLContextObj QZ_GetCGLContextObj(NSOpenGLContext *nsctx);

/* Main driver structure to store required state information */
typedef struct SDL_PrivateVideoData {
BOOL use_new_mode_apis; /* 1 == >= 10.6 APIs available */
BOOL allow_screensaver; /* 0 == disable screensaver */
CGDirectDisplayID display; /* 0 == main display (only support single display) */
const void *mode; /* current mode of the display */
@@ -127,6 +128,7 @@ typedef struct SDL_PrivateVideoData {
#define display_id (this->hidden->display)
#define mode (this->hidden->mode)
#define save_mode (this->hidden->save_mode)
#define use_new_mode_apis (this->hidden->use_new_mode_apis)
#define allow_screensaver (this->hidden->allow_screensaver)
#define palette (this->hidden->palette)
#define gl_context (this->hidden->gl_context)
@@ -127,7 +127,7 @@ static void QZ_ReleaseDisplayMode(_THIS, const void *moderef)
{
/* we only own these references in the 10.6+ API. */
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)
if (IS_SNOW_LEOPARD_OR_LATER(this)) {
if (use_new_mode_apis) {
CGDisplayModeRelease((CGDisplayModeRef) moderef);
}
#endif
@@ -137,7 +137,7 @@ static void QZ_ReleaseDisplayModeList(_THIS, CFArrayRef mode_list)
{
/* we only own these references in the 10.6+ API. */
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)
if (IS_SNOW_LEOPARD_OR_LATER(this)) {
if (use_new_mode_apis) {
CFRelease(mode_list);
}
#endif
@@ -239,7 +239,7 @@ static void QZ_GetModeInfo(_THIS, const void *_mode, Uint32 *w, Uint32 *h, Uint3
}

#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)
if (IS_SNOW_LEOPARD_OR_LATER(this)) {
if (use_new_mode_apis) {
CGDisplayModeRef vidmode = (CGDisplayModeRef) _mode;
CFStringRef fmt = CGDisplayModeCopyPixelEncoding(vidmode);

@@ -257,7 +257,7 @@ static void QZ_GetModeInfo(_THIS, const void *_mode, Uint32 *w, Uint32 *h, Uint3
#endif

#if (MAC_OS_X_VERSION_MIN_REQUIRED < 1060)
if (!IS_SNOW_LEOPARD_OR_LATER(this)) {
if (!use_new_mode_apis) {
CFDictionaryRef vidmode = (CFDictionaryRef) _mode;
CFNumberGetValue (
CFDictionaryGetValue (vidmode, kCGDisplayBitsPerPixel),
@@ -287,6 +287,12 @@ static int QZ_VideoInit (_THIS, SDL_PixelFormat *video_format)
if ( Gestalt(gestaltSystemVersion, &system_version) != noErr )
system_version = 0;

use_new_mode_apis = NO;

#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)
use_new_mode_apis = IS_SNOW_LEOPARD_OR_LATER(this);
#endif

/* Initialize the video settings; this data persists between mode switches */
display_id = kCGDirectMainDisplay;

@@ -304,13 +310,13 @@ static int QZ_VideoInit (_THIS, SDL_PixelFormat *video_format)
#endif

#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)
if (IS_SNOW_LEOPARD_OR_LATER(this)) {
if (use_new_mode_apis) {
save_mode = CGDisplayCopyDisplayMode(display_id);
}
#endif

#if (MAC_OS_X_VERSION_MIN_REQUIRED < 1060)
if (!IS_SNOW_LEOPARD_OR_LATER(this)) {
if (!use_new_mode_apis) {
save_mode = CGDisplayCurrentMode(display_id);
}
#endif
@@ -394,13 +400,13 @@ static int QZ_VideoInit (_THIS, SDL_PixelFormat *video_format)
}

#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)
if (IS_SNOW_LEOPARD_OR_LATER(this)) {
if (use_new_mode_apis) {
mode_list = CGDisplayCopyAllDisplayModes(display_id, NULL);
}
#endif

#if (MAC_OS_X_VERSION_MIN_REQUIRED < 1060)
if (!IS_SNOW_LEOPARD_OR_LATER(this)) {
if (!use_new_mode_apis) {
mode_list = CGDisplayAvailableModes(display_id);
}
#endif
@@ -498,13 +504,13 @@ static SDL_bool QZ_WindowPosition(_THIS, int *x, int *y)
static CGError QZ_SetDisplayMode(_THIS, const void *vidmode)
{
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)
if (IS_SNOW_LEOPARD_OR_LATER(this)) {
if (use_new_mode_apis) {
return CGDisplaySetDisplayMode(display_id, (CGDisplayModeRef) vidmode, NULL);
}
#endif

#if (MAC_OS_X_VERSION_MIN_REQUIRED < 1060)
if (!IS_SNOW_LEOPARD_OR_LATER(this)) {
if (!use_new_mode_apis) {
return CGDisplaySwitchToMode(display_id, (CFDictionaryRef) vidmode);
}
#endif
@@ -606,7 +612,7 @@ static void QZ_UnsetVideoMode (_THIS, BOOL to_desktop)
}

#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)
if (IS_SNOW_LEOPARD_OR_LATER(this)) {
if (use_new_mode_apis) {
/* apparently, we have to roll our own now. :/ */
CFArrayRef mode_list = CGDisplayCopyAllDisplayModes(display_id, NULL);
if (mode_list != NULL) {
@@ -630,7 +636,7 @@ static void QZ_UnsetVideoMode (_THIS, BOOL to_desktop)
#endif

#if (MAC_OS_X_VERSION_MIN_REQUIRED < 1060)
if (!IS_SNOW_LEOPARD_OR_LATER(this)) {
if (!use_new_mode_apis) {
boolean_t exact = 0;
best = CGDisplayBestModeForParameters(display_id, bpp, w, h, &exact);
if (!exact) {

0 comments on commit 9fbe67b

Please sign in to comment.