From 18bc4d1a1d27b0cf5b06be9322c65ca88282b1ee Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sun, 2 Mar 2025 17:11:04 +0300
Subject: [PATCH] video, quartz: fix build against macOS 10.9+ SDKs when
targeting 10.6-
---
src/video/quartz/SDL_QuartzVideo.h | 2 +-
src/video/quartz/SDL_QuartzVideo.m | 12 ++++++++----
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/video/quartz/SDL_QuartzVideo.h b/src/video/quartz/SDL_QuartzVideo.h
index 408689c4..d121db35 100644
--- a/src/video/quartz/SDL_QuartzVideo.h
+++ b/src/video/quartz/SDL_QuartzVideo.h
@@ -91,7 +91,7 @@ typedef struct SDL_PrivateVideoData {
CGDirectDisplayID display; /* 0 == main display (only support single display) */
const void *mode; /* current mode of the display */
const void *save_mode; /* original mode of the display */
-#if (MAC_OS_X_VERSION_MIN_REQUIRED < 1070)
+#if (MAC_OS_X_VERSION_MIN_REQUIRED < 1070) && (MAC_OS_X_VERSION_MAX_ALLOWED < 1090)
CGDirectPaletteRef palette; /* palette of an 8-bit display */
#endif
NSOpenGLContext *gl_context; /* OpenGL rendering context */
diff --git a/src/video/quartz/SDL_QuartzVideo.m b/src/video/quartz/SDL_QuartzVideo.m
index f147cf0a..8721b148 100644
--- a/src/video/quartz/SDL_QuartzVideo.m
+++ b/src/video/quartz/SDL_QuartzVideo.m
@@ -35,7 +35,9 @@ CG_EXTERN size_t CGDisplayBytesPerRow(CGDirectDisplayID display)
CG_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_6,
__IPHONE_NA, __IPHONE_NA);
#endif
-
+#if (MAC_OS_X_VERSION_MIN_REQUIRED < 1070) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1090)
+#warning Palette code disabled when building against 10.9+ SDK
+#endif
static inline BOOL IS_LION_OR_LATER(_THIS)
{
@@ -333,7 +335,7 @@ static int QZ_VideoInit (_THIS, SDL_PixelFormat *video_format)
}
#endif
-#if (MAC_OS_X_VERSION_MIN_REQUIRED < 1070)
+#if (MAC_OS_X_VERSION_MIN_REQUIRED < 1070) && (MAC_OS_X_VERSION_MAX_ALLOWED < 1090)
if (!IS_LION_OR_LATER(this)) {
palette = CGPaletteCreateDefaultColorPalette();
}
@@ -783,8 +785,10 @@ other blitting while waiting on the VBL (and hence results in higher framerates)
thread = SDL_CreateThread ((int (*)(void *))QZ_ThreadFlip, this);
}
+ #if (MAC_OS_X_VERSION_MAX_ALLOWED < 1090)
if ( CGDisplayCanSetPalette (display_id) )
current->flags |= SDL_HWPALETTE;
+ #endif
}
#endif
@@ -1264,7 +1268,7 @@ static int QZ_ToggleFullScreen (_THIS, int on)
static int QZ_SetColors (_THIS, int first_color, int num_colors,
SDL_Color *colors)
{
-#if (MAC_OS_X_VERSION_MIN_REQUIRED < 1070)
+#if (MAC_OS_X_VERSION_MIN_REQUIRED < 1070) && (MAC_OS_X_VERSION_MAX_ALLOWED < 1090)
/* we shouldn't have an 8-bit mode on Lion! */
if (!IS_LION_OR_LATER(this)) {
CGTableCount index;
@@ -1592,7 +1596,7 @@ static void QZ_VideoQuit (_THIS)
else
QZ_UnsetVideoMode (this, TRUE, FALSE);
-#if (MAC_OS_X_VERSION_MIN_REQUIRED < 1070)
+#if (MAC_OS_X_VERSION_MIN_REQUIRED < 1070) && (MAC_OS_X_VERSION_MAX_ALLOWED < 1090)
if (!IS_LION_OR_LATER(this)) {
CGPaletteRelease(palette);
}