Make SDL-1.2 Quartz target to work on Lion when built with the 10.4u SDK. SDL-1.2
authorRyan C. Gordon <icculus@icculus.org>
Fri, 16 Sep 2011 01:37:44 -0400
branchSDL-1.2
changeset 5945 3868f2e09b12
parent 5944 f5c4ce6a2f67
child 5946 19520acd1501
Make SDL-1.2 Quartz target to work on Lion when built with the 10.4u SDK. sigh.
src/video/quartz/SDL_QuartzVideo.h
src/video/quartz/SDL_QuartzVideo.m
--- a/src/video/quartz/SDL_QuartzVideo.h	Fri Sep 16 00:46:59 2011 -0400
+++ b/src/video/quartz/SDL_QuartzVideo.h	Fri Sep 16 01:37:44 2011 -0400
@@ -86,6 +86,7 @@
 
 /* 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 @@
 #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)
--- a/src/video/quartz/SDL_QuartzVideo.m	Fri Sep 16 00:46:59 2011 -0400
+++ b/src/video/quartz/SDL_QuartzVideo.m	Fri Sep 16 01:37:44 2011 -0400
@@ -127,7 +127,7 @@
 {
     /* 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 @@
 {
     /* 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 @@
     }
 
 #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 @@
 #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 @@
     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 @@
 #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 @@
     }
 
 #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 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 @@
     }
 
 #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 @@
 #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) {