Ticket #52210: SDL2-2.0.4_OSX_105.patch

File SDL2-2.0.4_OSX_105.patch, 65.9 KB (added by miniupnp (Thomas BERNARD), 6 years ago)

patch to compile SDL2-2.0.4 under OS X 10.5.8 Leopard

  • include/SDL_config.h

    Only in SDL2-2.0.4: Makefile
    Only in SDL2-2.0.4: Makefile.rules
    Only in SDL2-2.0.4: build
    Only in SDL2-2.0.4: config.log
    Only in SDL2-2.0.4: config.status
    diff -ru SDL2-2.0.4-orig/include/SDL_config.h SDL2-2.0.4/include/SDL_config.h
    old new  
     1/* include/SDL_config.h.  Generated from SDL_config.h.in by configure.  */
    12/*
    23  Simple DirectMedia Layer
    34  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
     
    2223#ifndef _SDL_config_h
    2324#define _SDL_config_h
    2425
    25 #include "SDL_platform.h"
    26 
    2726/**
    28  *  \file SDL_config.h
     27 *  \file SDL_config.h.in
     28 *
     29 *  This is a set of defines to configure the SDL features
    2930 */
    3031
    31 /* Add any platform that doesn't build using the configure system. */
    32 #ifdef USING_PREMAKE_CONFIG_H
    33 #include "SDL_config_premake.h"
    34 #elif defined(__WIN32__)
    35 #include "SDL_config_windows.h"
    36 #elif defined(__WINRT__)
    37 #include "SDL_config_winrt.h"
    38 #elif defined(__MACOSX__)
    39 #include "SDL_config_macosx.h"
    40 #elif defined(__IPHONEOS__)
    41 #include "SDL_config_iphoneos.h"
    42 #elif defined(__ANDROID__)
    43 #include "SDL_config_android.h"
    44 #elif defined(__PSP__)
    45 #include "SDL_config_psp.h"
     32/* General platform specific identifiers */
     33#include "SDL_platform.h"
     34
     35/* Make sure that this isn't included by Visual C++ */
     36#ifdef _MSC_VER
     37#error You should run hg revert SDL_config.h
     38#endif
     39
     40/* C language features */
     41/* #undef const */
     42/* #undef inline */
     43/* #undef volatile */
     44
     45/* C datatypes */
     46#ifdef __LP64__
     47#define SIZEOF_VOIDP 8
    4648#else
    47 /* This is a minimal configuration just to get SDL running on new platforms */
    48 #include "SDL_config_minimal.h"
    49 #endif /* platform config */
     49#define SIZEOF_VOIDP 4
     50#endif
     51/* #undef HAVE_GCC_ATOMICS */
     52/* #undef HAVE_GCC_SYNC_LOCK_TEST_AND_SET */
     53
     54/* #undef HAVE_DDRAW_H */
     55/* #undef HAVE_DINPUT_H */
     56/* #undef HAVE_DSOUND_H */
     57/* #undef HAVE_DXGI_H */
     58/* #undef HAVE_XINPUT_H */
     59
     60/* Comment this if you want to build without any C library requirements */
     61#define HAVE_LIBC 1
     62#if HAVE_LIBC
    5063
    51 #ifdef USING_GENERATED_CONFIG_H
    52 #error Wrong SDL_config.h, check your include path?
     64/* Useful headers */
     65#define HAVE_ALLOCA_H 1
     66#define HAVE_SYS_TYPES_H 1
     67#define HAVE_STDIO_H 1
     68#define STDC_HEADERS 1
     69#define HAVE_STDLIB_H 1
     70#define HAVE_STDARG_H 1
     71/* #undef HAVE_MALLOC_H */
     72#define HAVE_MEMORY_H 1
     73#define HAVE_STRING_H 1
     74#define HAVE_STRINGS_H 1
     75#define HAVE_INTTYPES_H 1
     76#define HAVE_STDINT_H 1
     77#define HAVE_CTYPE_H 1
     78#define HAVE_MATH_H 1
     79#define HAVE_ICONV_H 1
     80#define HAVE_SIGNAL_H 1
     81#define HAVE_ALTIVEC_H 1
     82/* #undef HAVE_PTHREAD_NP_H */
     83/* #undef HAVE_LIBUDEV_H */
     84/* #undef HAVE_DBUS_DBUS_H */
     85/* #undef HAVE_IBUS_IBUS_H */
     86
     87/* C library functions */
     88#define HAVE_MALLOC 1
     89#define HAVE_CALLOC 1
     90#define HAVE_REALLOC 1
     91#define HAVE_FREE 1
     92#define HAVE_ALLOCA 1
     93#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */
     94#define HAVE_GETENV 1
     95#define HAVE_SETENV 1
     96#define HAVE_PUTENV 1
     97#define HAVE_UNSETENV 1
    5398#endif
     99#define HAVE_QSORT 1
     100#define HAVE_ABS 1
     101#define HAVE_BCOPY 1
     102#define HAVE_MEMSET 1
     103#define HAVE_MEMCPY 1
     104#define HAVE_MEMMOVE 1
     105#define HAVE_MEMCMP 1
     106#define HAVE_STRLEN 1
     107#define HAVE_STRLCPY 1
     108#define HAVE_STRLCAT 1
     109#define HAVE_STRDUP 1
     110/* #undef HAVE__STRREV */
     111/* #undef HAVE__STRUPR */
     112/* #undef HAVE__STRLWR */
     113/* #undef HAVE_INDEX */
     114/* #undef HAVE_RINDEX */
     115#define HAVE_STRCHR 1
     116#define HAVE_STRRCHR 1
     117#define HAVE_STRSTR 1
     118/* #undef HAVE_ITOA */
     119/* #undef HAVE__LTOA */
     120/* #undef HAVE__UITOA */
     121/* #undef HAVE__ULTOA */
     122#define HAVE_STRTOL 1
     123#define HAVE_STRTOUL 1
     124/* #undef HAVE__I64TOA */
     125/* #undef HAVE__UI64TOA */
     126#define HAVE_STRTOLL 1
     127#define HAVE_STRTOULL 1
     128#define HAVE_STRTOD 1
     129#define HAVE_ATOI 1
     130#define HAVE_ATOF 1
     131#define HAVE_STRCMP 1
     132#define HAVE_STRNCMP 1
     133/* #undef HAVE__STRICMP */
     134#define HAVE_STRCASECMP 1
     135/* #undef HAVE__STRNICMP */
     136#define HAVE_STRNCASECMP 1
     137/* #undef HAVE_SSCANF */
     138#define HAVE_VSSCANF 1
     139/* #undef HAVE_SNPRINTF */
     140#define HAVE_VSNPRINTF 1
     141#define HAVE_M_PI /**/
     142#define HAVE_ATAN 1
     143#define HAVE_ATAN2 1
     144#define HAVE_ACOS 1
     145#define HAVE_ASIN 1
     146#define HAVE_CEIL 1
     147#define HAVE_COPYSIGN 1
     148#define HAVE_COS 1
     149#define HAVE_COSF 1
     150#define HAVE_FABS 1
     151#define HAVE_FLOOR 1
     152#define HAVE_LOG 1
     153#define HAVE_POW 1
     154#define HAVE_SCALBN 1
     155#define HAVE_SIN 1
     156#define HAVE_SINF 1
     157#define HAVE_SQRT 1
     158#define HAVE_SQRTF 1
     159#define HAVE_TAN 1
     160#define HAVE_TANF 1
     161#define HAVE_FSEEKO 1
     162/* #undef HAVE_FSEEKO64 */
     163#define HAVE_SIGACTION 1
     164#define HAVE_SA_SIGACTION 1
     165#define HAVE_SETJMP 1
     166#define HAVE_NANOSLEEP 1
     167#define HAVE_SYSCONF 1
     168#define HAVE_SYSCTLBYNAME 1
     169/* #undef HAVE_CLOCK_GETTIME */
     170/* #undef HAVE_GETPAGESIZE */
     171#define HAVE_MPROTECT 1
     172#define HAVE_ICONV 1
     173/* #undef HAVE_PTHREAD_SETNAME_NP */
     174/* #undef HAVE_PTHREAD_SET_NAME_NP */
     175/* #undef HAVE_SEM_TIMEDWAIT */
     176
     177#else
     178#define HAVE_STDARG_H 1
     179#define HAVE_STDDEF_H 1
     180#define HAVE_STDINT_H 1
     181#endif /* HAVE_LIBC */
     182
     183/* SDL internal assertion support */
     184/* #undef SDL_DEFAULT_ASSERT_LEVEL */
     185
     186/* Allow disabling of core subsystems */
     187/* #undef SDL_ATOMIC_DISABLED */
     188/* #undef SDL_AUDIO_DISABLED */
     189/* #undef SDL_CPUINFO_DISABLED */
     190/* #undef SDL_EVENTS_DISABLED */
     191/* #undef SDL_FILE_DISABLED */
     192/* #undef SDL_JOYSTICK_DISABLED */
     193/* #undef SDL_HAPTIC_DISABLED */
     194/* #undef SDL_LOADSO_DISABLED */
     195/* #undef SDL_RENDER_DISABLED */
     196/* #undef SDL_THREADS_DISABLED */
     197/* #undef SDL_TIMERS_DISABLED */
     198/* #undef SDL_VIDEO_DISABLED */
     199/* #undef SDL_POWER_DISABLED */
     200/* #undef SDL_FILESYSTEM_DISABLED */
     201
     202/* Enable various audio drivers */
     203/* #undef SDL_AUDIO_DRIVER_ALSA */
     204/* #undef SDL_AUDIO_DRIVER_ALSA_DYNAMIC */
     205/* #undef SDL_AUDIO_DRIVER_ARTS */
     206/* #undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC */
     207/* #undef SDL_AUDIO_DRIVER_PULSEAUDIO */
     208/* #undef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC */
     209/* #undef SDL_AUDIO_DRIVER_HAIKU */
     210/* #undef SDL_AUDIO_DRIVER_BSD */
     211#define SDL_AUDIO_DRIVER_COREAUDIO 1
     212#define SDL_AUDIO_DRIVER_DISK 1
     213#define SDL_AUDIO_DRIVER_DUMMY 1
     214/* #undef SDL_AUDIO_DRIVER_ANDROID */
     215/* #undef SDL_AUDIO_DRIVER_XAUDIO2 */
     216/* #undef SDL_AUDIO_DRIVER_DSOUND */
     217/* #undef SDL_AUDIO_DRIVER_ESD */
     218/* #undef SDL_AUDIO_DRIVER_ESD_DYNAMIC */
     219/* #undef SDL_AUDIO_DRIVER_NACL */
     220/* #undef SDL_AUDIO_DRIVER_NAS */
     221/* #undef SDL_AUDIO_DRIVER_NAS_DYNAMIC */
     222/* #undef SDL_AUDIO_DRIVER_SNDIO */
     223/* #undef SDL_AUDIO_DRIVER_SNDIO_DYNAMIC */
     224/* #undef SDL_AUDIO_DRIVER_OSS */
     225/* #undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H */
     226/* #undef SDL_AUDIO_DRIVER_PAUDIO */
     227/* #undef SDL_AUDIO_DRIVER_QSA */
     228/* #undef SDL_AUDIO_DRIVER_SUNAUDIO */
     229/* #undef SDL_AUDIO_DRIVER_WINMM */
     230/* #undef SDL_AUDIO_DRIVER_FUSIONSOUND */
     231/* #undef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC */
     232/* #undef SDL_AUDIO_DRIVER_EMSCRIPTEN */
     233
     234/* Enable various input drivers */
     235/* #undef SDL_INPUT_LINUXEV */
     236/* #undef SDL_INPUT_LINUXKD */
     237/* #undef SDL_INPUT_TSLIB */
     238/* #undef SDL_JOYSTICK_HAIKU */
     239/* #undef SDL_JOYSTICK_DINPUT */
     240/* #undef SDL_JOYSTICK_XINPUT */
     241/* #undef SDL_JOYSTICK_DUMMY */
     242#define SDL_JOYSTICK_IOKIT 1
     243/* #undef SDL_JOYSTICK_LINUX */
     244/* #undef SDL_JOYSTICK_ANDROID */
     245/* #undef SDL_JOYSTICK_WINMM */
     246/* #undef SDL_JOYSTICK_USBHID */
     247/* #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H */
     248/* #undef SDL_JOYSTICK_EMSCRIPTEN */
     249/* #undef SDL_HAPTIC_DUMMY */
     250/* #undef SDL_HAPTIC_LINUX */
     251#define SDL_HAPTIC_IOKIT 1
     252/* #undef SDL_HAPTIC_DINPUT */
     253/* #undef SDL_HAPTIC_XINPUT */
     254
     255/* Enable various shared object loading systems */
     256/* #undef SDL_LOADSO_HAIKU */
     257#define SDL_LOADSO_DLOPEN 1
     258/* #undef SDL_LOADSO_DUMMY */
     259/* #undef SDL_LOADSO_LDG */
     260/* #undef SDL_LOADSO_WINDOWS */
     261
     262/* Enable various threading systems */
     263#define SDL_THREAD_PTHREAD 1
     264#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
     265/* #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP */
     266/* #undef SDL_THREAD_WINDOWS */
     267
     268/* Enable various timer systems */
     269/* #undef SDL_TIMER_HAIKU */
     270/* #undef SDL_TIMER_DUMMY */
     271#define SDL_TIMER_UNIX 1
     272/* #undef SDL_TIMER_WINDOWS */
     273
     274/* Enable various video drivers */
     275/* #undef SDL_VIDEO_DRIVER_HAIKU */
     276#define SDL_VIDEO_DRIVER_COCOA 1
     277/* #undef SDL_VIDEO_DRIVER_DIRECTFB */
     278/* #undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC */
     279#define SDL_VIDEO_DRIVER_DUMMY 1
     280/* #undef SDL_VIDEO_DRIVER_WINDOWS */
     281/* #undef SDL_VIDEO_DRIVER_WAYLAND */
     282/* #undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
     283/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC */
     284/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL */
     285/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR */
     286/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON */
     287/* #undef SDL_VIDEO_DRIVER_MIR */
     288/* #undef SDL_VIDEO_DRIVER_MIR_DYNAMIC */
     289/* #undef SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON */
     290#define SDL_VIDEO_DRIVER_X11 1
     291/* #undef SDL_VIDEO_DRIVER_RPI */
     292/* #undef SDL_VIDEO_DRIVER_ANDROID */
     293/* #undef SDL_VIDEO_DRIVER_EMSCRIPTEN */
     294#define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib"
     295#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib"
     296#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR "/usr/X11R6/lib/libXcursor.1.dylib"
     297#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/usr/X11R6/lib/libXinerama.1.dylib"
     298/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 */
     299/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR */
     300#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/usr/X11R6/lib/libXss.1.dylib"
     301#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "/usr/X11R6/lib/libXxf86vm.1.dylib"
     302#define SDL_VIDEO_DRIVER_X11_XCURSOR 1
     303#define SDL_VIDEO_DRIVER_X11_XDBE 1
     304#define SDL_VIDEO_DRIVER_X11_XINERAMA 1
     305/* #undef SDL_VIDEO_DRIVER_X11_XINPUT2 */
     306/* #undef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH */
     307/* #undef SDL_VIDEO_DRIVER_X11_XRANDR */
     308#define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1
     309#define SDL_VIDEO_DRIVER_X11_XSHAPE 1
     310#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1
     311/* #undef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS */
     312/* #undef SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY */
     313#define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1
     314/* #undef SDL_VIDEO_DRIVER_NACL */
     315/* #undef SDL_VIDEO_DRIVER_VIVANTE */
     316/* #undef SDL_VIDEO_DRIVER_VIVANTE_VDK */
     317
     318/* #undef SDL_VIDEO_RENDER_D3D */
     319/* #undef SDL_VIDEO_RENDER_D3D11 */
     320#define SDL_VIDEO_RENDER_OGL 1
     321/* #undef SDL_VIDEO_RENDER_OGL_ES */
     322/* #undef SDL_VIDEO_RENDER_OGL_ES2 */
     323/* #undef SDL_VIDEO_RENDER_DIRECTFB */
     324
     325/* Enable OpenGL support */
     326#define SDL_VIDEO_OPENGL 1
     327/* #undef SDL_VIDEO_OPENGL_ES */
     328/* #undef SDL_VIDEO_OPENGL_ES2 */
     329/* #undef SDL_VIDEO_OPENGL_BGL */
     330#define SDL_VIDEO_OPENGL_CGL 1
     331/* #undef SDL_VIDEO_OPENGL_EGL */
     332#define SDL_VIDEO_OPENGL_GLX 1
     333/* #undef SDL_VIDEO_OPENGL_WGL */
     334/* #undef SDL_VIDEO_OPENGL_OSMESA */
     335/* #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC */
     336
     337/* Enable system power support */
     338/* #undef SDL_POWER_LINUX */
     339/* #undef SDL_POWER_WINDOWS */
     340#define SDL_POWER_MACOSX 1
     341/* #undef SDL_POWER_HAIKU */
     342/* #undef SDL_POWER_ANDROID */
     343/* #undef SDL_POWER_EMSCRIPTEN */
     344/* #undef SDL_POWER_HARDWIRED */
     345
     346/* Enable system filesystem support */
     347/* #undef SDL_FILESYSTEM_HAIKU */
     348#define SDL_FILESYSTEM_COCOA 1
     349/* #undef SDL_FILESYSTEM_DUMMY */
     350/* #undef SDL_FILESYSTEM_UNIX */
     351/* #undef SDL_FILESYSTEM_WINDOWS */
     352/* #undef SDL_FILESYSTEM_NACL */
     353/* #undef SDL_FILESYSTEM_ANDROID */
     354/* #undef SDL_FILESYSTEM_EMSCRIPTEN */
     355
     356/* Enable assembly routines */
     357#define SDL_ASSEMBLY_ROUTINES 1
     358#define SDL_ALTIVEC_BLITTERS 1
    54359
    55360#endif /* _SDL_config_h */
  • include/SDL_platform.h

    diff -ru SDL2-2.0.4-orig/include/SDL_platform.h SDL2-2.0.4/include/SDL_platform.h
    old new  
    7070/* lets us know what version of Mac OS X we're compiling on */
    7171#include "AvailabilityMacros.h"
    7272#include "TargetConditionals.h"
    73 #if TARGET_OS_IPHONE
     73#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
    7474/* if compiling for iPhone */
    7575#undef __IPHONEOS__
    7676#define __IPHONEOS__ 1
     
    8080#undef __MACOSX__
    8181#define __MACOSX__  1
    8282#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050
     83#if 0
    8384# error SDL for Mac OS X only supports deploying on 10.5 and above.
     85#endif
    8486#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1050 */
    8587#endif /* TARGET_OS_IPHONE */
    8688#endif /* defined(__APPLE__) */
  • include/SDL_syswm.h

    diff -ru SDL2-2.0.4-orig/include/SDL_syswm.h SDL2-2.0.4/include/SDL_syswm.h
    old new  
    215215#if defined(SDL_VIDEO_DRIVER_COCOA)
    216216        struct
    217217        {
     218#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    218219#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
    219220            NSWindow __unsafe_unretained *window; /* The Cocoa window */
    220221#else
    221222            NSWindow *window;                     /* The Cocoa window */
    222223#endif
     224#else
     225            NSWindow *window;                     /* The Cocoa window */
     226#endif
    223227        } cocoa;
    224228#endif
    225229#if defined(SDL_VIDEO_DRIVER_UIKIT)
    226230        struct
    227231        {
     232#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    228233#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
    229234            UIWindow __unsafe_unretained *window; /* The UIKit window */
    230235#else
    231236            UIWindow *window;                     /* The UIKit window */
    232237#endif
     238#else
     239            UIWindow *window;                     /* The UIKit window */
     240#endif
    233241            GLuint framebuffer; /* The GL view's Framebuffer Object. It must be bound when rendering to the screen using GL. */
    234242            GLuint colorbuffer; /* The GL view's color Renderbuffer Object. It must be bound when SDL_GL_SwapWindow is called. */
    235243            GLuint resolveFramebuffer; /* The Framebuffer Object which holds the resolve color Renderbuffer, when MSAA is used. */
  • src/atomic/SDL_spinlock.c

    Only in SDL2-2.0.4: libtool
    Only in SDL2-2.0.4: sdl2-config
    Only in SDL2-2.0.4: sdl2-config.cmake
    Only in SDL2-2.0.4: sdl2.pc
    diff -ru SDL2-2.0.4-orig/src/atomic/SDL_spinlock.c SDL2-2.0.4/src/atomic/SDL_spinlock.c
    old new  
    2828#include "SDL_mutex.h"
    2929#include "SDL_timer.h"
    3030
     31#if defined(__MACOSX__) || defined(__IPHONEOS__)
     32#include <libkern/OSAtomic.h>
     33#endif
     34
    3135#if !defined(HAVE_GCC_ATOMICS) && defined(__SOLARIS__)
    3236#include <atomic.h>
    3337#endif
  • src/file/cocoa/SDL_rwopsbundlesupport.m

    diff -ru SDL2-2.0.4-orig/src/file/cocoa/SDL_rwopsbundlesupport.m SDL2-2.0.4/src/file/cocoa/SDL_rwopsbundlesupport.m
    old new  
    3333 Also, note the bundle layouts are different for iPhone and Mac.
    3434*/
    3535FILE* SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode)
     36#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    3637{ @autoreleasepool
     38#endif
    3739{
    3840    FILE* fp = NULL;
    3941
     
    4244        return fopen(file, mode);
    4345    }
    4446
     47#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     48    NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
     49#endif
    4550    NSFileManager* file_manager = [NSFileManager defaultManager];
    4651    NSString* resource_path = [[NSBundle mainBundle] resourcePath];
    4752
     
    5459        fp = fopen(file, mode);
    5560    }
    5661
     62#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     63    [autorelease_pool drain];
     64#endif
    5765    return fp;
     66#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     67}
     68#else
    5869}}
     70#endif
    5971
    6072#endif /* __APPLE__ */
    6173
  • src/filesystem/cocoa/SDL_sysfilesystem.m

    diff -ru SDL2-2.0.4-orig/src/filesystem/cocoa/SDL_sysfilesystem.m SDL2-2.0.4/src/filesystem/cocoa/SDL_sysfilesystem.m
    old new  
    3535
    3636char *
    3737SDL_GetBasePath(void)
     38#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    3839{ @autoreleasepool
    3940{
     41#else
     42{
     43    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     44#endif
    4045    NSBundle *bundle = [NSBundle mainBundle];
    4146    const char* baseType = [[[bundle infoDictionary] objectForKey:@"SDL_FILESYSTEM_BASE_DIR_TYPE"] UTF8String];
    4247    const char *base = NULL;
     
    6469        }
    6570    }
    6671
     72#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    6773    return retval;
    6874}}
     75#else
     76    [pool release];
     77    return retval;
     78}
     79#endif
    6980
    7081char *
    7182SDL_GetPrefPath(const char *org, const char *app)
     83#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    7284{ @autoreleasepool
    7385{
     86#else
     87{
     88    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     89#endif
    7490    char *retval = NULL;
    7591
    7692    NSArray *array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
     
    98114        }
    99115    }
    100116
     117#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    101118    return retval;
    102119}}
     120#else
     121    [pool release];
     122    return retval;
     123}
     124#endif
    103125
    104126#endif /* SDL_FILESYSTEM_COCOA */
    105127
  • src/joystick/darwin/SDL_sysjoystick.c

    diff -ru SDL2-2.0.4-orig/src/joystick/darwin/SDL_sysjoystick.c SDL2-2.0.4/src/joystick/darwin/SDL_sysjoystick.c
    old new  
    452452
    453453    /* We have to do some storage of the io_service_t for SDL_HapticOpenFromJoystick */
    454454
    455 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
     455#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    456456    if (IOHIDDeviceGetService != NULL) {  /* weak reference: available in 10.6 and later. */
    457 #endif
    458457
    459458        const io_service_t ioservice = IOHIDDeviceGetService(ioHIDDeviceObject);
    460459#if SDL_HAPTIC_IOKIT
     
    464463        }
    465464#endif
    466465
    467 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
    468466    }
    469467#endif
    470468
  • src/video/cocoa/SDL_cocoaclipboard.m

    diff -ru SDL2-2.0.4-orig/src/video/cocoa/SDL_cocoaclipboard.m SDL2-2.0.4/src/video/cocoa/SDL_cocoaclipboard.m
    old new  
    2828static NSString *
    2929GetTextFormat(_THIS)
    3030{
     31#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    3132    if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) {
    3233        return NSPasteboardTypeString;
    3334    } else {
     35#endif
    3436        return NSStringPboardType;
     37#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    3538    }
     39#endif
    3640}
    3741
    3842int
    3943Cocoa_SetClipboardText(_THIS, const char *text)
     44#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    4045{ @autoreleasepool
    4146{
     47#else
     48{   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
     49#endif
    4250    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    4351    NSPasteboard *pasteboard;
    4452    NSString *format = GetTextFormat(_this);
     
    4755    data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
    4856    [pasteboard setString:[NSString stringWithUTF8String:text] forType:format];
    4957
     58#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     59    [pool release];
     60#endif
    5061    return 0;
     62#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    5163}}
     64#else
     65}
     66#endif
    5267
    5368char *
    5469Cocoa_GetClipboardText(_THIS)
     70#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    5571{ @autoreleasepool
    5672{
     73#else
     74{   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
     75#endif
    5776    NSPasteboard *pasteboard;
    5877    NSString *format = GetTextFormat(_this);
    5978    NSString *available;
     
    7695        text = SDL_strdup("");
    7796    }
    7897
     98#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     99    [pool release];
     100#endif
    79101    return text;
     102#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    80103}}
     104#else
     105}
     106#endif
    81107
    82108SDL_bool
    83109Cocoa_HasClipboardText(_THIS)
     
    93119
    94120void
    95121Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data)
     122#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    96123{ @autoreleasepool
    97124{
     125#else
     126{   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
     127#endif
    98128    NSPasteboard *pasteboard;
    99129    NSInteger count;
    100130
     
    106136        }
    107137        data->clipboard_count = count;
    108138    }
     139#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    109140}}
     141#else
     142    [pool release];
     143}
     144#endif
    110145
    111146#endif /* SDL_VIDEO_DRIVER_COCOA */
    112147
  • src/video/cocoa/SDL_cocoaevents.m

    diff -ru SDL2-2.0.4-orig/src/video/cocoa/SDL_cocoaevents.m SDL2-2.0.4/src/video/cocoa/SDL_cocoaevents.m
    old new  
    5454- (void)setAppleMenu:(NSMenu *)menu;
    5555@end
    5656
     57#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    5758@interface SDLAppDelegate : NSObject <NSApplicationDelegate> {
     59#else
     60@interface SDLAppDelegate : NSObject {
     61#endif
    5862@public
    5963    BOOL seenFirstActivate;
    6064}
     
    311315
    312316void
    313317Cocoa_RegisterApp(void)
     318#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    314319{ @autoreleasepool
     320#endif
    315321{
    316322    /* This can get called more than once! Be careful what you initialize! */
    317 
     323#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     324    NSAutoreleasePool *pool;
     325    pool = [[NSAutoreleasePool alloc] init];
     326#endif
    318327    if (NSApp == nil) {
    319328        [SDLApplication sharedApplication];
    320329        SDL_assert(NSApp != nil);
    321330
    322331        const char *hint = SDL_GetHint(SDL_HINT_MAC_BACKGROUND_APP);
    323332        if (!hint || *hint == '0') {
     333#if defined(MAC_OS_X_VERSION_10_6)
    324334#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
    325335                        if ([NSApp respondsToSelector:@selector(setActivationPolicy:)]) {
    326336#endif
     
    331341                                TransformProcessType(&psn, kProcessTransformToForegroundApplication);
    332342                        }
    333343#endif
     344#endif
    334345            [NSApp activateIgnoringOtherApps:YES];
    335346                }
    336347               
     
    358369            appDelegate->seenFirstActivate = YES;
    359370        }
    360371    }
     372#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    361373}}
     374#else
     375    [pool release];
     376}
     377#endif
    362378
    363379void
    364380Cocoa_PumpEvents(_THIS)
     381#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    365382{ @autoreleasepool
    366383{
     384#else
     385{
     386    NSAutoreleasePool *pool;
     387#endif
    367388    /* Update activity every 30 seconds to prevent screensaver */
    368389    SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
    369390    if (_this->suspend_screensaver && !data->screensaver_use_iopm) {
     
    375396        }
    376397    }
    377398
     399#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     400    pool = [[NSAutoreleasePool alloc] init];
     401#endif
    378402    for ( ; ; ) {
    379403        NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
    380404        if ( event == nil ) {
     
    406430        /* Pass through to NSApp to make sure everything stays in sync */
    407431        [NSApp sendEvent:event];
    408432    }
     433#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    409434}}
     435#else
     436    [pool release];
     437}
     438#endif
    410439
    411440void
    412441Cocoa_SuspendScreenSaver(_THIS)
     442#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    413443{ @autoreleasepool
    414444{
    415445    SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
     
    436466                                           &data->screensaver_assertion);
    437467    }
    438468}}
     469#else
     470{
     471}
     472#endif
    439473
    440474#endif /* SDL_VIDEO_DRIVER_COCOA */
    441475
  • src/video/cocoa/SDL_cocoakeyboard.m

    diff -ru SDL2-2.0.4-orig/src/video/cocoa/SDL_cocoakeyboard.m SDL2-2.0.4/src/video/cocoa/SDL_cocoakeyboard.m
    old new  
    150150            aRange.location, aRange.length, windowHeight,
    151151            NSStringFromRect(rect));
    152152
     153#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    153154    if ([[self window] respondsToSelector:@selector(convertRectToScreen:)]) {
    154155        rect = [[self window] convertRectToScreen:rect];
    155156    } else {
     157#endif
    156158        rect.origin = [[self window] convertBaseToScreen:rect.origin];
     159#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    157160    }
     161#endif
    158162
    159163    return rect;
    160164}
     
    498502    SDL_SetScancodeName(SDL_SCANCODE_RALT, "Right Option");
    499503    SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Command");
    500504
     505#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    501506    /* On pre-10.6, you might have the initial capslock key state wrong. */
    502507    if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_6) {
    503508        data->modifierFlags = [NSEvent modifierFlags];
    504509        SDL_ToggleModState(KMOD_CAPS, (data->modifierFlags & NSAlphaShiftKeyMask) != 0);
    505510    }
     511#endif
    506512}
    507513
    508514void
    509515Cocoa_StartTextInput(_THIS)
     516#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    510517{ @autoreleasepool
     518#endif
    511519{
    512520    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
     521#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     522    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     523#endif
    513524    SDL_Window *window = SDL_GetKeyboardFocus();
    514525    NSWindow *nswindow = nil;
    515526    if (window) {
     
    534545        [parentView addSubview: data->fieldEdit];
    535546        [nswindow makeFirstResponder: data->fieldEdit];
    536547    }
     548#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    537549}}
     550#else
     551    [pool release];
     552}
     553#endif
    538554
    539555void
    540556Cocoa_StopTextInput(_THIS)
     557#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    541558{ @autoreleasepool
     559#endif
    542560{
    543561    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    544562
    545563    if (data && data->fieldEdit) {
     564#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     565        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     566#endif
    546567        [data->fieldEdit removeFromSuperview];
    547568        [data->fieldEdit release];
    548569        data->fieldEdit = nil;
     570#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     571        [pool release];
     572#endif
    549573    }
     574#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    550575}}
     576#else
     577}
     578#endif
    551579
    552580void
    553581Cocoa_SetTextInputRect(_THIS, SDL_Rect *rect)
  • src/video/cocoa/SDL_cocoamessagebox.m

    diff -ru SDL2-2.0.4-orig/src/video/cocoa/SDL_cocoamessagebox.m SDL2-2.0.4/src/video/cocoa/SDL_cocoamessagebox.m
    old new  
    7979/* Display a Cocoa message box */
    8080int
    8181Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
     82#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    8283{ @autoreleasepool
     84#endif
    8385{
    8486    Cocoa_RegisterApp();
    8587
     88#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     89    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     90#endif
    8691    NSAlert* alert = [[[NSAlert alloc] init] autorelease];
    8792
    8893    if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) {
     
    124129        returnValue = SDL_SetError("Did not get a valid `clicked button' id: %ld", (long)clicked);
    125130    }
    126131
     132#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     133    [pool release];
     134#endif
    127135    return returnValue;
     136#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    128137}}
     138#else
     139}
     140#endif
    129141
    130142#endif /* SDL_VIDEO_DRIVER_COCOA */
    131143
  • src/video/cocoa/SDL_cocoamodes.m

    diff -ru SDL2-2.0.4-orig/src/video/cocoa/SDL_cocoamodes.m SDL2-2.0.4/src/video/cocoa/SDL_cocoamodes.m
    old new  
    7070#if FORCE_OLD_API
    7171    return NO;
    7272#else
     73#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    7374    return floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5;
     75#else
     76    return NO;
     77#endif
    7478#endif
    7579}
    7680
     
    132136    }
    133137    data->moderef = moderef;
    134138
     139    #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    135140    if (IS_SNOW_LEOPARD_OR_LATER()) {
    136141        CGDisplayModeRef vidmode = (CGDisplayModeRef) moderef;
    137142        CFStringRef fmt = CGDisplayModeCopyPixelEncoding(vidmode);
     
    154159
    155160        CFRelease(fmt);
    156161    }
     162    #endif
    157163
    158164    #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
    159165    if (!IS_SNOW_LEOPARD_OR_LATER()) {
     
    206212static void
    207213Cocoa_ReleaseDisplayMode(_THIS, const void *moderef)
    208214{
     215    #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    209216    if (IS_SNOW_LEOPARD_OR_LATER()) {
    210217        CGDisplayModeRelease((CGDisplayModeRef) moderef);  /* NULL is ok */
    211218    }
     219    #endif
    212220}
    213221
    214222static void
    215223Cocoa_ReleaseDisplayModeList(_THIS, CFArrayRef modelist)
    216224{
     225    #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    217226    if (IS_SNOW_LEOPARD_OR_LATER()) {
    218227        CFRelease(modelist);  /* NULL is ok */
    219228    }
     229    #endif
    220230}
    221231
    222232static const char *
     
    235245
    236246void
    237247Cocoa_InitModes(_THIS)
     248#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    238249{ @autoreleasepool
    239250{
     251#else
     252{
     253    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     254#endif
    240255    CGDisplayErr result;
    241256    CGDirectDisplayID *displays;
    242257    CGDisplayCount numDisplays;
     
    245260    result = CGGetOnlineDisplayList(0, NULL, &numDisplays);
    246261    if (result != kCGErrorSuccess) {
    247262        CG_SetError("CGGetOnlineDisplayList()", result);
     263#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     264        [pool release];
     265#endif
    248266        return;
    249267    }
    250268    displays = SDL_stack_alloc(CGDirectDisplayID, numDisplays);
     
    252270    if (result != kCGErrorSuccess) {
    253271        CG_SetError("CGGetOnlineDisplayList()", result);
    254272        SDL_stack_free(displays);
     273#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     274        [pool release];
     275#endif
    255276        return;
    256277    }
    257278
     
    278299                continue;
    279300            }
    280301
     302            #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    281303            if (IS_SNOW_LEOPARD_OR_LATER()) {
    282304                moderef = CGDisplayCopyDisplayMode(displays[i]);
    283305            }
     306            #endif
    284307
    285308            #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
    286309            if (!IS_SNOW_LEOPARD_OR_LATER()) {
     
    322345        }
    323346    }
    324347    SDL_stack_free(displays);
     348#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     349    [pool release];
     350}
     351#else
    325352}}
     353#endif
    326354
    327355int
    328356Cocoa_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect)
     
    344372    SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
    345373    CFArrayRef modes = NULL;
    346374
     375    #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    347376    if (IS_SNOW_LEOPARD_OR_LATER()) {
    348377        modes = CGDisplayCopyAllDisplayModes(data->display, NULL);
    349378    }
     379    #endif
    350380
    351381    #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
    352382    if (!IS_SNOW_LEOPARD_OR_LATER()) {
     
    365395            const void *moderef = CFArrayGetValueAtIndex(modes, i);
    366396            SDL_DisplayMode mode;
    367397            if (GetDisplayMode(_this, moderef, link, &mode)) {
     398                #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    368399                if (IS_SNOW_LEOPARD_OR_LATER()) {
    369400                    CGDisplayModeRetain((CGDisplayModeRef) moderef);
    370401                }
     402                #endif
    371403                SDL_AddDisplayMode(display, &mode);
    372404            }
    373405        }
     
    380412static CGError
    381413Cocoa_SwitchMode(_THIS, CGDirectDisplayID display, const void *mode)
    382414{
     415    #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    383416    if (IS_SNOW_LEOPARD_OR_LATER()) {
    384417        return CGDisplaySetDisplayMode(display, (CGDisplayModeRef) mode, NULL);
    385418    }
     419    #endif
    386420 
    387421    #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
    388422    if (!IS_SNOW_LEOPARD_OR_LATER()) {
  • src/video/cocoa/SDL_cocoamouse.m

    diff -ru SDL2-2.0.4-orig/src/video/cocoa/SDL_cocoamouse.m SDL2-2.0.4/src/video/cocoa/SDL_cocoamouse.m
    old new  
    6666
    6767static SDL_Cursor *
    6868Cocoa_CreateDefaultCursor()
     69#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    6970{ @autoreleasepool
    7071{
     72#else
     73{
     74    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     75#endif
    7176    NSCursor *nscursor;
    7277    SDL_Cursor *cursor = NULL;
    7378
     
    8186        }
    8287    }
    8388
     89#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     90    [pool release];
     91#endif
    8492    return cursor;
     93#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    8594}}
     95#else
     96}
     97#endif
    8698
    8799static SDL_Cursor *
    88100Cocoa_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
     101#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    89102{ @autoreleasepool
    90103{
     104#else
     105{
     106    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     107#endif
    91108    NSImage *nsimage;
    92109    NSCursor *nscursor = NULL;
    93110    SDL_Cursor *cursor = NULL;
     
    106123        }
    107124    }
    108125
     126#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     127    [pool release];
     128#endif
    109129    return cursor;
     130#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    110131}}
     132#else
     133}
     134#endif
    111135
    112136static SDL_Cursor *
    113137Cocoa_CreateSystemCursor(SDL_SystemCursor id)
     138#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    114139{ @autoreleasepool
    115140{
     141#else
     142{
     143    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     144#endif
    116145    NSCursor *nscursor = NULL;
    117146    SDL_Cursor *cursor = NULL;
    118147
     
    165194        }
    166195    }
    167196
     197#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     198    [pool release];
     199#endif
    168200    return cursor;
     201#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    169202}}
     203#else
     204}
     205#endif
    170206
    171207static void
    172208Cocoa_FreeCursor(SDL_Cursor * cursor)
     209#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    173210{ @autoreleasepool
    174211{
     212#else
     213{
     214    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     215#endif
    175216    NSCursor *nscursor = (NSCursor *)cursor->driverdata;
    176217
    177218    [nscursor release];
    178219    SDL_free(cursor);
     220#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    179221}}
     222#else
     223    [pool release];
     224}
     225#endif
    180226
    181227static int
    182228Cocoa_ShowCursor(SDL_Cursor * cursor)
     229#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    183230{ @autoreleasepool
    184231{
     232#else
     233{
     234    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     235#endif
    185236    SDL_VideoDevice *device = SDL_GetVideoDevice();
    186237    SDL_Window *window = (device ? device->windows : NULL);
    187238    for (; window != NULL; window = window->next) {
     
    192243                                                waitUntilDone:NO];
    193244        }
    194245    }
     246#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     247    [pool release];
     248#endif
    195249    return 0;
     250#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    196251}}
     252#else
     253}
     254#endif
    197255
    198256static SDL_Window *
    199257SDL_FindWindowAtPoint(const int x, const int y)
  • src/video/cocoa/SDL_cocoaopengl.m

    diff -ru SDL2-2.0.4-orig/src/video/cocoa/SDL_cocoaopengl.m SDL2-2.0.4/src/video/cocoa/SDL_cocoaopengl.m
    old new  
    150150
    151151SDL_GLContext
    152152Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
     153#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    153154{ @autoreleasepool
    154155{
     156#else
     157{
     158    NSAutoreleasePool *pool;
     159#endif
    155160    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    156161    SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
     162#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1670
    157163    SDL_bool lion_or_later = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6;
     164#else
     165    SDL_bool lion_or_later = SDL_FALSE;
     166#endif
    158167    NSOpenGLPixelFormatAttribute attr[32];
    159168    NSOpenGLPixelFormat *fmt;
    160169    SDLOpenGLContext *context;
     
    173182        return NULL;
    174183    }
    175184
     185#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     186    pool = [[NSAutoreleasePool alloc] init];
     187#endif
    176188    /* specify a profile if we're on Lion (10.7) or later. */
     189#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    177190    if (lion_or_later) {
    178191        NSOpenGLPixelFormatAttribute profile = NSOpenGLProfileVersionLegacy;
    179192        if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) {
     
    182195        attr[i++] = NSOpenGLPFAOpenGLProfile;
    183196        attr[i++] = profile;
    184197    }
     198#endif
    185199
    186200    attr[i++] = NSOpenGLPFAColorSize;
    187201    attr[i++] = SDL_BYTESPERPIXEL(display->current_mode.format)*8;
     
    237251    fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
    238252    if (fmt == nil) {
    239253        SDL_SetError("Failed creating OpenGL pixel format");
     254#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     255        [pool release];
     256#endif
    240257        return NULL;
    241258    }
    242259
     
    250267
    251268    if (context == nil) {
    252269        SDL_SetError("Failed creating OpenGL context");
     270#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     271        [pool release];
     272#endif
    253273        return NULL;
    254274    }
    255275
    256276    if ( Cocoa_GL_MakeCurrent(_this, window, context) < 0 ) {
    257277        Cocoa_GL_DeleteContext(_this, context);
    258278        SDL_SetError("Failed making OpenGL context current");
     279#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     280        [pool release];
     281#endif
    259282        return NULL;
    260283    }
    261284
     
    270293        if (!glGetStringFunc) {
    271294            Cocoa_GL_DeleteContext(_this, context);
    272295            SDL_SetError ("Failed getting OpenGL glGetString entry point");
     296#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     297            [pool release];
     298#endif
    273299            return NULL;
    274300        }
    275301
     
    277303        if (glversion == NULL) {
    278304            Cocoa_GL_DeleteContext(_this, context);
    279305            SDL_SetError ("Failed getting OpenGL context version");
     306#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     307            [pool release];
     308#endif
    280309            return NULL;
    281310        }
    282311
    283312        if (SDL_sscanf(glversion, "%d.%d", &glversion_major, &glversion_minor) != 2) {
    284313            Cocoa_GL_DeleteContext(_this, context);
    285314            SDL_SetError ("Failed parsing OpenGL context version");
     315#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     316            [pool release];
     317#endif
    286318            return NULL;
    287319        }
    288320
     
    290322           ((glversion_major == _this->gl_config.major_version) && (glversion_minor < _this->gl_config.minor_version))) {
    291323            Cocoa_GL_DeleteContext(_this, context);
    292324            SDL_SetError ("Failed creating OpenGL context at version requested");
     325#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     326            [pool release];
     327#endif
    293328            return NULL;
    294329        }
    295330
     
    299334        /*_this->gl_config.major_version = glversion_major;*/
    300335        /*_this->gl_config.minor_version = glversion_minor;*/
    301336    }
     337#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     338    [pool release];
     339#endif
    302340    return context;
     341#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     342}
     343#else
    303344}}
     345#endif
    304346
    305347int
    306348Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
     349#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    307350{ @autoreleasepool
    308351{
     352#else
     353{
     354    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     355#endif
    309356    if (context) {
    310357        SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context;
    311358        [nscontext setWindow:window];
     
    315362        [NSOpenGLContext clearCurrentContext];
    316363    }
    317364
     365#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     366    [pool release];
     367#endif
    318368    return 0;
     369#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    319370}}
     371#else
     372}
     373#endif
    320374
    321375void
    322376Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
     
    327381
    328382    /* This gives us the correct viewport for a Retina-enabled view, only
    329383     * supported on 10.7+. */
     384#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    330385    if ([contentView respondsToSelector:@selector(convertRectToBacking:)]) {
    331386        viewport = [contentView convertRectToBacking:viewport];
    332387    }
     388#endif
    333389
    334390    if (w) {
    335391        *w = viewport.size.width;
     
    342398
    343399int
    344400Cocoa_GL_SetSwapInterval(_THIS, int interval)
     401#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    345402{ @autoreleasepool
     403#endif
    346404{
    347405    NSOpenGLContext *nscontext;
    348406    GLint value;
     
    351409    if (interval < 0) {  /* no extension for this on Mac OS X at the moment. */
    352410        return SDL_SetError("Late swap tearing currently unsupported");
    353411    }
     412#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     413    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     414#endif
    354415
    355416    nscontext = (NSOpenGLContext*)SDL_GL_GetCurrentContext();
    356417    if (nscontext != nil) {
     
    361422        status = SDL_SetError("No current OpenGL context");
    362423    }
    363424
     425#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     426    [pool release];
     427#endif
    364428    return status;
     429#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    365430}}
     431#else
     432}
     433#endif
    366434
    367435int
    368436Cocoa_GL_GetSwapInterval(_THIS)
     437#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    369438{ @autoreleasepool
    370439{
     440#else
     441{
     442    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     443#endif
    371444    NSOpenGLContext *nscontext;
    372445    GLint value;
    373446    int status = 0;
     
    378451        status = (int)value;
    379452    }
    380453
     454#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     455    [pool release];
     456#endif
    381457    return status;
     458#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    382459}}
     460#else
     461}
     462#endif
    383463
    384464void
    385465Cocoa_GL_SwapWindow(_THIS, SDL_Window * window)
     466#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    386467{ @autoreleasepool
    387468{
     469#else
     470{
     471    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     472#endif
    388473    SDLOpenGLContext* nscontext = (SDLOpenGLContext*)SDL_GL_GetCurrentContext();
    389474    [nscontext flushBuffer];
    390475    [nscontext updateIfNeeded];
     476#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    391477}}
     478#else
     479    [pool release];
     480}
     481#endif
    392482
    393483void
    394484Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context)
     485#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    395486{ @autoreleasepool
    396487{
     488#else
     489{
     490    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     491#endif
    397492    SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context;
    398493
    399494    [nscontext setWindow:NULL];
    400495    [nscontext release];
     496#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    401497}}
     498#else
     499    [pool release];
     500}
     501#endif
    402502
    403503#endif /* SDL_VIDEO_OPENGL_CGL */
    404504
  • src/video/cocoa/SDL_cocoashape.m

    diff -ru SDL2-2.0.4-orig/src/video/cocoa/SDL_cocoashape.m SDL2-2.0.4/src/video/cocoa/SDL_cocoashape.m
    old new  
    7575
    7676int
    7777Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode)
     78#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    7879{ @autoreleasepool
    7980{
     81#else
     82{
     83    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     84#endif
    8085    SDL_ShapeData* data = (SDL_ShapeData*)shaper->driverdata;
    8186    SDL_WindowData* windata = (SDL_WindowData*)shaper->window->driverdata;
    8287    SDL_CocoaClosure closure;
     
    99104    SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure);
    100105    [closure.path addClip];
    101106
     107#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     108    [pool release];
     109#endif
    102110    return 0;
     111#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    103112}}
     113#else
     114}
     115#endif
    104116
    105117int
    106118Cocoa_ResizeWindowShape(SDL_Window *window)
  • src/video/cocoa/SDL_cocoavideo.m

    diff -ru SDL2-2.0.4-orig/src/video/cocoa/SDL_cocoavideo.m SDL2-2.0.4/src/video/cocoa/SDL_cocoavideo.m
    old new  
    2222
    2323#if SDL_VIDEO_DRIVER_COCOA
    2424
     25#if defined(__APPLE__) && defined(__POWERPC__) && !defined(__APPLE_ALTIVEC__)
     26#include <altivec.h>
     27#undef bool
     28#undef vector
     29#undef pixel
     30#endif
     31
    2532#include "SDL.h"
    2633#include "SDL_endian.h"
    2734#include "SDL_cocoavideo.h"
     
    147154    Cocoa_InitMouse(_this);
    148155
    149156    const char *hint = SDL_GetHint(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES);
     157#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    150158    data->allow_spaces = ( (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) && (!hint || (*hint != '0')) );
    151159
    152160    /* The IOPM assertion API can disable the screensaver as of 10.7. */
    153161    data->screensaver_use_iopm = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6;
     162#else
     163    data->allow_spaces = 0;
     164    data->screensaver_use_iopm = 0;
     165#endif
    154166
    155167    return 0;
    156168}
  • src/video/cocoa/SDL_cocoawindow.h

    diff -ru SDL2-2.0.4-orig/src/video/cocoa/SDL_cocoawindow.h SDL2-2.0.4/src/video/cocoa/SDL_cocoawindow.h
    old new  
    3535    PENDING_OPERATION_MINIMIZE
    3636} PendingWindowOperation;
    3737
     38#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    3839@interface Cocoa_WindowListener : NSResponder <NSWindowDelegate> {
     40#else
     41@interface Cocoa_WindowListener : NSResponder {
     42#endif
    3943    SDL_WindowData *_data;
    4044    BOOL observingVisible;
    4145    BOOL wasCtrlLeft;
     
    7579-(void) windowDidEnterFullScreen:(NSNotification *) aNotification;
    7680-(void) windowWillExitFullScreen:(NSNotification *) aNotification;
    7781-(void) windowDidExitFullScreen:(NSNotification *) aNotification;
     82#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    7883-(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions;
     84#endif
    7985
    8086/* See if event is in a drag area, toggle on window dragging. */
    8187-(BOOL) processHitTest:(NSEvent *)theEvent;
     
    98104-(void) touchesCancelledWithEvent:(NSEvent *) theEvent;
    99105
    100106/* Touch event handling */
     107#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    101108-(void) handleTouches:(NSTouchPhase) phase withEvent:(NSEvent*) theEvent;
     109#else
     110typedef enum {
     111    COCOA_TOUCH_DOWN,
     112    COCOA_TOUCH_UP,
     113    COCOA_TOUCH_MOVE,
     114    COCOA_TOUCH_CANCELLED
     115} cocoaTouchType;
     116-(void) handleTouches:(cocoaTouchType)type withEvent:(NSEvent*) event;
     117#endif
    102118
    103119@end
    104120/* *INDENT-ON* */
  • src/video/cocoa/SDL_cocoawindow.m

    diff -ru SDL2-2.0.4-orig/src/video/cocoa/SDL_cocoawindow.m SDL2-2.0.4/src/video/cocoa/SDL_cocoawindow.m
    old new  
    2323#if SDL_VIDEO_DRIVER_COCOA
    2424
    2525#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
     26#if 0
    2627# error SDL for Mac OS X must be built with a 10.7 SDK or above.
     28#endif
    2729#endif /* MAC_OS_X_VERSION_MAX_ALLOWED < 1070 */
    2830
    2931#include "SDL_syswm.h"
     
    5355#define FULLSCREEN_MASK (SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN)
    5456
    5557
     58#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     59@interface SDLWindow : NSWindow
     60#else
    5661@interface SDLWindow : NSWindow <NSDraggingDestination>
     62#endif
    5763/* These are needed for borderless/fullscreen windows */
    5864- (BOOL)canBecomeKeyWindow;
    5965- (BOOL)canBecomeMainWindow;
     
    114120}
    115121
    116122- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
     123#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    117124{ @autoreleasepool
    118125{
     126#else
     127{
     128    NSAutoreleasePool *pool;
     129#endif
    119130    NSPasteboard *pasteboard = [sender draggingPasteboard];
    120131    NSArray *types = [NSArray arrayWithObject:NSFilenamesPboardType];
    121132    NSString *desiredType = [pasteboard availableTypeFromArray:types];
     
    128139        return NO;
    129140    }
    130141
     142#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     143    pool = [[NSAutoreleasePool alloc] init];
     144#endif
    131145    SDL_assert([desiredType isEqualToString:NSFilenamesPboardType]);
    132146    NSArray *array = [pasteboard propertyListForType:@"NSFilenamesPboardType"];
    133147
    134148    for (NSString *path in array) {
    135149        NSURL *fileURL = [[NSURL fileURLWithPath:path] autorelease];
     150#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    136151        NSNumber *isAlias = nil;
    137152
    138153        /* Functionality for resolving URL aliases was added with OS X 10.6. */
     
    156171                }
    157172            }
    158173        }
     174#endif
    159175
    160176        if (!SDL_SendDropFile([[fileURL path] UTF8String])) {
     177#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     178            [pool release];
     179#endif
    161180            return NO;
    162181        }
    163182    }
    164183
     184#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     185    [pool release];
     186#endif
    165187    return YES;
     188#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     189}
     190#else
    166191}}
     192#endif
    167193
    168194- (BOOL)wantsPeriodicDraggingUpdates
    169195{
     
    277303        [center addObserver:self selector:@selector(windowDidDeminiaturize:) name:NSWindowDidDeminiaturizeNotification object:window];
    278304        [center addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:window];
    279305        [center addObserver:self selector:@selector(windowDidResignKey:) name:NSWindowDidResignKeyNotification object:window];
     306#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    280307        [center addObserver:self selector:@selector(windowDidChangeBackingProperties:) name:NSWindowDidChangeBackingPropertiesNotification object:window];
    281308        [center addObserver:self selector:@selector(windowWillEnterFullScreen:) name:NSWindowWillEnterFullScreenNotification object:window];
    282309        [center addObserver:self selector:@selector(windowDidEnterFullScreen:) name:NSWindowDidEnterFullScreenNotification object:window];
    283310        [center addObserver:self selector:@selector(windowWillExitFullScreen:) name:NSWindowWillExitFullScreenNotification object:window];
    284311        [center addObserver:self selector:@selector(windowDidExitFullScreen:) name:NSWindowDidExitFullScreenNotification object:window];
     312#endif
    285313        [center addObserver:self selector:@selector(windowDidFailToEnterFullScreen:) name:@"NSWindowDidFailToEnterFullScreenNotification" object:window];
    286314        [center addObserver:self selector:@selector(windowDidFailToExitFullScreen:) name:@"NSWindowDidFailToExitFullScreenNotification" object:window];
    287315    } else {
     
    302330
    303331    [view setNextResponder:self];
    304332
     333#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    305334    if ([view respondsToSelector:@selector(setAcceptsTouchEvents:)]) {
    306335        [view setAcceptsTouchEvents:YES];
    307336    }
     337#endif
    308338}
    309339
    310340- (void)observeValueForKeyPath:(NSString *)keyPath
     
    374404    inFullscreenTransition = YES;
    375405
    376406    /* you need to be FullScreenPrimary, or toggleFullScreen doesn't work. Unset it again in windowDidExitFullScreen. */
     407#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    377408    [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
     409#endif
    378410    [nswindow performSelectorOnMainThread: @selector(toggleFullScreen:) withObject:nswindow waitUntilDone:NO];
    379411    return YES;
    380412}
     
    410442        [center removeObserver:self name:NSWindowDidDeminiaturizeNotification object:window];
    411443        [center removeObserver:self name:NSWindowDidBecomeKeyNotification object:window];
    412444        [center removeObserver:self name:NSWindowDidResignKeyNotification object:window];
     445#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    413446        [center removeObserver:self name:NSWindowDidChangeBackingPropertiesNotification object:window];
    414447        [center removeObserver:self name:NSWindowWillEnterFullScreenNotification object:window];
    415448        [center removeObserver:self name:NSWindowDidEnterFullScreenNotification object:window];
    416449        [center removeObserver:self name:NSWindowWillExitFullScreenNotification object:window];
    417450        [center removeObserver:self name:NSWindowDidExitFullScreenNotification object:window];
     451#endif
    418452        [center removeObserver:self name:@"NSWindowDidFailToEnterFullScreenNotification" object:window];
    419453        [center removeObserver:self name:@"NSWindowDidFailToExitFullScreenNotification" object:window];
    420454    } else {
     
    589623        [NSMenu setMenuBarVisible:NO];
    590624    }
    591625
     626#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    592627    /* On pre-10.6, you might have the capslock key state wrong now because we can't check here. */
    593628    if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_6) {
    594629        const unsigned int newflags = [NSEvent modifierFlags] & NSAlphaShiftKeyMask;
    595630        _data->videodata->modifierFlags = (_data->videodata->modifierFlags & ~NSAlphaShiftKeyMask) | newflags;
    596631        SDL_ToggleModState(KMOD_CAPS, newflags != 0);
    597632    }
     633#endif
    598634}
    599635
    600636- (void)windowDidResignKey:(NSNotification *)aNotification
     
    621657
    622658- (void)windowDidChangeBackingProperties:(NSNotification *)aNotification
    623659{
     660#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    624661    NSNumber *oldscale = [[aNotification userInfo] objectForKey:NSBackingPropertyOldScaleFactorKey];
    625662
    626663    if (inFullscreenTransition) {
     
    633670        _data->window->h = 0;
    634671        [self windowDidResize:aNotification];
    635672    }
     673#endif
    636674}
    637675
    638676- (void)windowWillEnterFullScreen:(NSNotification *)aNotification
     
    733771        [nswindow miniaturize:nil];
    734772    } else {
    735773        /* Adjust the fullscreen toggle button and readd menu now that we're here. */
     774#if MAC_OS_X_VERSION_MIN_REQUIRED > 1070
    736775        if (window->flags & SDL_WINDOW_RESIZABLE) {
    737776            /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
    738777            [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
    739778        } else {
    740779            [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged];
    741780        }
     781#endif
    742782        [NSMenu setMenuBarVisible:YES];
    743783
    744784        pendingWindowOperation = PENDING_OPERATION_NONE;
     
    756796    }
    757797}
    758798
     799#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    759800-(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions
    760801{
    761802    if ((_data->window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
     
    764805        return proposedOptions;
    765806    }
    766807}
     808#endif
    767809
    768810
    769811/* We'll respond to key events by doing nothing so we don't beep.
     
    9931035
    9941036- (void)touchesBeganWithEvent:(NSEvent *) theEvent
    9951037{
     1038#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    9961039    NSSet *touches = [theEvent touchesMatchingPhase:NSTouchPhaseAny inView:nil];
    9971040    int existingTouchCount = 0;
    9981041
     
    10131056
    10141057    DLog("Began Fingers: %lu .. existing: %d", (unsigned long)[touches count], existingTouchCount);
    10151058    [self handleTouches:NSTouchPhaseBegan withEvent:theEvent];
     1059#endif
    10161060}
    10171061
    10181062- (void)touchesMovedWithEvent:(NSEvent *) theEvent
    10191063{
     1064#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    10201065    [self handleTouches:NSTouchPhaseMoved withEvent:theEvent];
     1066#endif
    10211067}
    10221068
    10231069- (void)touchesEndedWithEvent:(NSEvent *) theEvent
    10241070{
     1071#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    10251072    [self handleTouches:NSTouchPhaseEnded withEvent:theEvent];
     1073#endif
    10261074}
    10271075
    10281076- (void)touchesCancelledWithEvent:(NSEvent *) theEvent
    10291077{
     1078#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    10301079    [self handleTouches:NSTouchPhaseCancelled withEvent:theEvent];
     1080#endif
    10311081}
    10321082
     1083#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
     1084#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
    10331085- (void)handleTouches:(NSTouchPhase) phase withEvent:(NSEvent *) theEvent
     1086#else
     1087- (void)handleTouches:(cocoaTouchType)type withEvent:(NSEvent *)event
     1088#endif
    10341089{
     1090#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1091    NSSet *touches = 0;
     1092    NSEnumerator *enumerator;
     1093    NSTouch *touch;
     1094
     1095    switch (type) {
     1096        case COCOA_TOUCH_DOWN:
     1097            touches = [event touchesMatchingPhase:NSTouchPhaseBegan inView:nil];
     1098            break;
     1099        case COCOA_TOUCH_UP:
     1100            touches = [event touchesMatchingPhase:NSTouchPhaseEnded inView:nil];
     1101            break;
     1102        case COCOA_TOUCH_CANCELLED:
     1103            touches = [event touchesMatchingPhase:NSTouchPhaseCancelled inView:nil];
     1104            break;
     1105        case COCOA_TOUCH_MOVE:
     1106            touches = [event touchesMatchingPhase:NSTouchPhaseMoved inView:nil];
     1107            break;
     1108    }
     1109
     1110    enumerator = [touches objectEnumerator];
     1111    touch = (NSTouch*)[enumerator nextObject];
     1112    while (touch) {
     1113        const SDL_TouchID touchId = (SDL_TouchID)(intptr_t)[touch device];
     1114        if (!SDL_GetTouch(touchId)) {
     1115            if (SDL_AddTouch(touchId, "") < 0) {
     1116                return;
     1117            }
     1118        }
     1119
     1120        const SDL_FingerID fingerId = (SDL_FingerID)(intptr_t)[touch identity];
     1121        float x = [touch normalizedPosition].x;
     1122        float y = [touch normalizedPosition].y;
     1123        /* Make the origin the upper left instead of the lower left */
     1124        y = 1.0f - y;
     1125
     1126        switch (type) {
     1127        case COCOA_TOUCH_DOWN:
     1128            SDL_SendTouch(touchId, fingerId, SDL_TRUE, x, y, 1.0f);
     1129            break;
     1130        case COCOA_TOUCH_UP:
     1131        case COCOA_TOUCH_CANCELLED:
     1132            SDL_SendTouch(touchId, fingerId, SDL_FALSE, x, y, 1.0f);
     1133            break;
     1134        case COCOA_TOUCH_MOVE:
     1135            SDL_SendTouchMotion(touchId, fingerId, x, y, 1.0f);
     1136            break;
     1137        }
     1138
     1139        touch = (NSTouch*)[enumerator nextObject];
     1140     }
     1141#else
    10351142    NSSet *touches = [theEvent touchesMatchingPhase:phase inView:nil];
    10361143
    10371144    for (NSTouch *touch in touches) {
     
    10611168            break;
    10621169        }
    10631170    }
     1171#endif
    10641172}
     1173#endif
    10651174
    10661175@end
    10671176
     
    11181227
    11191228static int
    11201229SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created)
     1230#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    11211231{ @autoreleasepool
    11221232{
     1233#else
     1234{
     1235    NSAutoreleasePool *pool;
     1236#endif
    11231237    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
    11241238    SDL_WindowData *data;
    11251239
     
    11341248    data->videodata = videodata;
    11351249    data->nscontexts = [[NSMutableArray alloc] init];
    11361250
     1251#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1252    pool = [[NSAutoreleasePool alloc] init];
     1253#endif
    11371254    /* Create an event listener for the window */
    11381255    data->listener = [[Cocoa_WindowListener alloc] init];
    11391256
     
    11941311     */
    11951312    [nswindow setOneShot:NO];
    11961313
     1314#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1315    [pool release];
     1316#endif
    11971317    /* All done! */
    11981318    window->driverdata = data;
    11991319    return 0;
     1320#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1321}
     1322#else
    12001323}}
     1324#endif
    12011325
    12021326int
    12031327Cocoa_CreateWindow(_THIS, SDL_Window * window)
     1328#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    12041329{ @autoreleasepool
    12051330{
     1331#else
     1332{
     1333    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1334#endif
    12061335    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
    12071336    NSWindow *nswindow;
    12081337    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
     
    12431372    [nswindow setBackgroundColor:[NSColor blackColor]];
    12441373
    12451374    if (videodata->allow_spaces) {
     1375#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    12461376        SDL_assert(floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6);
    12471377        SDL_assert([nswindow respondsToSelector:@selector(toggleFullScreen:)]);
    12481378        /* we put FULLSCREEN_DESKTOP windows in their own Space, without a toggle button or menubar, later */
     
    12501380            /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
    12511381            [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
    12521382        }
     1383#endif
    12531384    }
    12541385
    12551386    /* Create a default view for this window */
     
    12681399
    12691400    /* Allow files and folders to be dragged onto the window by users */
    12701401    [nswindow registerForDraggedTypes:[NSArray arrayWithObject:(NSString *)kUTTypeFileURL]];
     1402#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1403    [pool release];
     1404#endif
    12711405
    12721406    if (SetupWindowData(_this, window, nswindow, SDL_TRUE) < 0) {
    12731407        [nswindow release];
    12741408        return -1;
    12751409    }
    12761410    return 0;
     1411#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    12771412}}
     1413#else
     1414}
     1415#endif
    12781416
    12791417int
    12801418Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
     1419#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    12811420{ @autoreleasepool
    12821421{
     1422#else
     1423{
     1424    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1425#endif
    12831426    NSWindow *nswindow = (NSWindow *) data;
    12841427    NSString *title;
    12851428
     
    12901433    }
    12911434
    12921435    return SetupWindowData(_this, window, nswindow, SDL_FALSE);
     1436#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    12931437}}
     1438#else
     1439    [pool release];
     1440}
     1441#endif
    12941442
    12951443void
    12961444Cocoa_SetWindowTitle(_THIS, SDL_Window * window)
     1445#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    12971446{ @autoreleasepool
    12981447{
     1448#else
     1449{
     1450    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1451#endif
    12991452    const char *title = window->title ? window->title : "";
    13001453    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
    13011454    NSString *string = [[NSString alloc] initWithUTF8String:title];
    13021455    [nswindow setTitle:string];
    13031456    [string release];
     1457#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13041458}}
     1459#else
     1460    [pool release];
     1461}
     1462#endif
    13051463
    13061464void
    13071465Cocoa_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
     1466#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13081467{ @autoreleasepool
    13091468{
     1469#else
     1470{
     1471    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1472#endif
    13101473    NSImage *nsimage = Cocoa_CreateImage(icon);
    13111474
    13121475    if (nsimage) {
    13131476        [NSApp setApplicationIconImage:nsimage];
    13141477    }
     1478#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13151479}}
     1480#else
     1481    [pool release];
     1482}
     1483#endif
    13161484
    13171485void
    13181486Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
     1487#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13191488{ @autoreleasepool
    13201489{
     1490#else
     1491{
     1492    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1493#endif
    13211494    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    13221495    NSWindow *nswindow = windata->nswindow;
    13231496    NSRect rect;
     
    13351508    s_moveHack = moveHack;
    13361509
    13371510    ScheduleContextUpdates(windata);
     1511#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13381512}}
     1513#else
     1514    [pool release];
     1515}
     1516#endif
    13391517
    13401518void
    13411519Cocoa_SetWindowSize(_THIS, SDL_Window * window)
     1520#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13421521{ @autoreleasepool
    13431522{
     1523#else
     1524{
     1525    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1526#endif
    13441527    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    13451528    NSWindow *nswindow = windata->nswindow;
    13461529    NSRect rect;
     
    13621545    s_moveHack = moveHack;
    13631546
    13641547    ScheduleContextUpdates(windata);
     1548#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13651549}}
     1550#else
     1551    [pool release];
     1552}
     1553#endif
    13661554
    13671555void
    13681556Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window)
     1557#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13691558{ @autoreleasepool
    13701559{
     1560#else
     1561{
     1562    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1563#endif
    13711564    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    13721565
    13731566    NSSize minSize;
     
    13751568    minSize.height = window->min_h;
    13761569
    13771570    [windata->nswindow setContentMinSize:minSize];
     1571#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13781572}}
     1573#else
     1574    [pool release];
     1575}
     1576#endif
    13791577
    13801578void
    13811579Cocoa_SetWindowMaximumSize(_THIS, SDL_Window * window)
     1580#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13821581{ @autoreleasepool
    13831582{
     1583#else
     1584{
     1585    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1586#endif
    13841587    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    13851588
    13861589    NSSize maxSize;
     
    13881591    maxSize.height = window->max_h;
    13891592
    13901593    [windata->nswindow setContentMaxSize:maxSize];
     1594#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13911595}}
     1596#else
     1597    [pool release];
     1598}
     1599#endif
    13921600
    13931601void
    13941602Cocoa_ShowWindow(_THIS, SDL_Window * window)
     1603#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13951604{ @autoreleasepool
    13961605{
     1606#else
     1607{
     1608    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1609#endif
    13971610    SDL_WindowData *windowData = ((SDL_WindowData *) window->driverdata);
    13981611    NSWindow *nswindow = windowData->nswindow;
    13991612
     
    14021615        [nswindow makeKeyAndOrderFront:nil];
    14031616        [windowData->listener resumeVisibleObservation];
    14041617    }
     1618#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14051619}}
     1620#else
     1621    [pool release];
     1622}
     1623#endif
    14061624
    14071625void
    14081626Cocoa_HideWindow(_THIS, SDL_Window * window)
     1627#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14091628{ @autoreleasepool
    14101629{
     1630#else
     1631{
     1632    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1633#endif
    14111634    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
    14121635
    14131636    [nswindow orderOut:nil];
     1637#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14141638}}
     1639#else
     1640    [pool release];
     1641}
     1642#endif
    14151643
    14161644void
    14171645Cocoa_RaiseWindow(_THIS, SDL_Window * window)
     1646#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14181647{ @autoreleasepool
    14191648{
     1649#else
     1650{
     1651    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1652#endif
    14201653    SDL_WindowData *windowData = ((SDL_WindowData *) window->driverdata);
    14211654    NSWindow *nswindow = windowData->nswindow;
    14221655
     
    14291662        [nswindow makeKeyAndOrderFront:nil];
    14301663    }
    14311664    [windowData->listener resumeVisibleObservation];
     1665#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14321666}}
     1667#else
     1668    [pool release];
     1669}
     1670#endif
    14331671
    14341672void
    14351673Cocoa_MaximizeWindow(_THIS, SDL_Window * window)
     1674#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14361675{ @autoreleasepool
    14371676{
     1677#else
     1678{
     1679    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1680#endif
    14381681    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    14391682    NSWindow *nswindow = windata->nswindow;
    14401683
    14411684    [nswindow zoom:nil];
    14421685
    14431686    ScheduleContextUpdates(windata);
     1687#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14441688}}
     1689#else
     1690    [pool release];
     1691}
     1692#endif
    14451693
    14461694void
    14471695Cocoa_MinimizeWindow(_THIS, SDL_Window * window)
     1696#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14481697{ @autoreleasepool
    14491698{
     1699#else
     1700{
     1701    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1702#endif
    14501703    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    14511704    NSWindow *nswindow = data->nswindow;
    14521705
     
    14551708    } else {
    14561709        [nswindow miniaturize:nil];
    14571710    }
     1711#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14581712}}
     1713#else
     1714    [pool release];
     1715}
     1716#endif
    14591717
    14601718void
    14611719Cocoa_RestoreWindow(_THIS, SDL_Window * window)
     1720#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14621721{ @autoreleasepool
    14631722{
     1723#else
     1724{
     1725    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1726#endif
    14641727    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
    14651728
    14661729    if ([nswindow isMiniaturized]) {
     
    14681731    } else if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) {
    14691732        [nswindow zoom:nil];
    14701733    }
     1734#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14711735}}
     1736#else
     1737    [pool release];
     1738}
     1739#endif
    14721740
    14731741static NSWindow *
    14741742Cocoa_RebuildWindow(SDL_WindowData * data, NSWindow * nswindow, unsigned style)
     
    14931761
    14941762void
    14951763Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
     1764#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14961765{ @autoreleasepool
    14971766{
     1767#else
     1768{
     1769    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1770#endif
    14981771    if (SetWindowStyle(window, GetWindowStyle(window))) {
    14991772        if (bordered) {
    15001773            Cocoa_SetWindowTitle(_this, window);  /* this got blanked out. */
    15011774        }
    15021775    }
     1776#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15031777}}
     1778#else
     1779    [pool release];
     1780}
     1781#endif
    15041782
    15051783
    15061784void
    15071785Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
     1786#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15081787{ @autoreleasepool
    15091788{
     1789#else
     1790{
     1791    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1792#endif
    15101793    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    15111794    NSWindow *nswindow = data->nswindow;
    15121795    NSRect rect;
     
    15851868    }
    15861869
    15871870    ScheduleContextUpdates(data);
     1871#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15881872}}
     1873#else
     1874    [pool release];
     1875}
     1876#endif
    15891877
    15901878int
    15911879Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp)
     
    16701958
    16711959void
    16721960Cocoa_DestroyWindow(_THIS, SDL_Window * window)
     1961#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    16731962{ @autoreleasepool
    16741963{
     1964#else
     1965{
     1966    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1967#endif
    16751968    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    16761969
    16771970    if (data) {
     
    16941987        SDL_free(data);
    16951988    }
    16961989    window->driverdata = NULL;
     1990#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    16971991}}
     1992#else
     1993    [pool release];
     1994}
     1995#endif
    16981996
    16991997SDL_bool
    17001998Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
     
    17262024
    17272025SDL_bool
    17282026Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state)
     2027#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    17292028{ @autoreleasepool
    17302029{
     2030#else
     2031{
     2032    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     2033#endif
    17312034    SDL_bool succeeded = SDL_FALSE;
    17322035    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    17332036
     
    17582061        succeeded = SDL_TRUE;
    17592062    }
    17602063
     2064#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     2065    [pool release];
     2066#endif
    17612067    return succeeded;
     2068#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    17622069}}
     2070#else
     2071}
     2072#endif
    17632073
    17642074int
    17652075Cocoa_SetWindowHitTest(SDL_Window * window, SDL_bool enabled)