From 79d0d58fdd699ef96df27fc301ec0daa746a5573 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 5 Jan 2012 19:19:58 -0500 Subject: [PATCH] Fixed bug 1363 - SDL 1.2 hg does not compile against the 10.5 SDK Alexei Svitkine 2012-01-05 15:55:47 PST Open SDL.xcodeproject and change SDK to 10.5 and try to build. It will fail. There are two errors: 1. Incorrect SDK version check in src/cdrom/macosx/AudioFilePlayer.h, which redefines FSIORefNum. FSIORefNum is actually defined in the 10.5 SDK, but not in the 10.4 one. 2. Code in SDL_QuartzVideo.m that tries to access NSScreen's private _frame ivar, which fails to link on 64-bit. See: https://www.google.com/?q=%22_OBJC_IVAR_%24_NSScreen._frame%22 Attached patch fixes both of these problems. --- src/cdrom/macosx/AudioFilePlayer.h | 2 +- src/video/quartz/SDL_QuartzVideo.m | 35 ++++++++++++++++-------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/cdrom/macosx/AudioFilePlayer.h b/src/cdrom/macosx/AudioFilePlayer.h index 6f9e07091..886d017a5 100644 --- a/src/cdrom/macosx/AudioFilePlayer.h +++ b/src/cdrom/macosx/AudioFilePlayer.h @@ -37,7 +37,7 @@ #include #endif -#if (MAC_OS_X_VERSION_MAX_ALLOWED <= 1050) +#if (MAC_OS_X_VERSION_MAX_ALLOWED < 1050) typedef SInt16 FSIORefNum; #endif diff --git a/src/video/quartz/SDL_QuartzVideo.m b/src/video/quartz/SDL_QuartzVideo.m index 86b1856c2..d86974c66 100644 --- a/src/video/quartz/SDL_QuartzVideo.m +++ b/src/video/quartz/SDL_QuartzVideo.m @@ -36,7 +36,18 @@ CG_EXTERN size_t CGDisplayBytesPerRow(CGDirectDisplayID display) __IPHONE_NA, __IPHONE_NA); #endif -#if (MAC_OS_X_VERSION_MAX_ALLOWED < 1060) /* Fixed in Snow Leopard */ + +static inline BOOL IS_LION_OR_LATER(_THIS) +{ + return (system_version >= 0x1070); +} + +static inline BOOL IS_SNOW_LEOPARD_OR_LATER(_THIS) +{ + return (system_version >= 0x1060); +} + +#if (MAC_OS_X_VERSION_MAX_ALLOWED < 1060) && !defined(__LP64__) /* Fixed in Snow Leopard */ /* Add methods to get at private members of NSScreen. Since there is a bug in Apple's screen switching code @@ -54,12 +65,14 @@ - (void) setFrame:(NSRect)frame; _frame = frame; } @end -static inline void QZ_SetFrame(NSScreen *nsscreen, NSRect frame) +static inline void QZ_SetFrame(_THIS, NSScreen *nsscreen, NSRect frame) { - [nsscreen setFrame:frame]; + if (!IS_SNOW_LEOPARD_OR_LATER(this)) { + [nsscreen setFrame:frame]; + } } #else -static inline void QZ_SetFrame(NSScreen *nsscreen, NSRect frame) +static inline void QZ_SetFrame(_THIS, NSScreen *nsscreen, NSRect frame) { } #endif @@ -125,16 +138,6 @@ static int QZ_SetColors (_THIS, int first_color, # endif #endif -static inline BOOL IS_LION_OR_LATER(_THIS) -{ - return (system_version >= 0x1070); -} - -static inline BOOL IS_SNOW_LEOPARD_OR_LATER(_THIS) -{ - return (system_version >= 0x1060); -} - static void QZ_ReleaseDisplayMode(_THIS, const void *moderef) { /* we only own these references in the 10.6+ API. */ @@ -607,7 +610,7 @@ static void QZ_UnsetVideoMode (_THIS, BOOL to_desktop, BOOL save_gl) See comment in QZ_SetVideoFullscreen for why we do this */ screen_rect = NSMakeRect(0,0,device_width,device_height); - QZ_SetFrame([ NSScreen mainScreen ], screen_rect); + QZ_SetFrame(this, [ NSScreen mainScreen ], screen_rect); } } /* Release window mode resources */ @@ -927,7 +930,7 @@ other blitting while waiting on the VBL (and hence results in higher framerates) ourselves. This hack should be removed if/when the bug is fixed. */ screen_rect = NSMakeRect(0,0,width,height); - QZ_SetFrame([ NSScreen mainScreen ], screen_rect); + QZ_SetFrame(this, [ NSScreen mainScreen ], screen_rect); /* Save the flags to ensure correct tear-down */ mode_flags = current->flags;