Ticket #52210: SDL2-2.0.5_OSX_105.patch

File SDL2-2.0.5_OSX_105.patch, 69.5 KB (added by miniupnp (Thomas BERNARD), 6 months ago)

patch to compile SDL2.0.5 on OS X 10.5 Leopard

  • include/SDL_config.h

    Only in SDL2-2.0.5: Makefile
    Only in SDL2-2.0.5: Makefile.rules
    Only in SDL2-2.0.5: build
    Only in SDL2-2.0.5: config.log
    Only in SDL2-2.0.5: config.status
    diff -ru SDL2-2.0.5-orig/include/SDL_config.h SDL2-2.0.5/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
     63
     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/* #undef HAVE_FCITX_FRONTEND_H */
    5087
    51 #ifdef USING_GENERATED_CONFIG_H
    52 #error Wrong SDL_config.h, check your include path?
     88/* C library functions */
     89#define HAVE_MALLOC 1
     90#define HAVE_CALLOC 1
     91#define HAVE_REALLOC 1
     92#define HAVE_FREE 1
     93#define HAVE_ALLOCA 1
     94#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */
     95#define HAVE_GETENV 1
     96#define HAVE_SETENV 1
     97#define HAVE_PUTENV 1
     98#define HAVE_UNSETENV 1
    5399#endif
     100#define HAVE_QSORT 1
     101#define HAVE_ABS 1
     102#define HAVE_BCOPY 1
     103#define HAVE_MEMSET 1
     104#define HAVE_MEMCPY 1
     105#define HAVE_MEMMOVE 1
     106#define HAVE_MEMCMP 1
     107#define HAVE_STRLEN 1
     108#define HAVE_STRLCPY 1
     109#define HAVE_STRLCAT 1
     110#define HAVE_STRDUP 1
     111/* #undef HAVE__STRREV */
     112/* #undef HAVE__STRUPR */
     113/* #undef HAVE__STRLWR */
     114/* #undef HAVE_INDEX */
     115/* #undef HAVE_RINDEX */
     116#define HAVE_STRCHR 1
     117#define HAVE_STRRCHR 1
     118#define HAVE_STRSTR 1
     119/* #undef HAVE_ITOA */
     120/* #undef HAVE__LTOA */
     121/* #undef HAVE__UITOA */
     122/* #undef HAVE__ULTOA */
     123#define HAVE_STRTOL 1
     124#define HAVE_STRTOUL 1
     125/* #undef HAVE__I64TOA */
     126/* #undef HAVE__UI64TOA */
     127#define HAVE_STRTOLL 1
     128#define HAVE_STRTOULL 1
     129#define HAVE_STRTOD 1
     130#define HAVE_ATOI 1
     131#define HAVE_ATOF 1
     132#define HAVE_STRCMP 1
     133#define HAVE_STRNCMP 1
     134/* #undef HAVE__STRICMP */
     135#define HAVE_STRCASECMP 1
     136/* #undef HAVE__STRNICMP */
     137#define HAVE_STRNCASECMP 1
     138/* #undef HAVE_SSCANF */
     139#define HAVE_VSSCANF 1
     140/* #undef HAVE_SNPRINTF */
     141#define HAVE_VSNPRINTF 1
     142#define HAVE_M_PI /**/
     143#define HAVE_ATAN 1
     144#define HAVE_ATAN2 1
     145#define HAVE_ACOS 1
     146#define HAVE_ASIN 1
     147#define HAVE_CEIL 1
     148#define HAVE_COPYSIGN 1
     149#define HAVE_COS 1
     150#define HAVE_COSF 1
     151#define HAVE_FABS 1
     152#define HAVE_FLOOR 1
     153#define HAVE_LOG 1
     154#define HAVE_POW 1
     155#define HAVE_SCALBN 1
     156#define HAVE_SIN 1
     157#define HAVE_SINF 1
     158#define HAVE_SQRT 1
     159#define HAVE_SQRTF 1
     160#define HAVE_TAN 1
     161#define HAVE_TANF 1
     162#define HAVE_FSEEKO 1
     163/* #undef HAVE_FSEEKO64 */
     164#define HAVE_SIGACTION 1
     165#define HAVE_SA_SIGACTION 1
     166#define HAVE_SETJMP 1
     167#define HAVE_NANOSLEEP 1
     168#define HAVE_SYSCONF 1
     169#define HAVE_SYSCTLBYNAME 1
     170/* #undef HAVE_CLOCK_GETTIME */
     171/* #undef HAVE_GETPAGESIZE */
     172#define HAVE_MPROTECT 1
     173#define HAVE_ICONV 1
     174/* #undef HAVE_PTHREAD_SETNAME_NP */
     175/* #undef HAVE_PTHREAD_SET_NAME_NP */
     176/* #undef HAVE_SEM_TIMEDWAIT */
     177
     178#else
     179#define HAVE_STDARG_H 1
     180#define HAVE_STDDEF_H 1
     181#define HAVE_STDINT_H 1
     182#endif /* HAVE_LIBC */
     183
     184/* SDL internal assertion support */
     185/* #undef SDL_DEFAULT_ASSERT_LEVEL */
     186
     187/* Allow disabling of core subsystems */
     188/* #undef SDL_ATOMIC_DISABLED */
     189/* #undef SDL_AUDIO_DISABLED */
     190/* #undef SDL_CPUINFO_DISABLED */
     191/* #undef SDL_EVENTS_DISABLED */
     192/* #undef SDL_FILE_DISABLED */
     193/* #undef SDL_JOYSTICK_DISABLED */
     194/* #undef SDL_HAPTIC_DISABLED */
     195/* #undef SDL_LOADSO_DISABLED */
     196/* #undef SDL_RENDER_DISABLED */
     197/* #undef SDL_THREADS_DISABLED */
     198/* #undef SDL_TIMERS_DISABLED */
     199/* #undef SDL_VIDEO_DISABLED */
     200/* #undef SDL_POWER_DISABLED */
     201/* #undef SDL_FILESYSTEM_DISABLED */
     202
     203/* Enable various audio drivers */
     204/* #undef SDL_AUDIO_DRIVER_ALSA */
     205/* #undef SDL_AUDIO_DRIVER_ALSA_DYNAMIC */
     206/* #undef SDL_AUDIO_DRIVER_ARTS */
     207/* #undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC */
     208/* #undef SDL_AUDIO_DRIVER_PULSEAUDIO */
     209/* #undef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC */
     210/* #undef SDL_AUDIO_DRIVER_HAIKU */
     211/* #undef SDL_AUDIO_DRIVER_BSD */
     212#define SDL_AUDIO_DRIVER_COREAUDIO 1
     213#define SDL_AUDIO_DRIVER_DISK 1
     214#define SDL_AUDIO_DRIVER_DUMMY 1
     215/* #undef SDL_AUDIO_DRIVER_ANDROID */
     216/* #undef SDL_AUDIO_DRIVER_XAUDIO2 */
     217/* #undef SDL_AUDIO_DRIVER_DSOUND */
     218/* #undef SDL_AUDIO_DRIVER_ESD */
     219/* #undef SDL_AUDIO_DRIVER_ESD_DYNAMIC */
     220/* #undef SDL_AUDIO_DRIVER_NACL */
     221/* #undef SDL_AUDIO_DRIVER_NAS */
     222/* #undef SDL_AUDIO_DRIVER_NAS_DYNAMIC */
     223/* #undef SDL_AUDIO_DRIVER_SNDIO */
     224/* #undef SDL_AUDIO_DRIVER_SNDIO_DYNAMIC */
     225/* #undef SDL_AUDIO_DRIVER_OSS */
     226/* #undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H */
     227/* #undef SDL_AUDIO_DRIVER_PAUDIO */
     228/* #undef SDL_AUDIO_DRIVER_QSA */
     229/* #undef SDL_AUDIO_DRIVER_SUNAUDIO */
     230/* #undef SDL_AUDIO_DRIVER_WINMM */
     231/* #undef SDL_AUDIO_DRIVER_FUSIONSOUND */
     232/* #undef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC */
     233/* #undef SDL_AUDIO_DRIVER_EMSCRIPTEN */
     234
     235/* Enable various input drivers */
     236/* #undef SDL_INPUT_LINUXEV */
     237/* #undef SDL_INPUT_LINUXKD */
     238/* #undef SDL_INPUT_TSLIB */
     239/* #undef SDL_JOYSTICK_HAIKU */
     240/* #undef SDL_JOYSTICK_DINPUT */
     241/* #undef SDL_JOYSTICK_XINPUT */
     242/* #undef SDL_JOYSTICK_DUMMY */
     243#define SDL_JOYSTICK_IOKIT 1
     244/* #undef SDL_JOYSTICK_LINUX */
     245/* #undef SDL_JOYSTICK_ANDROID */
     246/* #undef SDL_JOYSTICK_WINMM */
     247/* #undef SDL_JOYSTICK_USBHID */
     248/* #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H */
     249/* #undef SDL_JOYSTICK_EMSCRIPTEN */
     250/* #undef SDL_HAPTIC_DUMMY */
     251/* #undef SDL_HAPTIC_LINUX */
     252#define SDL_HAPTIC_IOKIT 1
     253/* #undef SDL_HAPTIC_DINPUT */
     254/* #undef SDL_HAPTIC_XINPUT */
     255
     256/* Enable various shared object loading systems */
     257/* #undef SDL_LOADSO_HAIKU */
     258#define SDL_LOADSO_DLOPEN 1
     259/* #undef SDL_LOADSO_DUMMY */
     260/* #undef SDL_LOADSO_LDG */
     261/* #undef SDL_LOADSO_WINDOWS */
     262
     263/* Enable various threading systems */
     264#define SDL_THREAD_PTHREAD 1
     265#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
     266/* #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP */
     267/* #undef SDL_THREAD_WINDOWS */
     268
     269/* Enable various timer systems */
     270/* #undef SDL_TIMER_HAIKU */
     271/* #undef SDL_TIMER_DUMMY */
     272#define SDL_TIMER_UNIX 1
     273/* #undef SDL_TIMER_WINDOWS */
     274
     275/* Enable various video drivers */
     276/* #undef SDL_VIDEO_DRIVER_HAIKU */
     277#define SDL_VIDEO_DRIVER_COCOA 1
     278/* #undef SDL_VIDEO_DRIVER_DIRECTFB */
     279/* #undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC */
     280#define SDL_VIDEO_DRIVER_DUMMY 1
     281/* #undef SDL_VIDEO_DRIVER_WINDOWS */
     282/* #undef SDL_VIDEO_DRIVER_WAYLAND */
     283/* #undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
     284/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC */
     285/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL */
     286/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR */
     287/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON */
     288/* #undef SDL_VIDEO_DRIVER_MIR */
     289/* #undef SDL_VIDEO_DRIVER_MIR_DYNAMIC */
     290/* #undef SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON */
     291#define SDL_VIDEO_DRIVER_X11 1
     292/* #undef SDL_VIDEO_DRIVER_RPI */
     293/* #undef SDL_VIDEO_DRIVER_ANDROID */
     294/* #undef SDL_VIDEO_DRIVER_EMSCRIPTEN */
     295#define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib"
     296#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib"
     297#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR "/usr/X11R6/lib/libXcursor.1.dylib"
     298#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/usr/X11R6/lib/libXinerama.1.dylib"
     299/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 */
     300/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR */
     301#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/usr/X11R6/lib/libXss.1.dylib"
     302#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "/usr/X11R6/lib/libXxf86vm.1.dylib"
     303#define SDL_VIDEO_DRIVER_X11_XCURSOR 1
     304#define SDL_VIDEO_DRIVER_X11_XDBE 1
     305#define SDL_VIDEO_DRIVER_X11_XINERAMA 1
     306/* #undef SDL_VIDEO_DRIVER_X11_XINPUT2 */
     307/* #undef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH */
     308/* #undef SDL_VIDEO_DRIVER_X11_XRANDR */
     309#define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1
     310#define SDL_VIDEO_DRIVER_X11_XSHAPE 1
     311#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1
     312/* #undef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS */
     313/* #undef SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY */
     314#define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1
     315/* #undef SDL_VIDEO_DRIVER_NACL */
     316/* #undef SDL_VIDEO_DRIVER_VIVANTE */
     317/* #undef SDL_VIDEO_DRIVER_VIVANTE_VDK */
     318
     319/* #undef SDL_VIDEO_RENDER_D3D */
     320/* #undef SDL_VIDEO_RENDER_D3D11 */
     321#define SDL_VIDEO_RENDER_OGL 1
     322/* #undef SDL_VIDEO_RENDER_OGL_ES */
     323/* #undef SDL_VIDEO_RENDER_OGL_ES2 */
     324/* #undef SDL_VIDEO_RENDER_DIRECTFB */
     325
     326/* Enable OpenGL support */
     327#define SDL_VIDEO_OPENGL 1
     328/* #undef SDL_VIDEO_OPENGL_ES */
     329/* #undef SDL_VIDEO_OPENGL_ES2 */
     330/* #undef SDL_VIDEO_OPENGL_BGL */
     331#define SDL_VIDEO_OPENGL_CGL 1
     332/* #undef SDL_VIDEO_OPENGL_EGL */
     333#define SDL_VIDEO_OPENGL_GLX 1
     334/* #undef SDL_VIDEO_OPENGL_WGL */
     335/* #undef SDL_VIDEO_OPENGL_OSMESA */
     336/* #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC */
     337
     338/* Enable system power support */
     339/* #undef SDL_POWER_LINUX */
     340/* #undef SDL_POWER_WINDOWS */
     341#define SDL_POWER_MACOSX 1
     342/* #undef SDL_POWER_HAIKU */
     343/* #undef SDL_POWER_ANDROID */
     344/* #undef SDL_POWER_EMSCRIPTEN */
     345/* #undef SDL_POWER_HARDWIRED */
     346
     347/* Enable system filesystem support */
     348/* #undef SDL_FILESYSTEM_HAIKU */
     349#define SDL_FILESYSTEM_COCOA 1
     350/* #undef SDL_FILESYSTEM_DUMMY */
     351/* #undef SDL_FILESYSTEM_UNIX */
     352/* #undef SDL_FILESYSTEM_WINDOWS */
     353/* #undef SDL_FILESYSTEM_NACL */
     354/* #undef SDL_FILESYSTEM_ANDROID */
     355/* #undef SDL_FILESYSTEM_EMSCRIPTEN */
     356
     357/* Enable assembly routines */
     358#define SDL_ASSEMBLY_ROUTINES 1
     359#define SDL_ALTIVEC_BLITTERS 1
     360
     361/* Enable ime support */
     362/* #undef SDL_USE_IME */
    54363
    55364#endif /* _SDL_config_h */
  • include/SDL_platform.h

    diff -ru SDL2-2.0.5-orig/include/SDL_platform.h SDL2-2.0.5/include/SDL_platform.h
    old new  
    8484#undef __MACOSX__
    8585#define __MACOSX__  1
    8686#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
     87#if 0
    8788# error SDL for Mac OS X only supports deploying on 10.6 and above.
     89#endif
    8890#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1060 */
    8991#endif /* TARGET_OS_IPHONE */
    9092#endif /* defined(__APPLE__) */
  • include/SDL_syswm.h

    diff -ru SDL2-2.0.5-orig/include/SDL_syswm.h SDL2-2.0.5/include/SDL_syswm.h
    old new  
    227227#if defined(SDL_VIDEO_DRIVER_COCOA)
    228228        struct
    229229        {
     230#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    230231#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
    231232            NSWindow __unsafe_unretained *window; /* The Cocoa window */
    232233#else
    233234            NSWindow *window;                     /* The Cocoa window */
    234235#endif
     236#else
     237            NSWindow *window;                     /* The Cocoa window */
     238#endif
    235239        } cocoa;
    236240#endif
    237241#if defined(SDL_VIDEO_DRIVER_UIKIT)
    238242        struct
    239243        {
     244#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    240245#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
    241246            UIWindow __unsafe_unretained *window; /* The UIKit window */
    242247#else
    243248            UIWindow *window;                     /* The UIKit window */
    244249#endif
     250#else
     251            UIWindow *window;                     /* The UIKit window */
     252#endif
    245253            GLuint framebuffer; /* The GL view's Framebuffer Object. It must be bound when rendering to the screen using GL. */
    246254            GLuint colorbuffer; /* The GL view's color Renderbuffer Object. It must be bound when SDL_GL_SwapWindow is called. */
    247255            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.5: libtool
    Only in SDL2-2.0.5: sdl2-config
    Only in SDL2-2.0.5: sdl2-config.cmake
    Only in SDL2-2.0.5: sdl2.pc
    diff -ru SDL2-2.0.5-orig/src/atomic/SDL_spinlock.c SDL2-2.0.5/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.5-orig/src/file/cocoa/SDL_rwopsbundlesupport.m SDL2-2.0.5/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.5-orig/src/filesystem/cocoa/SDL_sysfilesystem.m SDL2-2.0.5/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.5-orig/src/joystick/darwin/SDL_sysjoystick.c SDL2-2.0.5/src/joystick/darwin/SDL_sysjoystick.c
    old new  
    436436    device->instance_id = ++s_joystick_instance_id;
    437437
    438438    /* We have to do some storage of the io_service_t for SDL_HapticOpenFromJoystick */
     439    #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    439440    ioservice = IOHIDDeviceGetService(ioHIDDeviceObject);
     441    #else
     442    ioservice = 0;
     443    #endif
    440444#if SDL_HAPTIC_IOKIT
    441445    if ((ioservice) && (FFIsForceFeedback(ioservice) == FF_OK)) {
    442446        device->ffservice = ioservice;
  • src/video/cocoa/SDL_cocoaclipboard.m

    diff -ru SDL2-2.0.5-orig/src/video/cocoa/SDL_cocoaclipboard.m SDL2-2.0.5/src/video/cocoa/SDL_cocoaclipboard.m
    old new  
    2525#include "SDL_cocoavideo.h"
    2626#include "../../events/SDL_clipboardevents_c.h"
    2727
     28static NSString *
     29GetTextFormat(_THIS)
     30{
     31#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
     32    if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) {
     33        return NSPasteboardTypeString;
     34    } else {
     35#endif
     36        return NSStringPboardType;
     37#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
     38    }
     39#endif
     40}
     41
    2842int
    2943Cocoa_SetClipboardText(_THIS, const char *text)
     44#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    3045{ @autoreleasepool
    3146{
     47#else
     48{   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
     49#endif
    3250    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    3351    NSPasteboard *pasteboard;
     52#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    3453    NSString *format = NSPasteboardTypeString;
     54#else
     55    NSString *format = GetTextFormat(_this);
     56#endif
    3557
    3658    pasteboard = [NSPasteboard generalPasteboard];
    3759    data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
    3860    [pasteboard setString:[NSString stringWithUTF8String:text] forType:format];
    3961
     62#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     63    [pool release];
     64#endif
    4065    return 0;
     66#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    4167}}
     68#else
     69}
     70#endif
    4271
    4372char *
    4473Cocoa_GetClipboardText(_THIS)
     74#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    4575{ @autoreleasepool
    4676{
     77#else
     78{   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
     79#endif
    4780    NSPasteboard *pasteboard;
     81#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    4882    NSString *format = NSPasteboardTypeString;
     83#else
     84    NSString *format = GetTextFormat(_this);
     85#endif
    4986    NSString *available;
    5087    char *text;
    5188
     
    66103        text = SDL_strdup("");
    67104    }
    68105
     106#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     107    [pool release];
     108#endif
    69109    return text;
     110#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    70111}}
     112#else
     113}
     114#endif
    71115
    72116SDL_bool
    73117Cocoa_HasClipboardText(_THIS)
     
    83127
    84128void
    85129Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data)
     130#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    86131{ @autoreleasepool
    87132{
     133#else
     134{   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
     135#endif
    88136    NSPasteboard *pasteboard;
    89137    NSInteger count;
    90138
     
    96144        }
    97145        data->clipboard_count = count;
    98146    }
     147#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    99148}}
     149#else
     150    [pool release];
     151}
     152#endif
    100153
    101154#endif /* SDL_VIDEO_DRIVER_COCOA */
    102155
  • src/video/cocoa/SDL_cocoaevents.m

    diff -ru SDL2-2.0.5-orig/src/video/cocoa/SDL_cocoaevents.m SDL2-2.0.5/src/video/cocoa/SDL_cocoaevents.m
    old new  
    9797- (void)setAppleMenu:(NSMenu *)menu;
    9898@end
    9999
     100#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    100101@interface SDLAppDelegate : NSObject <NSApplicationDelegate> {
     102#else
     103@interface SDLAppDelegate : NSObject {
     104#endif
    101105@public
    102106    BOOL seenFirstActivate;
    103107}
     
    157161     */
    158162    for (NSWindow *window in [NSApp orderedWindows]) {
    159163        if (window != win && [window canBecomeKeyWindow]) {
    160             if (![window isOnActiveSpace]) {
    161                 continue;
     164            if ([window respondsToSelector:@selector(isOnActiveSpace)]) {
     165                if (![window isOnActiveSpace]) {
     166                    continue;
     167                }
    162168            }
    163169            [window makeKeyAndOrderFront:self];
    164170            return;
     
    328334    [windowMenu release];
    329335
    330336
     337#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    331338    /* Add the fullscreen view toggle menu option, if supported */
    332339    if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
    333340        /* Create the view menu */
     
    345352
    346353        [viewMenu release];
    347354    }
     355#endif
    348356}
    349357
    350358void
    351359Cocoa_RegisterApp(void)
     360#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    352361{ @autoreleasepool
    353362{
     363#else
     364{
     365    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     366#endif
    354367    /* This can get called more than once! Be careful what you initialize! */
    355368
    356369    if (NSApp == nil) {
     
    360373        s_bShouldHandleEventsInSDLApplication = SDL_TRUE;
    361374
    362375        if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, SDL_FALSE)) {
     376#if defined(MAC_OS_X_VERSION_10_6)
     377#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
    363378            [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
     379#endif
     380#endif
    364381            [NSApp activateIgnoringOtherApps:YES];
    365382                }
    366383               
     
    388405            appDelegate->seenFirstActivate = YES;
    389406        }
    390407    }
     408#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    391409}}
     410#else
     411    [pool release];
     412}
     413#endif
    392414
    393415void
    394416Cocoa_PumpEvents(_THIS)
     417#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    395418{ @autoreleasepool
    396419{
     420#else
     421{
     422    NSAutoreleasePool *pool;
     423#endif
    397424    /* Update activity every 30 seconds to prevent screensaver */
    398425    SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
    399426    if (_this->suspend_screensaver && !data->screensaver_use_iopm) {
     
    405432        }
    406433    }
    407434
     435#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     436    pool = [[NSAutoreleasePool alloc] init];
     437#endif
    408438    for ( ; ; ) {
    409439        NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
    410440        if ( event == nil ) {
     
    418448        // Pass events down to SDLApplication to be handled in sendEvent:
    419449        [NSApp sendEvent:event];
    420450    }
     451#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    421452}}
     453#else
     454    [pool release];
     455}
     456#endif
    422457
    423458void
    424459Cocoa_SuspendScreenSaver(_THIS)
     460#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    425461{ @autoreleasepool
    426462{
    427463    SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
     
    448484                                           &data->screensaver_assertion);
    449485    }
    450486}}
     487#else
     488{
     489}
     490#endif
    451491
    452492#endif /* SDL_VIDEO_DRIVER_COCOA */
    453493
  • src/video/cocoa/SDL_cocoakeyboard.m

    diff -ru SDL2-2.0.5-orig/src/video/cocoa/SDL_cocoakeyboard.m SDL2-2.0.5/src/video/cocoa/SDL_cocoakeyboard.m
    old new  
    143143            aRange.location, aRange.length, windowHeight,
    144144            NSStringFromRect(rect));
    145145
     146#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    146147    if ([window respondsToSelector:@selector(convertRectToScreen:)]) {
    147148        rect = [window convertRectToScreen:rect];
    148149    } else {
     150#endif
    149151        rect.origin = [window convertBaseToScreen:rect.origin];
     152#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    150153    }
     154#endif
    151155
    152156    return rect;
    153157}
     
    588592
    589593void
    590594Cocoa_StartTextInput(_THIS)
     595#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    591596{ @autoreleasepool
    592597{
     598#else
     599{
     600    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     601#endif
    593602    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    594603    SDL_Window *window = SDL_GetKeyboardFocus();
    595604    NSWindow *nswindow = nil;
     
    615624        [parentView addSubview: data->fieldEdit];
    616625        [nswindow makeFirstResponder: data->fieldEdit];
    617626    }
     627#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    618628}}
     629#else
     630    [pool release];
     631}
     632#endif
    619633
    620634void
    621635Cocoa_StopTextInput(_THIS)
     636#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    622637{ @autoreleasepool
     638#endif
    623639{
    624640    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    625641
    626642    if (data && data->fieldEdit) {
     643#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     644        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     645#endif
    627646        [data->fieldEdit removeFromSuperview];
    628647        [data->fieldEdit release];
    629648        data->fieldEdit = nil;
     649#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     650        [pool release];
     651#endif
    630652    }
     653#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    631654}}
     655#else
     656}
     657#endif
    632658
    633659void
    634660Cocoa_SetTextInputRect(_THIS, SDL_Rect *rect)
  • src/video/cocoa/SDL_cocoamessagebox.m

    diff -ru SDL2-2.0.5-orig/src/video/cocoa/SDL_cocoamessagebox.m SDL2-2.0.5/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.h

    diff -ru SDL2-2.0.5-orig/src/video/cocoa/SDL_cocoamodes.h SDL2-2.0.5/src/video/cocoa/SDL_cocoamodes.h
    old new  
    3030
    3131typedef struct
    3232{
     33#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    3334    CGDisplayModeRef moderef;
     35#else
     36    const void *moderef;
     37#endif
    3438} SDL_DisplayModeData;
    3539
    3640extern void Cocoa_InitModes(_THIS);
  • src/video/cocoa/SDL_cocoamodes.m

    diff -ru SDL2-2.0.5-orig/src/video/cocoa/SDL_cocoamodes.m SDL2-2.0.5/src/video/cocoa/SDL_cocoamodes.m
    old new  
    100100}
    101101
    102102static SDL_bool
     103#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    103104GetDisplayMode(_THIS, CGDisplayModeRef vidmode, CVDisplayLinkRef link, SDL_DisplayMode *mode)
     105#else
     106GetDisplayMode(_THIS, const void *moderef, CVDisplayLinkRef link, SDL_DisplayMode *mode)
     107#endif
    104108{
    105109    SDL_DisplayModeData *data;
     110#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    106111    int width = 0;
    107112    int height = 0;
    108113    int bpp = 0;
    109114    int refreshRate = 0;
    110115    CFStringRef fmt;
     116#else
     117    long width = 0;
     118    long height = 0;
     119    long bpp = 0;
     120    long refreshRate = 0;
     121#endif
    111122
    112123    data = (SDL_DisplayModeData *) SDL_malloc(sizeof(*data));
    113124    if (!data) {
    114125        return SDL_FALSE;
    115126    }
     127#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    116128    data->moderef = vidmode;
     129#else
     130    data->moderef = moderef;
     131#endif
    117132
     133#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    118134    fmt = CGDisplayModeCopyPixelEncoding(vidmode);
    119135    width = (int) CGDisplayModeGetWidth(vidmode);
    120136    height = (int) CGDisplayModeGetHeight(vidmode);
     
    134150    }
    135151
    136152    CFRelease(fmt);
     153#else
     154    {
     155        CFNumberRef number;
     156        double refresh;
     157        CFDictionaryRef vidmode = (CFDictionaryRef) moderef;
     158        number = CFDictionaryGetValue(vidmode, kCGDisplayWidth);
     159        CFNumberGetValue(number, kCFNumberLongType, &width);
     160        number = CFDictionaryGetValue(vidmode, kCGDisplayHeight);
     161        CFNumberGetValue(number, kCFNumberLongType, &height);
     162        number = CFDictionaryGetValue(vidmode, kCGDisplayBitsPerPixel);
     163        CFNumberGetValue(number, kCFNumberLongType, &bpp);
     164        number = CFDictionaryGetValue(vidmode, kCGDisplayRefreshRate);
     165        CFNumberGetValue(number, kCFNumberDoubleType, &refresh);
     166        refreshRate = (long) (refresh + 0.5);
     167    }
     168#endif
    137169
    138170    /* CGDisplayModeGetRefreshRate returns 0 for many non-CRT displays. */
    139171    if (refreshRate == 0 && link != NULL) {
     
    182214
    183215void
    184216Cocoa_InitModes(_THIS)
     217#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    185218{ @autoreleasepool
    186219{
     220#else
     221{
     222    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     223#endif
    187224    CGDisplayErr result;
    188225    CGDirectDisplayID *displays;
    189226    CGDisplayCount numDisplays;
     
    192229    result = CGGetOnlineDisplayList(0, NULL, &numDisplays);
    193230    if (result != kCGErrorSuccess) {
    194231        CG_SetError("CGGetOnlineDisplayList()", result);
     232#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     233        [pool release];
     234#endif
    195235        return;
    196236    }
    197237    displays = SDL_stack_alloc(CGDirectDisplayID, numDisplays);
     
    199239    if (result != kCGErrorSuccess) {
    200240        CG_SetError("CGGetOnlineDisplayList()", result);
    201241        SDL_stack_free(displays);
     242#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     243        [pool release];
     244#endif
    202245        return;
    203246    }
    204247
     
    208251            SDL_VideoDisplay display;
    209252            SDL_DisplayData *displaydata;
    210253            SDL_DisplayMode mode;
     254#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    211255            CGDisplayModeRef moderef = NULL;
     256#else
     257            const void *moderef = NULL;
     258#endif
    212259            CVDisplayLinkRef link = NULL;
    213260
    214261            if (pass == 0) {
     
    225272                continue;
    226273            }
    227274
     275            #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    228276            moderef = CGDisplayCopyDisplayMode(displays[i]);
     277            #else
     278            moderef = CGDisplayCurrentMode(displays[i]);
     279            #endif
    229280
    230281            if (!moderef) {
    231282                continue;
     
    233284
    234285            displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
    235286            if (!displaydata) {
     287            #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    236288                CGDisplayModeRelease(moderef);
     289            #endif
    237290                continue;
    238291            }
    239292            displaydata->display = displays[i];
     
    245298            display.name = (char *)Cocoa_GetDisplayName(displays[i]);
    246299            if (!GetDisplayMode(_this, moderef, link, &mode)) {
    247300                CVDisplayLinkRelease(link);
     301            #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    248302                CGDisplayModeRelease(moderef);
     303            #endif
    249304                SDL_free(display.name);
    250305                SDL_free(displaydata);
    251306                continue;
     
    261316        }
    262317    }
    263318    SDL_stack_free(displays);
     319#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     320    [pool release];
     321}
     322#else
    264323}}
     324#endif
    265325
    266326int
    267327Cocoa_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect)
     
    340400Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
    341401{
    342402    SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
     403#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    343404    CFArrayRef modes = CGDisplayCopyAllDisplayModes(data->display, NULL);
     405#else
     406    CFArrayRef modes = CGDisplayAvailableModes(data->display);
     407#endif
    344408
    345409    if (modes) {
    346410        CVDisplayLinkRef link = NULL;
     
    350414        CVDisplayLinkCreateWithCGDisplay(data->display, &link);
    351415
    352416        for (i = 0; i < count; i++) {
     417#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    353418            CGDisplayModeRef moderef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
     419#else
     420            const void *moderef = CFArrayGetValueAtIndex(modes, i);
     421#endif
    354422            SDL_DisplayMode mode;
    355423            if (GetDisplayMode(_this, moderef, link, &mode)) {
     424                #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    356425                CGDisplayModeRetain(moderef);
     426                #endif
    357427                SDL_AddDisplayMode(display, &mode);
    358428            }
    359429        }
     
    378448
    379449    if (data == display->desktop_mode.driverdata) {
    380450        /* Restoring desktop mode */
     451#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    381452        CGDisplaySetDisplayMode(displaydata->display, data->moderef, NULL);
     453#else
     454        CGDisplaySwitchToMode(displaydata->display, data->moderef);
     455#endif
    382456
    383457        if (CGDisplayIsMain(displaydata->display)) {
    384458            CGReleaseAllDisplays();
     
    403477        }
    404478
    405479        /* Do the physical switch */
     480#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    406481        result = CGDisplaySetDisplayMode(displaydata->display, data->moderef, NULL);
     482#else
     483        result = CGDisplaySwitchToMode(displaydata->display, data->moderef);
     484#endif
    407485        if (result != kCGErrorSuccess) {
    408486            CG_SetError("CGDisplaySwitchToMode()", result);
    409487            goto ERR_NO_SWITCH;
     
    448526        }
    449527
    450528        mode = (SDL_DisplayModeData *) display->desktop_mode.driverdata;
     529        #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    451530        CGDisplayModeRelease(mode->moderef);
     531        #endif
    452532
    453533        for (j = 0; j < display->num_display_modes; j++) {
    454534            mode = (SDL_DisplayModeData*) display->display_modes[j].driverdata;
     535        #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    455536            CGDisplayModeRelease(mode->moderef);
     537        #endif
    456538        }
    457539
    458540    }
  • src/video/cocoa/SDL_cocoamouse.m

    diff -ru SDL2-2.0.5-orig/src/video/cocoa/SDL_cocoamouse.m SDL2-2.0.5/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.5-orig/src/video/cocoa/SDL_cocoaopengl.m SDL2-2.0.5/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;
     
    175184
    176185    attr[i++] = NSOpenGLPFAAllowOfflineRenderers;
    177186
     187#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     188    pool = [[NSAutoreleasePool alloc] init];
     189#endif
    178190    /* specify a profile if we're on Lion (10.7) or later. */
     191#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    179192    if (lion_or_later) {
    180193        NSOpenGLPixelFormatAttribute profile = NSOpenGLProfileVersionLegacy;
    181194        if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) {
     
    184197        attr[i++] = NSOpenGLPFAOpenGLProfile;
    185198        attr[i++] = profile;
    186199    }
     200#endif
    187201
    188202    attr[i++] = NSOpenGLPFAColorSize;
    189203    attr[i++] = SDL_BYTESPERPIXEL(display->current_mode.format)*8;
     
    239253    fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
    240254    if (fmt == nil) {
    241255        SDL_SetError("Failed creating OpenGL pixel format");
     256#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     257        [pool release];
     258#endif
    242259        return NULL;
    243260    }
    244261
     
    252269
    253270    if (context == nil) {
    254271        SDL_SetError("Failed creating OpenGL context");
     272#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     273        [pool release];
     274#endif
    255275        return NULL;
    256276    }
    257277
    258278    if ( Cocoa_GL_MakeCurrent(_this, window, context) < 0 ) {
    259279        Cocoa_GL_DeleteContext(_this, context);
    260280        SDL_SetError("Failed making OpenGL context current");
     281#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     282        [pool release];
     283#endif
    261284        return NULL;
    262285    }
    263286
     
    272295        if (!glGetStringFunc) {
    273296            Cocoa_GL_DeleteContext(_this, context);
    274297            SDL_SetError ("Failed getting OpenGL glGetString entry point");
     298#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     299            [pool release];
     300#endif
    275301            return NULL;
    276302        }
    277303
     
    279305        if (glversion == NULL) {
    280306            Cocoa_GL_DeleteContext(_this, context);
    281307            SDL_SetError ("Failed getting OpenGL context version");
     308#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     309            [pool release];
     310#endif
    282311            return NULL;
    283312        }
    284313
    285314        if (SDL_sscanf(glversion, "%d.%d", &glversion_major, &glversion_minor) != 2) {
    286315            Cocoa_GL_DeleteContext(_this, context);
    287316            SDL_SetError ("Failed parsing OpenGL context version");
     317#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     318            [pool release];
     319#endif
    288320            return NULL;
    289321        }
    290322
     
    292324           ((glversion_major == _this->gl_config.major_version) && (glversion_minor < _this->gl_config.minor_version))) {
    293325            Cocoa_GL_DeleteContext(_this, context);
    294326            SDL_SetError ("Failed creating OpenGL context at version requested");
     327#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     328            [pool release];
     329#endif
    295330            return NULL;
    296331        }
    297332
     
    301336        /*_this->gl_config.major_version = glversion_major;*/
    302337        /*_this->gl_config.minor_version = glversion_minor;*/
    303338    }
     339#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     340    [pool release];
     341#endif
    304342    return context;
     343#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     344}
     345#else
    305346}}
     347#endif
    306348
    307349int
    308350Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
     351#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    309352{ @autoreleasepool
    310353{
     354#else
     355{
     356    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     357#endif
    311358    if (context) {
    312359        SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context;
    313360        [nscontext setWindow:window];
     
    317364        [NSOpenGLContext clearCurrentContext];
    318365    }
    319366
     367#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     368    [pool release];
     369#endif
    320370    return 0;
     371#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    321372}}
     373#else
     374}
     375#endif
    322376
    323377void
    324378Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
     
    329383
    330384    /* This gives us the correct viewport for a Retina-enabled view, only
    331385     * supported on 10.7+. */
     386#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    332387    if ([contentView respondsToSelector:@selector(convertRectToBacking:)]) {
    333388        viewport = [contentView convertRectToBacking:viewport];
    334389    }
     390#endif
    335391
    336392    if (w) {
    337393        *w = viewport.size.width;
     
    344400
    345401int
    346402Cocoa_GL_SetSwapInterval(_THIS, int interval)
     403#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    347404{ @autoreleasepool
     405#endif
    348406{
    349407    NSOpenGLContext *nscontext;
    350408    GLint value;
     
    353411    if (interval < 0) {  /* no extension for this on Mac OS X at the moment. */
    354412        return SDL_SetError("Late swap tearing currently unsupported");
    355413    }
     414#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     415    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     416#endif
    356417
    357418    nscontext = (NSOpenGLContext*)SDL_GL_GetCurrentContext();
    358419    if (nscontext != nil) {
     
    363424        status = SDL_SetError("No current OpenGL context");
    364425    }
    365426
     427#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     428    [pool release];
     429#endif
    366430    return status;
     431#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    367432}}
     433#else
     434}
     435#endif
    368436
    369437int
    370438Cocoa_GL_GetSwapInterval(_THIS)
     439#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    371440{ @autoreleasepool
    372441{
     442#else
     443{
     444    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     445#endif
    373446    NSOpenGLContext *nscontext;
    374447    GLint value;
    375448    int status = 0;
     
    380453        status = (int)value;
    381454    }
    382455
     456#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     457    [pool release];
     458#endif
    383459    return status;
     460#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    384461}}
     462#else
     463}
     464#endif
    385465
    386466void
    387467Cocoa_GL_SwapWindow(_THIS, SDL_Window * window)
     468#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    388469{ @autoreleasepool
    389470{
     471#else
     472{
     473    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     474#endif
    390475    SDLOpenGLContext* nscontext = (SDLOpenGLContext*)SDL_GL_GetCurrentContext();
    391476    [nscontext flushBuffer];
    392477    [nscontext updateIfNeeded];
     478#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    393479}}
     480#else
     481    [pool release];
     482}
     483#endif
    394484
    395485void
    396486Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context)
     487#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    397488{ @autoreleasepool
    398489{
     490#else
     491{
     492    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     493#endif
    399494    SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context;
    400495
    401496    [nscontext setWindow:NULL];
    402497    [nscontext release];
     498#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    403499}}
     500#else
     501    [pool release];
     502}
     503#endif
    404504
    405505#endif /* SDL_VIDEO_OPENGL_CGL */
    406506
  • src/video/cocoa/SDL_cocoashape.m

    diff -ru SDL2-2.0.5-orig/src/video/cocoa/SDL_cocoashape.m SDL2-2.0.5/src/video/cocoa/SDL_cocoashape.m
    old new  
    7373
    7474int
    7575Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode)
     76#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    7677{ @autoreleasepool
    7778{
     79#else
     80{
     81    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     82#endif
    7883    SDL_ShapeData* data = (SDL_ShapeData*)shaper->driverdata;
    7984    SDL_WindowData* windata = (SDL_WindowData*)shaper->window->driverdata;
    8085    SDL_CocoaClosure closure;
     
    97102    SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure);
    98103    [closure.path addClip];
    99104
     105#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     106    [pool release];
     107#endif
    100108    return 0;
     109#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    101110}}
     111#else
     112}
     113#endif
    102114
    103115int
    104116Cocoa_ResizeWindowShape(SDL_Window *window)
  • src/video/cocoa/SDL_cocoavideo.m

    diff -ru SDL2-2.0.5-orig/src/video/cocoa/SDL_cocoavideo.m SDL2-2.0.5/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"
     
    150157    Cocoa_InitKeyboard(_this);
    151158    Cocoa_InitMouse(_this);
    152159
     160#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    153161    data->allow_spaces = ((floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) && SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_TRUE));
    154162
    155163    /* The IOPM assertion API can disable the screensaver as of 10.7. */
    156164    data->screensaver_use_iopm = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6;
     165#else
     166    data->allow_spaces = 0;
     167    data->screensaver_use_iopm = 0;
     168#endif
    157169
    158170    return 0;
    159171}
  • src/video/cocoa/SDL_cocoawindow.h

    diff -ru SDL2-2.0.5-orig/src/video/cocoa/SDL_cocoawindow.h SDL2-2.0.5/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.5-orig/src/video/cocoa/SDL_cocoawindow.m SDL2-2.0.5/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    SDL_VideoDevice *_this = SDL_GetVideoDevice();
    120131    NSPasteboard *pasteboard = [sender draggingPasteboard];
    121132    NSArray *types = [NSArray arrayWithObject:NSFilenamesPboardType];
     
    131142        return NO;
    132143    }
    133144
     145#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     146    pool = [[NSAutoreleasePool alloc] init];
     147#endif
     148
    134149    SDL_assert([desiredType isEqualToString:NSFilenamesPboardType]);
    135150    NSArray *array = [pasteboard propertyListForType:@"NSFilenamesPboardType"];
    136151
    137152    for (NSString *path in array) {
    138153        NSURL *fileURL = [NSURL fileURLWithPath:path];
     154#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    139155        NSNumber *isAlias = nil;
    140156
    141157        [fileURL getResourceValue:&isAlias forKey:NSURLIsAliasFileKey error:nil];
     
    156172                }
    157173            }
    158174        }
     175#endif
    159176
    160177        /* !!! FIXME: is there a better way to do this? */
    161178        if (_this) {
     
    168185        }
    169186
    170187        if (!SDL_SendDropFile(sdlwindow, [[fileURL path] UTF8String])) {
     188#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     189            [pool release];
     190#endif
    171191            return NO;
    172192        }
    173193    }
    174194
     195#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     196    [pool release];
     197#endif
    175198    SDL_SendDropComplete(sdlwindow);
    176199    return YES;
     200#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     201}
     202#else
    177203}}
     204#endif
    178205
    179206- (BOOL)wantsPeriodicDraggingUpdates
    180207{
     
    284311        [center addObserver:self selector:@selector(windowDidDeminiaturize:) name:NSWindowDidDeminiaturizeNotification object:window];
    285312        [center addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:window];
    286313        [center addObserver:self selector:@selector(windowDidResignKey:) name:NSWindowDidResignKeyNotification object:window];
     314#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    287315        [center addObserver:self selector:@selector(windowDidChangeBackingProperties:) name:NSWindowDidChangeBackingPropertiesNotification object:window];
    288316        [center addObserver:self selector:@selector(windowWillEnterFullScreen:) name:NSWindowWillEnterFullScreenNotification object:window];
    289317        [center addObserver:self selector:@selector(windowDidEnterFullScreen:) name:NSWindowDidEnterFullScreenNotification object:window];
    290318        [center addObserver:self selector:@selector(windowWillExitFullScreen:) name:NSWindowWillExitFullScreenNotification object:window];
    291319        [center addObserver:self selector:@selector(windowDidExitFullScreen:) name:NSWindowDidExitFullScreenNotification object:window];
     320#endif
    292321        [center addObserver:self selector:@selector(windowDidFailToEnterFullScreen:) name:@"NSWindowDidFailToEnterFullScreenNotification" object:window];
    293322        [center addObserver:self selector:@selector(windowDidFailToExitFullScreen:) name:@"NSWindowDidFailToExitFullScreenNotification" object:window];
    294323    } else {
     
    379408    inFullscreenTransition = YES;
    380409
    381410    /* you need to be FullScreenPrimary, or toggleFullScreen doesn't work. Unset it again in windowDidExitFullScreen. */
     411#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    382412    [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
     413#endif
    383414    [nswindow performSelectorOnMainThread: @selector(toggleFullScreen:) withObject:nswindow waitUntilDone:NO];
    384415    return YES;
    385416}
     
    415446        [center removeObserver:self name:NSWindowDidDeminiaturizeNotification object:window];
    416447        [center removeObserver:self name:NSWindowDidBecomeKeyNotification object:window];
    417448        [center removeObserver:self name:NSWindowDidResignKeyNotification object:window];
     449#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    418450        [center removeObserver:self name:NSWindowDidChangeBackingPropertiesNotification object:window];
    419451        [center removeObserver:self name:NSWindowWillEnterFullScreenNotification object:window];
    420452        [center removeObserver:self name:NSWindowDidEnterFullScreenNotification object:window];
    421453        [center removeObserver:self name:NSWindowWillExitFullScreenNotification object:window];
    422454        [center removeObserver:self name:NSWindowDidExitFullScreenNotification object:window];
     455#endif
    423456        [center removeObserver:self name:@"NSWindowDidFailToEnterFullScreenNotification" object:window];
    424457        [center removeObserver:self name:@"NSWindowDidFailToExitFullScreenNotification" object:window];
    425458    } else {
     
    594627        [NSMenu setMenuBarVisible:NO];
    595628    }
    596629
     630#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    597631    const unsigned int newflags = [NSEvent modifierFlags] & NSAlphaShiftKeyMask;
    598632    _data->videodata->modifierFlags = (_data->videodata->modifierFlags & ~NSAlphaShiftKeyMask) | newflags;
    599633    SDL_ToggleModState(KMOD_CAPS, newflags != 0);
     634#endif
    600635}
    601636
    602637- (void)windowDidResignKey:(NSNotification *)aNotification
     
    623658
    624659- (void)windowDidChangeBackingProperties:(NSNotification *)aNotification
    625660{
     661#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    626662    NSNumber *oldscale = [[aNotification userInfo] objectForKey:NSBackingPropertyOldScaleFactorKey];
    627663
    628664    if (inFullscreenTransition) {
     
    635671        _data->window->h = 0;
    636672        [self windowDidResize:aNotification];
    637673    }
     674#endif
    638675}
    639676
    640677- (void)windowWillEnterFullScreen:(NSNotification *)aNotification
     
    735772        [nswindow miniaturize:nil];
    736773    } else {
    737774        /* Adjust the fullscreen toggle button and readd menu now that we're here. */
     775#if MAC_OS_X_VERSION_MIN_REQUIRED > 1070
    738776        if (window->flags & SDL_WINDOW_RESIZABLE) {
    739777            /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
    740778            [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
    741779        } else {
    742780            [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged];
    743781        }
     782#endif
    744783        [NSMenu setMenuBarVisible:YES];
    745784
    746785        pendingWindowOperation = PENDING_OPERATION_NONE;
     
    758797    }
    759798}
    760799
     800#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    761801-(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions
    762802{
    763803    if ((_data->window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
     
    766806        return proposedOptions;
    767807    }
    768808}
     809#endif
    769810
    770811
    771812/* We'll respond to key events by doing nothing so we don't beep.
     
    9921033
    9931034- (void)touchesBeganWithEvent:(NSEvent *) theEvent
    9941035{
     1036#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    9951037    NSSet *touches = [theEvent touchesMatchingPhase:NSTouchPhaseAny inView:nil];
    9961038    int existingTouchCount = 0;
    9971039
     
    10121054
    10131055    DLog("Began Fingers: %lu .. existing: %d", (unsigned long)[touches count], existingTouchCount);
    10141056    [self handleTouches:NSTouchPhaseBegan withEvent:theEvent];
     1057#endif
    10151058}
    10161059
    10171060- (void)touchesMovedWithEvent:(NSEvent *) theEvent
    10181061{
     1062#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    10191063    [self handleTouches:NSTouchPhaseMoved withEvent:theEvent];
     1064#endif
    10201065}
    10211066
    10221067- (void)touchesEndedWithEvent:(NSEvent *) theEvent
    10231068{
     1069#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    10241070    [self handleTouches:NSTouchPhaseEnded withEvent:theEvent];
     1071#endif
    10251072}
    10261073
    10271074- (void)touchesCancelledWithEvent:(NSEvent *) theEvent
    10281075{
     1076#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    10291077    [self handleTouches:NSTouchPhaseCancelled withEvent:theEvent];
     1078#endif
    10301079}
    10311080
     1081#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
     1082#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
    10321083- (void)handleTouches:(NSTouchPhase) phase withEvent:(NSEvent *) theEvent
     1084#else
     1085- (void)handleTouches:(cocoaTouchType)type withEvent:(NSEvent *)event
     1086#endif
    10331087{
     1088#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1089    NSSet *touches = 0;
     1090    NSEnumerator *enumerator;
     1091    NSTouch *touch;
     1092
     1093    switch (type) {
     1094        case COCOA_TOUCH_DOWN:
     1095            touches = [event touchesMatchingPhase:NSTouchPhaseBegan inView:nil];
     1096            break;
     1097        case COCOA_TOUCH_UP:
     1098            touches = [event touchesMatchingPhase:NSTouchPhaseEnded inView:nil];
     1099            break;
     1100        case COCOA_TOUCH_CANCELLED:
     1101            touches = [event touchesMatchingPhase:NSTouchPhaseCancelled inView:nil];
     1102            break;
     1103        case COCOA_TOUCH_MOVE:
     1104            touches = [event touchesMatchingPhase:NSTouchPhaseMoved inView:nil];
     1105            break;
     1106    }
     1107
     1108    enumerator = [touches objectEnumerator];
     1109    touch = (NSTouch*)[enumerator nextObject];
     1110    while (touch) {
     1111        const SDL_TouchID touchId = (SDL_TouchID)(intptr_t)[touch device];
     1112        if (!SDL_GetTouch(touchId)) {
     1113            if (SDL_AddTouch(touchId, "") < 0) {
     1114                return;
     1115            }
     1116        }
     1117
     1118        const SDL_FingerID fingerId = (SDL_FingerID)(intptr_t)[touch identity];
     1119        float x = [touch normalizedPosition].x;
     1120        float y = [touch normalizedPosition].y;
     1121        /* Make the origin the upper left instead of the lower left */
     1122        y = 1.0f - y;
     1123
     1124        switch (type) {
     1125        case COCOA_TOUCH_DOWN:
     1126            SDL_SendTouch(touchId, fingerId, SDL_TRUE, x, y, 1.0f);
     1127            break;
     1128        case COCOA_TOUCH_UP:
     1129        case COCOA_TOUCH_CANCELLED:
     1130            SDL_SendTouch(touchId, fingerId, SDL_FALSE, x, y, 1.0f);
     1131            break;
     1132        case COCOA_TOUCH_MOVE:
     1133            SDL_SendTouchMotion(touchId, fingerId, x, y, 1.0f);
     1134            break;
     1135        }
     1136
     1137        touch = (NSTouch*)[enumerator nextObject];
     1138     }
     1139#else
    10341140    NSSet *touches = [theEvent touchesMatchingPhase:phase inView:nil];
    10351141
    10361142    for (NSTouch *touch in touches) {
     
    10601166            break;
    10611167        }
    10621168    }
     1169#endif
    10631170}
     1171#endif
    10641172
    10651173@end
    10661174
     
    11271235
    11281236static int
    11291237SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created)
     1238#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    11301239{ @autoreleasepool
    11311240{
     1241#else
     1242{
     1243    NSAutoreleasePool *pool;
     1244#endif
    11321245    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
    11331246    SDL_WindowData *data;
    11341247
     
    11431256    data->videodata = videodata;
    11441257    data->nscontexts = [[NSMutableArray alloc] init];
    11451258
     1259#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1260    pool = [[NSAutoreleasePool alloc] init];
     1261#endif
    11461262    /* Create an event listener for the window */
    11471263    data->listener = [[Cocoa_WindowListener alloc] init];
    11481264
     
    12031319     */
    12041320    [nswindow setOneShot:NO];
    12051321
     1322#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1323    [pool release];
     1324#endif
    12061325    /* All done! */
    12071326    window->driverdata = data;
    12081327    return 0;
     1328#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1329}
     1330#else
    12091331}}
     1332#endif
    12101333
    12111334int
    12121335Cocoa_CreateWindow(_THIS, SDL_Window * window)
     1336#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    12131337{ @autoreleasepool
    12141338{
     1339#else
     1340{
     1341    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1342#endif
    12151343    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
    12161344    NSWindow *nswindow;
    12171345    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
     
    12521380    [nswindow setBackgroundColor:[NSColor blackColor]];
    12531381
    12541382    if (videodata->allow_spaces) {
     1383#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    12551384        SDL_assert(floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6);
    12561385        SDL_assert([nswindow respondsToSelector:@selector(toggleFullScreen:)]);
    12571386        /* we put FULLSCREEN_DESKTOP windows in their own Space, without a toggle button or menubar, later */
     
    12591388            /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
    12601389            [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
    12611390        }
     1391#endif
    12621392    }
    12631393
    12641394    /* Create a default view for this window */
     
    12771407
    12781408    /* Allow files and folders to be dragged onto the window by users */
    12791409    [nswindow registerForDraggedTypes:[NSArray arrayWithObject:(NSString *)kUTTypeFileURL]];
     1410#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1411    [pool release];
     1412#endif
    12801413
    12811414    if (SetupWindowData(_this, window, nswindow, SDL_TRUE) < 0) {
    12821415        [nswindow release];
    12831416        return -1;
    12841417    }
    12851418    return 0;
     1419#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    12861420}}
     1421#else
     1422}
     1423#endif
    12871424
    12881425int
    12891426Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
     1427#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    12901428{ @autoreleasepool
    12911429{
     1430#else
     1431{
     1432    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1433#endif
    12921434    NSWindow *nswindow = (NSWindow *) data;
    12931435    NSString *title;
    12941436
     
    12991441    }
    13001442
    13011443    return SetupWindowData(_this, window, nswindow, SDL_FALSE);
     1444#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13021445}}
     1446#else
     1447    [pool release];
     1448}
     1449#endif
    13031450
    13041451void
    13051452Cocoa_SetWindowTitle(_THIS, SDL_Window * window)
     1453#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13061454{ @autoreleasepool
    13071455{
     1456#else
     1457{
     1458    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1459#endif
    13081460    const char *title = window->title ? window->title : "";
    13091461    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
    13101462    NSString *string = [[NSString alloc] initWithUTF8String:title];
    13111463    [nswindow setTitle:string];
    13121464    [string release];
     1465#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13131466}}
     1467#else
     1468    [pool release];
     1469}
     1470#endif
    13141471
    13151472void
    13161473Cocoa_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
     1474#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13171475{ @autoreleasepool
    13181476{
     1477#else
     1478{
     1479    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1480#endif
    13191481    NSImage *nsimage = Cocoa_CreateImage(icon);
    13201482
    13211483    if (nsimage) {
    13221484        [NSApp setApplicationIconImage:nsimage];
    13231485    }
     1486#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13241487}}
     1488#else
     1489    [pool release];
     1490}
     1491#endif
    13251492
    13261493void
    13271494Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
     1495#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13281496{ @autoreleasepool
    13291497{
     1498#else
     1499{
     1500    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1501#endif
    13301502    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    13311503    NSWindow *nswindow = windata->nswindow;
    13321504    NSRect rect;
     
    13441516    s_moveHack = moveHack;
    13451517
    13461518    ScheduleContextUpdates(windata);
     1519#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13471520}}
     1521#else
     1522    [pool release];
     1523}
     1524#endif
    13481525
    13491526void
    13501527Cocoa_SetWindowSize(_THIS, SDL_Window * window)
     1528#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13511529{ @autoreleasepool
    13521530{
     1531#else
     1532{
     1533    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1534#endif
    13531535    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    13541536    NSWindow *nswindow = windata->nswindow;
    13551537    NSRect rect;
     
    13711553    s_moveHack = moveHack;
    13721554
    13731555    ScheduleContextUpdates(windata);
     1556#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13741557}}
     1558#else
     1559    [pool release];
     1560}
     1561#endif
    13751562
    13761563void
    13771564Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window)
     1565#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13781566{ @autoreleasepool
    13791567{
     1568#else
     1569{
     1570    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1571#endif
    13801572    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    13811573
    13821574    NSSize minSize;
     
    13841576    minSize.height = window->min_h;
    13851577
    13861578    [windata->nswindow setContentMinSize:minSize];
     1579#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13871580}}
     1581#else
     1582    [pool release];
     1583}
     1584#endif
    13881585
    13891586void
    13901587Cocoa_SetWindowMaximumSize(_THIS, SDL_Window * window)
     1588#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13911589{ @autoreleasepool
    13921590{
     1591#else
     1592{
     1593    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1594#endif
    13931595    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    13941596
    13951597    NSSize maxSize;
     
    13971599    maxSize.height = window->max_h;
    13981600
    13991601    [windata->nswindow setContentMaxSize:maxSize];
     1602#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14001603}}
     1604#else
     1605    [pool release];
     1606}
     1607#endif
    14011608
    14021609void
    14031610Cocoa_ShowWindow(_THIS, SDL_Window * window)
     1611#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14041612{ @autoreleasepool
    14051613{
     1614#else
     1615{
     1616    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1617#endif
    14061618    SDL_WindowData *windowData = ((SDL_WindowData *) window->driverdata);
    14071619    NSWindow *nswindow = windowData->nswindow;
    14081620
     
    14111623        [nswindow makeKeyAndOrderFront:nil];
    14121624        [windowData->listener resumeVisibleObservation];
    14131625    }
     1626#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14141627}}
     1628#else
     1629    [pool release];
     1630}
     1631#endif
    14151632
    14161633void
    14171634Cocoa_HideWindow(_THIS, SDL_Window * window)
     1635#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14181636{ @autoreleasepool
    14191637{
     1638#else
     1639{
     1640    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1641#endif
    14201642    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
    14211643
    14221644    [nswindow orderOut:nil];
     1645#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14231646}}
     1647#else
     1648    [pool release];
     1649}
     1650#endif
    14241651
    14251652void
    14261653Cocoa_RaiseWindow(_THIS, SDL_Window * window)
     1654#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14271655{ @autoreleasepool
    14281656{
     1657#else
     1658{
     1659    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1660#endif
    14291661    SDL_WindowData *windowData = ((SDL_WindowData *) window->driverdata);
    14301662    NSWindow *nswindow = windowData->nswindow;
    14311663
     
    14381670        [nswindow makeKeyAndOrderFront:nil];
    14391671    }
    14401672    [windowData->listener resumeVisibleObservation];
     1673#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14411674}}
     1675#else
     1676    [pool release];
     1677}
     1678#endif
    14421679
    14431680void
    14441681Cocoa_MaximizeWindow(_THIS, SDL_Window * window)
     1682#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14451683{ @autoreleasepool
    14461684{
     1685#else
     1686{
     1687    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1688#endif
    14471689    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    14481690    NSWindow *nswindow = windata->nswindow;
    14491691
    14501692    [nswindow zoom:nil];
    14511693
    14521694    ScheduleContextUpdates(windata);
     1695#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14531696}}
     1697#else
     1698    [pool release];
     1699}
     1700#endif
    14541701
    14551702void
    14561703Cocoa_MinimizeWindow(_THIS, SDL_Window * window)
     1704#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14571705{ @autoreleasepool
    14581706{
     1707#else
     1708{
     1709    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1710#endif
    14591711    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    14601712    NSWindow *nswindow = data->nswindow;
    14611713
     
    14641716    } else {
    14651717        [nswindow miniaturize:nil];
    14661718    }
     1719#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14671720}}
     1721#else
     1722    [pool release];
     1723}
     1724#endif
    14681725
    14691726void
    14701727Cocoa_RestoreWindow(_THIS, SDL_Window * window)
     1728#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14711729{ @autoreleasepool
    14721730{
     1731#else
     1732{
     1733    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1734#endif
    14731735    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
    14741736
    14751737    if ([nswindow isMiniaturized]) {
     
    14771739    } else if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) {
    14781740        [nswindow zoom:nil];
    14791741    }
     1742#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14801743}}
     1744#else
     1745    [pool release];
     1746}
     1747#endif
    14811748
    14821749void
    14831750Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
     1751#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14841752{ @autoreleasepool
    14851753{
     1754#else
     1755{
     1756    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1757#endif
    14861758    if (SetWindowStyle(window, GetWindowStyle(window))) {
    14871759        if (bordered) {
    14881760            Cocoa_SetWindowTitle(_this, window);  /* this got blanked out. */
    14891761        }
    14901762    }
     1763#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14911764}}
     1765#else
     1766    [pool release];
     1767}
     1768#endif
     1769
    14921770
    14931771void
    14941772Cocoa_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable)
     1773#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14951774{ @autoreleasepool
    14961775{
     1776#else
     1777{
     1778    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1779#endif
    14971780    /* Don't set this if we're in a space!
    14981781     * The window will get permanently stuck if resizable is false.
    14991782     * -flibit
     
    15031786    if (![listener isInFullscreenSpace]) {
    15041787        SetWindowStyle(window, GetWindowStyle(window));
    15051788    }
     1789#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15061790}}
     1791#else
     1792    [pool release];
     1793}
     1794#endif
     1795
    15071796
    15081797void
    15091798Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
     1799#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15101800{ @autoreleasepool
    15111801{
     1802#else
     1803{
     1804    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1805#endif
    15121806    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    15131807    NSWindow *nswindow = data->nswindow;
    15141808    NSRect rect;
     
    15791873    }
    15801874
    15811875    ScheduleContextUpdates(data);
     1876#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15821877}}
     1878#else
     1879    [pool release];
     1880}
     1881#endif
    15831882
    15841883int
    15851884Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp)
     
    16641963
    16651964void
    16661965Cocoa_DestroyWindow(_THIS, SDL_Window * window)
     1966#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    16671967{ @autoreleasepool
    16681968{
     1969#else
     1970{
     1971    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1972#endif
    16691973    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    16701974
    16711975    if (data) {
     
    16881992        SDL_free(data);
    16891993    }
    16901994    window->driverdata = NULL;
     1995#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    16911996}}
     1997#else
     1998    [pool release];
     1999}
     2000#endif
    16922001
    16932002SDL_bool
    16942003Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
     
    17202029
    17212030SDL_bool
    17222031Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state)
     2032#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    17232033{ @autoreleasepool
    17242034{
     2035#else
     2036{
     2037    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     2038#endif
    17252039    SDL_bool succeeded = SDL_FALSE;
    17262040    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    17272041
     
    17522066        succeeded = SDL_TRUE;
    17532067    }
    17542068
     2069#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     2070    [pool release];
     2071#endif
    17552072    return succeeded;
     2073#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    17562074}}
     2075#else
     2076}
     2077#endif
    17572078
    17582079int
    17592080Cocoa_SetWindowHitTest(SDL_Window * window, SDL_bool enabled)