Ticket #52210: SDL2-2.0.8_OSX_105.patch

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

Patch to build SDL 2.0.8 on OS X 10.5.8 leopard

  • include/SDL_config.h

    Only in SDL2-2.0.8: Makefile
    Only in SDL2-2.0.8: Makefile.rules
    Only in SDL2-2.0.8: build
    Only in SDL2-2.0.8: config.log
    Only in SDL2-2.0.8: config.status
    diff -ru SDL2-2.0.8-orig/include/SDL_config.h SDL2-2.0.8/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-2018 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 #if defined(__WIN32__)
    33 #include "SDL_config_windows.h"
    34 #elif defined(__WINRT__)
    35 #include "SDL_config_winrt.h"
    36 #elif defined(__MACOSX__)
    37 #include "SDL_config_macosx.h"
    38 #elif defined(__IPHONEOS__)
    39 #include "SDL_config_iphoneos.h"
    40 #elif defined(__ANDROID__)
    41 #include "SDL_config_android.h"
    42 #elif defined(__PSP__)
    43 #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
    4448#else
    45 /* This is a minimal configuration just to get SDL running on new platforms */
    46 #include "SDL_config_minimal.h"
    47 #endif /* platform config */
     49#define SIZEOF_VOIDP 4
     50#endif
     51/* #undef HAVE_GCC_ATOMICS */
     52/* #undef HAVE_GCC_SYNC_LOCK_TEST_AND_SET */
    4853
    49 #ifdef USING_GENERATED_CONFIG_H
    50 #error Wrong SDL_config.h, check your include path?
     54/* Comment this if you want to build without any C library requirements */
     55#define HAVE_LIBC 1
     56#if HAVE_LIBC
     57
     58/* Useful headers */
     59#define STDC_HEADERS 1
     60#define HAVE_ALLOCA_H 1
     61#define HAVE_CTYPE_H 1
     62#define HAVE_FLOAT_H 1
     63#define HAVE_ICONV_H 1
     64#define HAVE_INTTYPES_H 1
     65#define HAVE_LIMITS_H 1
     66/* #undef HAVE_MALLOC_H */
     67#define HAVE_MATH_H 1
     68#define HAVE_MEMORY_H 1
     69#define HAVE_SIGNAL_H 1
     70#define HAVE_STDARG_H 1
     71#define HAVE_STDINT_H 1
     72#define HAVE_STDIO_H 1
     73#define HAVE_STDLIB_H 1
     74#define HAVE_STRINGS_H 1
     75#define HAVE_STRING_H 1
     76#define HAVE_SYS_TYPES_H 1
     77#define HAVE_WCHAR_H 1
     78/* #undef HAVE_PTHREAD_NP_H */
     79/* #undef HAVE_LIBUNWIND_H */
     80
     81/* C library functions */
     82#define HAVE_MALLOC 1
     83#define HAVE_CALLOC 1
     84#define HAVE_REALLOC 1
     85#define HAVE_FREE 1
     86#define HAVE_ALLOCA 1
     87#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */
     88#define HAVE_GETENV 1
     89#define HAVE_SETENV 1
     90#define HAVE_PUTENV 1
     91#define HAVE_UNSETENV 1
    5192#endif
     93#define HAVE_QSORT 1
     94#define HAVE_ABS 1
     95#define HAVE_BCOPY 1
     96#define HAVE_MEMSET 1
     97#define HAVE_MEMCPY 1
     98#define HAVE_MEMMOVE 1
     99#define HAVE_MEMCMP 1
     100#define HAVE_WCSLEN 1
     101/* #undef HAVE_WCSLCPY */
     102/* #undef HAVE_WCSLCAT */
     103#define HAVE_WCSCMP 1
     104#define HAVE_STRLEN 1
     105#define HAVE_STRLCPY 1
     106#define HAVE_STRLCAT 1
     107/* #undef HAVE__STRREV */
     108/* #undef HAVE__STRUPR */
     109/* #undef HAVE__STRLWR */
     110/* #undef HAVE_INDEX */
     111/* #undef HAVE_RINDEX */
     112#define HAVE_STRCHR 1
     113#define HAVE_STRRCHR 1
     114#define HAVE_STRSTR 1
     115/* #undef HAVE_ITOA */
     116/* #undef HAVE__LTOA */
     117/* #undef HAVE__UITOA */
     118/* #undef HAVE__ULTOA */
     119#define HAVE_STRTOL 1
     120#define HAVE_STRTOUL 1
     121/* #undef HAVE__I64TOA */
     122/* #undef HAVE__UI64TOA */
     123#define HAVE_STRTOLL 1
     124#define HAVE_STRTOULL 1
     125#define HAVE_STRTOD 1
     126#define HAVE_ATOI 1
     127#define HAVE_ATOF 1
     128#define HAVE_STRCMP 1
     129#define HAVE_STRNCMP 1
     130/* #undef HAVE__STRICMP */
     131#define HAVE_STRCASECMP 1
     132/* #undef HAVE__STRNICMP */
     133#define HAVE_STRNCASECMP 1
     134/* #undef HAVE_SSCANF */
     135#define HAVE_VSSCANF 1
     136/* #undef HAVE_SNPRINTF */
     137#define HAVE_VSNPRINTF 1
     138#define HAVE_M_PI /**/
     139#define HAVE_ACOS 1
     140#define HAVE_ACOSF 1
     141#define HAVE_ASIN 1
     142#define HAVE_ASINF 1
     143#define HAVE_ATAN 1
     144#define HAVE_ATANF 1
     145#define HAVE_ATAN2 1
     146#define HAVE_ATAN2F 1
     147#define HAVE_CEIL 1
     148#define HAVE_CEILF 1
     149#define HAVE_COPYSIGN 1
     150#define HAVE_COPYSIGNF 1
     151#define HAVE_COS 1
     152#define HAVE_COSF 1
     153#define HAVE_FABS 1
     154#define HAVE_FABSF 1
     155#define HAVE_FLOOR 1
     156#define HAVE_FLOORF 1
     157#define HAVE_FMOD 1
     158#define HAVE_FMODF 1
     159#define HAVE_LOG 1
     160#define HAVE_LOGF 1
     161#define HAVE_LOG10 1
     162#define HAVE_LOG10F 1
     163#define HAVE_POW 1
     164#define HAVE_POWF 1
     165#define HAVE_SCALBN 1
     166#define HAVE_SCALBNF 1
     167#define HAVE_SIN 1
     168#define HAVE_SINF 1
     169#define HAVE_SQRT 1
     170#define HAVE_SQRTF 1
     171#define HAVE_TAN 1
     172#define HAVE_TANF 1
     173/* #undef HAVE_FOPEN64 */
     174#define HAVE_FSEEKO 1
     175/* #undef HAVE_FSEEKO64 */
     176#define HAVE_SIGACTION 1
     177#define HAVE_SA_SIGACTION 1
     178#define HAVE_SETJMP 1
     179#define HAVE_NANOSLEEP 1
     180#define HAVE_SYSCONF 1
     181#define HAVE_SYSCTLBYNAME 1
     182/* #undef HAVE_CLOCK_GETTIME */
     183/* #undef HAVE_GETPAGESIZE */
     184#define HAVE_MPROTECT 1
     185#define HAVE_ICONV 1
     186/* #undef HAVE_PTHREAD_SETNAME_NP */
     187/* #undef HAVE_PTHREAD_SET_NAME_NP */
     188/* #undef HAVE_SEM_TIMEDWAIT */
     189/* #undef HAVE_GETAUXVAL */
     190#define HAVE_POLL 1
     191
     192#else
     193#define HAVE_STDARG_H 1
     194#define HAVE_STDDEF_H 1
     195#define HAVE_STDINT_H 1
     196#endif /* HAVE_LIBC */
     197
     198#define HAVE_ALTIVEC_H 1
     199/* #undef HAVE_DBUS_DBUS_H */
     200/* #undef HAVE_FCITX_FRONTEND_H */
     201/* #undef HAVE_IBUS_IBUS_H */
     202/* #undef HAVE_IMMINTRIN_H */
     203/* #undef HAVE_LIBSAMPLERATE_H */
     204/* #undef HAVE_LIBUDEV_H */
     205
     206/* #undef HAVE_DDRAW_H */
     207/* #undef HAVE_DINPUT_H */
     208/* #undef HAVE_DSOUND_H */
     209/* #undef HAVE_DXGI_H */
     210/* #undef HAVE_XINPUT_H */
     211/* #undef HAVE_XINPUT_GAMEPAD_EX */
     212/* #undef HAVE_XINPUT_STATE_EX */
     213
     214/* SDL internal assertion support */
     215/* #undef SDL_DEFAULT_ASSERT_LEVEL */
     216
     217/* Allow disabling of core subsystems */
     218/* #undef SDL_ATOMIC_DISABLED */
     219/* #undef SDL_AUDIO_DISABLED */
     220/* #undef SDL_CPUINFO_DISABLED */
     221/* #undef SDL_EVENTS_DISABLED */
     222/* #undef SDL_FILE_DISABLED */
     223/* #undef SDL_JOYSTICK_DISABLED */
     224/* #undef SDL_HAPTIC_DISABLED */
     225/* #undef SDL_LOADSO_DISABLED */
     226/* #undef SDL_RENDER_DISABLED */
     227/* #undef SDL_THREADS_DISABLED */
     228/* #undef SDL_TIMERS_DISABLED */
     229/* #undef SDL_VIDEO_DISABLED */
     230/* #undef SDL_POWER_DISABLED */
     231/* #undef SDL_FILESYSTEM_DISABLED */
     232
     233/* Enable various audio drivers */
     234/* #undef SDL_AUDIO_DRIVER_ALSA */
     235/* #undef SDL_AUDIO_DRIVER_ALSA_DYNAMIC */
     236/* #undef SDL_AUDIO_DRIVER_ANDROID */
     237/* #undef SDL_AUDIO_DRIVER_ARTS */
     238/* #undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC */
     239#define SDL_AUDIO_DRIVER_COREAUDIO 1
     240#define SDL_AUDIO_DRIVER_DISK 1
     241/* #undef SDL_AUDIO_DRIVER_DSOUND */
     242#define SDL_AUDIO_DRIVER_DUMMY 1
     243/* #undef SDL_AUDIO_DRIVER_EMSCRIPTEN */
     244/* #undef SDL_AUDIO_DRIVER_ESD */
     245/* #undef SDL_AUDIO_DRIVER_ESD_DYNAMIC */
     246/* #undef SDL_AUDIO_DRIVER_FUSIONSOUND */
     247/* #undef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC */
     248/* #undef SDL_AUDIO_DRIVER_HAIKU */
     249/* #undef SDL_AUDIO_DRIVER_JACK */
     250/* #undef SDL_AUDIO_DRIVER_JACK_DYNAMIC */
     251/* #undef SDL_AUDIO_DRIVER_NACL */
     252/* #undef SDL_AUDIO_DRIVER_NAS */
     253/* #undef SDL_AUDIO_DRIVER_NAS_DYNAMIC */
     254/* #undef SDL_AUDIO_DRIVER_NETBSD */
     255/* #undef SDL_AUDIO_DRIVER_OSS */
     256/* #undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H */
     257/* #undef SDL_AUDIO_DRIVER_PAUDIO */
     258/* #undef SDL_AUDIO_DRIVER_PULSEAUDIO */
     259/* #undef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC */
     260/* #undef SDL_AUDIO_DRIVER_QSA */
     261/* #undef SDL_AUDIO_DRIVER_SNDIO */
     262/* #undef SDL_AUDIO_DRIVER_SNDIO_DYNAMIC */
     263/* #undef SDL_AUDIO_DRIVER_SUNAUDIO */
     264/* #undef SDL_AUDIO_DRIVER_WASAPI */
     265/* #undef SDL_AUDIO_DRIVER_WINMM */
     266
     267/* Enable various input drivers */
     268/* #undef SDL_INPUT_LINUXEV */
     269/* #undef SDL_INPUT_LINUXKD */
     270/* #undef SDL_INPUT_TSLIB */
     271/* #undef SDL_JOYSTICK_HAIKU */
     272/* #undef SDL_JOYSTICK_DINPUT */
     273/* #undef SDL_JOYSTICK_XINPUT */
     274/* #undef SDL_JOYSTICK_DUMMY */
     275#define SDL_JOYSTICK_IOKIT 1
     276/* #undef SDL_JOYSTICK_LINUX */
     277/* #undef SDL_JOYSTICK_ANDROID */
     278/* #undef SDL_JOYSTICK_WINMM */
     279/* #undef SDL_JOYSTICK_USBHID */
     280/* #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H */
     281/* #undef SDL_JOYSTICK_EMSCRIPTEN */
     282/* #undef SDL_HAPTIC_DUMMY */
     283/* #undef SDL_HAPTIC_ANDROID */
     284/* #undef SDL_HAPTIC_LINUX */
     285#define SDL_HAPTIC_IOKIT 1
     286/* #undef SDL_HAPTIC_DINPUT */
     287/* #undef SDL_HAPTIC_XINPUT */
     288
     289/* Enable various shared object loading systems */
     290#define SDL_LOADSO_DLOPEN 1
     291/* #undef SDL_LOADSO_DUMMY */
     292/* #undef SDL_LOADSO_LDG */
     293/* #undef SDL_LOADSO_WINDOWS */
     294
     295/* Enable various threading systems */
     296#define SDL_THREAD_PTHREAD 1
     297#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
     298/* #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP */
     299/* #undef SDL_THREAD_WINDOWS */
     300
     301/* Enable various timer systems */
     302/* #undef SDL_TIMER_HAIKU */
     303/* #undef SDL_TIMER_DUMMY */
     304#define SDL_TIMER_UNIX 1
     305/* #undef SDL_TIMER_WINDOWS */
     306
     307/* Enable various video drivers */
     308/* #undef SDL_VIDEO_DRIVER_HAIKU */
     309#define SDL_VIDEO_DRIVER_COCOA 1
     310/* #undef SDL_VIDEO_DRIVER_DIRECTFB */
     311/* #undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC */
     312#define SDL_VIDEO_DRIVER_DUMMY 1
     313/* #undef SDL_VIDEO_DRIVER_WINDOWS */
     314/* #undef SDL_VIDEO_DRIVER_WAYLAND */
     315/* #undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
     316/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC */
     317/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL */
     318/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR */
     319/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON */
     320/* #undef SDL_VIDEO_DRIVER_MIR */
     321/* #undef SDL_VIDEO_DRIVER_MIR_DYNAMIC */
     322/* #undef SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON */
     323#define SDL_VIDEO_DRIVER_X11 1
     324/* #undef SDL_VIDEO_DRIVER_RPI */
     325/* #undef SDL_VIDEO_DRIVER_KMSDRM */
     326/* #undef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC */
     327/* #undef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM */
     328/* #undef SDL_VIDEO_DRIVER_ANDROID */
     329/* #undef SDL_VIDEO_DRIVER_EMSCRIPTEN */
     330#define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib"
     331#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib"
     332#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR "/usr/X11R6/lib/libXcursor.1.dylib"
     333#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/usr/X11R6/lib/libXinerama.1.dylib"
     334/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 */
     335/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR */
     336#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/usr/X11R6/lib/libXss.1.dylib"
     337#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "/usr/X11R6/lib/libXxf86vm.1.dylib"
     338#define SDL_VIDEO_DRIVER_X11_XCURSOR 1
     339#define SDL_VIDEO_DRIVER_X11_XDBE 1
     340#define SDL_VIDEO_DRIVER_X11_XINERAMA 1
     341/* #undef SDL_VIDEO_DRIVER_X11_XINPUT2 */
     342/* #undef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH */
     343/* #undef SDL_VIDEO_DRIVER_X11_XRANDR */
     344#define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1
     345#define SDL_VIDEO_DRIVER_X11_XSHAPE 1
     346#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1
     347/* #undef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS */
     348/* #undef SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY */
     349#define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1
     350/* #undef SDL_VIDEO_DRIVER_NACL */
     351/* #undef SDL_VIDEO_DRIVER_VIVANTE */
     352/* #undef SDL_VIDEO_DRIVER_VIVANTE_VDK */
     353/* #undef SDL_VIDEO_DRIVER_QNX */
     354
     355/* #undef SDL_VIDEO_RENDER_D3D */
     356/* #undef SDL_VIDEO_RENDER_D3D11 */
     357#define SDL_VIDEO_RENDER_OGL 1
     358/* #undef SDL_VIDEO_RENDER_OGL_ES */
     359/* #undef SDL_VIDEO_RENDER_OGL_ES2 */
     360/* #undef SDL_VIDEO_RENDER_DIRECTFB */
     361/* #undef SDL_VIDEO_RENDER_METAL */
     362
     363/* Enable OpenGL support */
     364#define SDL_VIDEO_OPENGL 1
     365/* #undef SDL_VIDEO_OPENGL_ES */
     366/* #undef SDL_VIDEO_OPENGL_ES2 */
     367/* #undef SDL_VIDEO_OPENGL_BGL */
     368#define SDL_VIDEO_OPENGL_CGL 1
     369/* #undef SDL_VIDEO_OPENGL_EGL */
     370#define SDL_VIDEO_OPENGL_GLX 1
     371/* #undef SDL_VIDEO_OPENGL_WGL */
     372/* #undef SDL_VIDEO_OPENGL_OSMESA */
     373/* #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC */
     374
     375/* Enable Vulkan support */
     376/* #undef SDL_VIDEO_VULKAN */
     377
     378/* Enable system power support */
     379/* #undef SDL_POWER_LINUX */
     380/* #undef SDL_POWER_WINDOWS */
     381#define SDL_POWER_MACOSX 1
     382/* #undef SDL_POWER_HAIKU */
     383/* #undef SDL_POWER_ANDROID */
     384/* #undef SDL_POWER_EMSCRIPTEN */
     385/* #undef SDL_POWER_HARDWIRED */
     386
     387/* Enable system filesystem support */
     388/* #undef SDL_FILESYSTEM_HAIKU */
     389#define SDL_FILESYSTEM_COCOA 1
     390/* #undef SDL_FILESYSTEM_DUMMY */
     391/* #undef SDL_FILESYSTEM_UNIX */
     392/* #undef SDL_FILESYSTEM_WINDOWS */
     393/* #undef SDL_FILESYSTEM_NACL */
     394/* #undef SDL_FILESYSTEM_ANDROID */
     395/* #undef SDL_FILESYSTEM_EMSCRIPTEN */
     396
     397/* Enable assembly routines */
     398#define SDL_ASSEMBLY_ROUTINES 1
     399#define SDL_ALTIVEC_BLITTERS 1
     400
     401/* Enable ime support */
     402/* #undef SDL_USE_IME */
     403
     404/* Enable dynamic udev support */
     405/* #undef SDL_UDEV_DYNAMIC */
     406
     407/* Enable dynamic libsamplerate support */
     408/* #undef SDL_LIBSAMPLERATE_DYNAMIC */
    52409
    53410#endif /* SDL_config_h_ */
  • include/SDL_platform.h

    diff -ru SDL2-2.0.8-orig/include/SDL_platform.h SDL2-2.0.8/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.8-orig/include/SDL_syswm.h SDL2-2.0.8/include/SDL_syswm.h
    old new  
    229229#if defined(SDL_VIDEO_DRIVER_COCOA)
    230230        struct
    231231        {
     232#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    232233#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
    233234            NSWindow __unsafe_unretained *window; /**< The Cocoa window */
    234235#else
    235236            NSWindow *window;                     /**< The Cocoa window */
    236237#endif
     238#else
     239            NSWindow *window;                     /**< The Cocoa window */
     240#endif
    237241        } cocoa;
    238242#endif
    239243#if defined(SDL_VIDEO_DRIVER_UIKIT)
    240244        struct
    241245        {
     246#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    242247#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
    243248            UIWindow __unsafe_unretained *window; /**< The UIKit window */
    244249#else
    245250            UIWindow *window;                     /**< The UIKit window */
    246251#endif
     252#else
     253            UIWindow *window;                     /**< The UIKit window */
     254#endif
    247255            GLuint framebuffer; /**< The GL view's Framebuffer Object. It must be bound when rendering to the screen using GL. */
    248256            GLuint colorbuffer; /**< The GL view's color Renderbuffer Object. It must be bound when SDL_GL_SwapWindow is called. */
    249257            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.8: libtool
    Only in SDL2-2.0.8: sdl2-config
    Only in SDL2-2.0.8: sdl2-config.cmake
    Only in SDL2-2.0.8: sdl2.pc
    diff -ru SDL2-2.0.8-orig/src/atomic/SDL_spinlock.c SDL2-2.0.8/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.8-orig/src/file/cocoa/SDL_rwopsbundlesupport.m SDL2-2.0.8/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.8-orig/src/filesystem/cocoa/SDL_sysfilesystem.m SDL2-2.0.8/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    if (!app) {
    7591        SDL_InvalidParamError("app");
    7692        return NULL;
     
    109125        }
    110126    }
    111127
     128#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    112129    return retval;
    113130}}
     131#else
     132    [pool release];
     133    return retval;
     134}
     135#endif
    114136
    115137#endif /* SDL_FILESYSTEM_COCOA */
    116138
  • src/joystick/darwin/SDL_sysjoystick.c

    diff -ru SDL2-2.0.8-orig/src/joystick/darwin/SDL_sysjoystick.c SDL2-2.0.8/src/joystick/darwin/SDL_sysjoystick.c
    old new  
    469469    device->instance_id = ++s_joystick_instance_id;
    470470
    471471    /* We have to do some storage of the io_service_t for SDL_HapticOpenFromJoystick */
     472    #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    472473    ioservice = IOHIDDeviceGetService(ioHIDDeviceObject);
     474    #else
     475    ioservice = 0;
     476    #endif
    473477#if SDL_HAPTIC_IOKIT
    474478    if ((ioservice) && (FFIsForceFeedback(ioservice) == FF_OK)) {
    475479        device->ffservice = ioservice;
  • src/video/cocoa/SDL_cocoaclipboard.m

    diff -ru SDL2-2.0.8-orig/src/video/cocoa/SDL_cocoaclipboard.m SDL2-2.0.8/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.8-orig/src/video/cocoa/SDL_cocoaevents.m SDL2-2.0.8/src/video/cocoa/SDL_cocoaevents.m
    old new  
    5757    SDL_VideoDevice *_this = SDL_GetVideoDevice();
    5858
    5959    switch ([theEvent type]) {
     60#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     61        case NSLeftMouseDown:
     62        case NSOtherMouseDown:
     63        case NSRightMouseDown:
     64        case NSLeftMouseUp:
     65        case NSOtherMouseUp:
     66        case NSRightMouseUp:
     67        case NSLeftMouseDragged:
     68        case NSRightMouseDragged:
     69        case NSOtherMouseDragged: /* usually middle mouse dragged */
     70        case NSMouseMoved:
     71        case NSScrollWheel:
     72#else
    6073        case NSEventTypeLeftMouseDown:
    6174        case NSEventTypeOtherMouseDown:
    6275        case NSEventTypeRightMouseDown:
     
    6881        case NSEventTypeOtherMouseDragged: /* usually middle mouse dragged */
    6982        case NSEventTypeMouseMoved:
    7083        case NSEventTypeScrollWheel:
     84#endif
    7185            Cocoa_HandleMouseEvent(_this, theEvent);
    7286            break;
     87#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     88        case NSKeyDown:
     89        case NSKeyUp:
     90        case NSFlagsChanged:
     91#else
    7392        case NSEventTypeKeyDown:
    7493        case NSEventTypeKeyUp:
    7594        case NSEventTypeFlagsChanged:
     95#endif
    7696            Cocoa_HandleKeyEvent(_this, theEvent);
    7797            break;
    7898        default:
     
    110130- (void)setAppleMenu:(NSMenu *)menu;
    111131@end
    112132
     133#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    113134@interface SDLAppDelegate : NSObject <NSApplicationDelegate> {
     135#else
     136@interface SDLAppDelegate : NSObject {
     137#endif
    114138@public
    115139    BOOL seenFirstActivate;
    116140}
     
    170194     */
    171195    for (NSWindow *window in [NSApp orderedWindows]) {
    172196        if (window != win && [window canBecomeKeyWindow]) {
    173             if (![window isOnActiveSpace]) {
    174                 continue;
     197            if ([window respondsToSelector:@selector(isOnActiveSpace)]) {
     198                if (![window isOnActiveSpace]) {
     199                    continue;
     200                }
    175201            }
    176202            [window makeKeyAndOrderFront:self];
    177203            return;
     
    357383    [windowMenu release];
    358384
    359385
     386#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    360387    /* Add the fullscreen view toggle menu option, if supported */
    361388    if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
    362389        /* Create the view menu */
     
    374401
    375402        [viewMenu release];
    376403    }
     404#endif
    377405}
    378406
    379407void
    380408Cocoa_RegisterApp(void)
     409#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    381410{ @autoreleasepool
    382411{
     412#else
     413{
     414    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     415#endif
    383416    /* This can get called more than once! Be careful what you initialize! */
    384417
    385418    if (NSApp == nil) {
     
    389422        s_bShouldHandleEventsInSDLApplication = SDL_TRUE;
    390423
    391424        if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, SDL_FALSE)) {
     425#if defined(MAC_OS_X_VERSION_10_6)
    392426            [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
     427#endif
    393428                }
    394429               
    395430        if ([NSApp mainMenu] == nil) {
     
    415450            appDelegate->seenFirstActivate = YES;
    416451        }
    417452    }
     453#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    418454}}
     455#else
     456    [pool release];
     457}
     458#endif
    419459
    420460void
    421461Cocoa_PumpEvents(_THIS)
     462#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    422463{ @autoreleasepool
    423464{
     465#else
     466{
     467    NSAutoreleasePool *pool;
     468#endif
    424469#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
    425470    /* Update activity every 30 seconds to prevent screensaver */
    426471    SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
     
    434479    }
    435480#endif
    436481
     482#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     483    pool = [[NSAutoreleasePool alloc] init];
     484#endif
    437485    for ( ; ; ) {
     486#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     487        NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
     488#else
    438489        NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
     490#endif
    439491        if ( event == nil ) {
    440492            break;
    441493        }
     
    447499        // Pass events down to SDLApplication to be handled in sendEvent:
    448500        [NSApp sendEvent:event];
    449501    }
     502#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    450503}}
     504#else
     505    [pool release];
     506}
     507#endif
    451508
    452509void
    453510Cocoa_SuspendScreenSaver(_THIS)
     511#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    454512{ @autoreleasepool
    455513{
    456514    SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
     
    477535                                           &data->screensaver_assertion);
    478536    }
    479537}}
     538#else
     539{
     540}
     541#endif
    480542
    481543#endif /* SDL_VIDEO_DRIVER_COCOA */
    482544
  • src/video/cocoa/SDL_cocoakeyboard.m

    diff -ru SDL2-2.0.8-orig/src/video/cocoa/SDL_cocoakeyboard.m SDL2-2.0.8/src/video/cocoa/SDL_cocoakeyboard.m
    old new  
    144144            NSStringFromRect(rect));
    145145
    146146#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     147#if defined(MAC_OS_X_VERSION_10_7)
    147148    if (![window respondsToSelector:@selector(convertRectToScreen:)]) {
     149#endif
    148150        rect.origin = [window convertBaseToScreen:rect.origin];
     151#if defined(MAC_OS_X_VERSION_10_7)
    149152    } else
    150153#endif
     154#endif
    151155    {
     156#if defined(MAC_OS_X_VERSION_10_7)
    152157        rect = [window convertRectToScreen:rect];
     158#endif
    153159    }
    154160
    155161    return rect;
     
    591597
    592598void
    593599Cocoa_StartTextInput(_THIS)
     600#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    594601{ @autoreleasepool
    595602{
     603#else
     604{
     605    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     606#endif
    596607    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    597608    SDL_Window *window = SDL_GetKeyboardFocus();
    598609    NSWindow *nswindow = nil;
     
    618629        [parentView addSubview: data->fieldEdit];
    619630        [nswindow makeFirstResponder: data->fieldEdit];
    620631    }
     632#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    621633}}
     634#else
     635    [pool release];
     636}
     637#endif
    622638
    623639void
    624640Cocoa_StopTextInput(_THIS)
     641#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    625642{ @autoreleasepool
     643#endif
    626644{
    627645    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    628646
    629647    if (data && data->fieldEdit) {
     648#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     649        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     650#endif
    630651        [data->fieldEdit removeFromSuperview];
    631652        [data->fieldEdit release];
    632653        data->fieldEdit = nil;
     654#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     655        [pool release];
     656#endif
    633657    }
     658#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    634659}}
     660#else
     661}
     662#endif
    635663
    636664void
    637665Cocoa_SetTextInputRect(_THIS, SDL_Rect *rect)
     
    673701    }
    674702
    675703    switch ([event type]) {
     704#if !defined(MAC_OS_X_VERSION_10_12)
     705    case NSKeyDown:
     706#else
    676707    case NSEventTypeKeyDown:
     708#endif
    677709        if (![event isARepeat]) {
    678710            /* See if we need to rebuild the keyboard layout */
    679711            UpdateKeymap(data, SDL_TRUE);
     
    697729#endif
    698730        }
    699731        break;
     732#if !defined(MAC_OS_X_VERSION_10_12)
     733    case NSKeyUp:
     734#else
    700735    case NSEventTypeKeyUp:
     736#endif
    701737        SDL_SendKeyboardKey(SDL_RELEASED, code);
    702738        break;
     739#if !defined(MAC_OS_X_VERSION_10_12)
     740    case NSFlagsChanged:
     741#else
    703742    case NSEventTypeFlagsChanged:
     743#endif
    704744        /* FIXME CW 2007-08-14: check if this whole mess that takes up half of this file is really necessary */
    705745        HandleModifiers(_this, scancode, [event modifierFlags]);
    706746        break;
  • src/video/cocoa/SDL_cocoamessagebox.m

    diff -ru SDL2-2.0.8-orig/src/video/cocoa/SDL_cocoamessagebox.m SDL2-2.0.8/src/video/cocoa/SDL_cocoamessagebox.m
    old new  
    9292/* Display a Cocoa message box */
    9393int
    9494Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
     95#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    9596{ @autoreleasepool
     97#endif
    9698{
    9799    Cocoa_RegisterApp();
    98100
     101#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     102    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     103#endif
    99104    NSAlert* alert = [[[NSAlert alloc] init] autorelease];
    100105
    101106    if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) {
     
    137142        returnValue = SDL_SetError("Did not get a valid `clicked button' id: %ld", (long)clicked);
    138143    }
    139144
     145#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     146    [pool release];
     147#endif
    140148    return returnValue;
     149#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    141150}}
     151#else
     152}
     153#endif
    142154
    143155#endif /* SDL_VIDEO_DRIVER_COCOA */
    144156
  • src/video/cocoa/SDL_cocoamodes.h

    diff -ru SDL2-2.0.8-orig/src/video/cocoa/SDL_cocoamodes.h SDL2-2.0.8/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.8-orig/src/video/cocoa/SDL_cocoamodes.m SDL2-2.0.8/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)
     
    341401{
    342402    SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
    343403    CVDisplayLinkRef link = NULL;
     404#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    344405    CGDisplayModeRef desktopmoderef;
    345406    SDL_DisplayMode desktopmode;
     407#endif
    346408    CFArrayRef modes;
    347409
    348410    CVDisplayLinkCreateWithCGDisplay(data->display, &link);
    349411
     412#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    350413    desktopmoderef = CGDisplayCopyDisplayMode(data->display);
    351414
    352415    /* CopyAllDisplayModes won't always contain the desktop display mode (if
     
    363426    } else {
    364427        CGDisplayModeRelease(desktopmoderef);
    365428    }
     429#endif
    366430
     431#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    367432    modes = CGDisplayCopyAllDisplayModes(data->display, NULL);
     433#else
     434    modes = CGDisplayAvailableModes(data->display);
     435#endif
    368436
    369437    if (modes) {
    370438        CFIndex i;
    371439        const CFIndex count = CFArrayGetCount(modes);
    372440
    373441        for (i = 0; i < count; i++) {
     442#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    374443            CGDisplayModeRef moderef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
     444#else
     445            const void *moderef = CFArrayGetValueAtIndex(modes, i);
     446#endif
    375447            SDL_DisplayMode mode;
    376448
    377449            if (GetDisplayMode(_this, moderef, link, &mode)) {
    378450                if (SDL_AddDisplayMode(display, &mode)) {
     451                #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    379452                    CGDisplayModeRetain(moderef);
     453                #endif
    380454                } else {
    381455                    SDL_free(mode.driverdata);
    382456                }
     
    404478
    405479    if (data == display->desktop_mode.driverdata) {
    406480        /* Restoring desktop mode */
     481#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    407482        CGDisplaySetDisplayMode(displaydata->display, data->moderef, NULL);
     483#else
     484        CGDisplaySwitchToMode(displaydata->display, data->moderef);
     485#endif
    408486
    409487        if (CGDisplayIsMain(displaydata->display)) {
    410488            CGReleaseAllDisplays();
     
    429507        }
    430508
    431509        /* Do the physical switch */
     510#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    432511        result = CGDisplaySetDisplayMode(displaydata->display, data->moderef, NULL);
     512#else
     513        result = CGDisplaySwitchToMode(displaydata->display, data->moderef);
     514#endif
    433515        if (result != kCGErrorSuccess) {
    434516            CG_SetError("CGDisplaySwitchToMode()", result);
    435517            goto ERR_NO_SWITCH;
     
    474556        }
    475557
    476558        mode = (SDL_DisplayModeData *) display->desktop_mode.driverdata;
     559        #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    477560        CGDisplayModeRelease(mode->moderef);
     561        #endif
    478562
    479563        for (j = 0; j < display->num_display_modes; j++) {
    480564            mode = (SDL_DisplayModeData*) display->display_modes[j].driverdata;
     565        #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    481566            CGDisplayModeRelease(mode->moderef);
     567        #endif
    482568        }
    483569
    484570    }
  • src/video/cocoa/SDL_cocoamouse.m

    diff -ru SDL2-2.0.8-orig/src/video/cocoa/SDL_cocoamouse.m SDL2-2.0.8/src/video/cocoa/SDL_cocoamouse.m
    old new  
    6767
    6868static SDL_Cursor *
    6969Cocoa_CreateDefaultCursor()
     70#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    7071{ @autoreleasepool
    7172{
     73#else
     74{
     75    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     76#endif
    7277    NSCursor *nscursor;
    7378    SDL_Cursor *cursor = NULL;
    7479
     
    8287        }
    8388    }
    8489
     90#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     91    [pool release];
     92#endif
    8593    return cursor;
     94#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    8695}}
     96#else
     97}
     98#endif
    8799
    88100static SDL_Cursor *
    89101Cocoa_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
     102#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    90103{ @autoreleasepool
    91104{
     105#else
     106{
     107    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     108#endif
    92109    NSImage *nsimage;
    93110    NSCursor *nscursor = NULL;
    94111    SDL_Cursor *cursor = NULL;
     
    107124        }
    108125    }
    109126
     127#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     128    [pool release];
     129#endif
    110130    return cursor;
     131#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    111132}}
     133#else
     134}
     135#endif
    112136
    113137static SDL_Cursor *
    114138Cocoa_CreateSystemCursor(SDL_SystemCursor id)
     139#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    115140{ @autoreleasepool
    116141{
     142#else
     143{
     144    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     145#endif
    117146    NSCursor *nscursor = NULL;
    118147    SDL_Cursor *cursor = NULL;
    119148
     
    166195        }
    167196    }
    168197
     198#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     199    [pool release];
     200#endif
    169201    return cursor;
     202#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    170203}}
     204#else
     205}
     206#endif
    171207
    172208static void
    173209Cocoa_FreeCursor(SDL_Cursor * cursor)
     210#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    174211{ @autoreleasepool
    175212{
     213#else
     214{
     215    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     216#endif
    176217    NSCursor *nscursor = (NSCursor *)cursor->driverdata;
    177218
    178219    [nscursor release];
    179220    SDL_free(cursor);
     221#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    180222}}
     223#else
     224    [pool release];
     225}
     226#endif
    181227
    182228static int
    183229Cocoa_ShowCursor(SDL_Cursor * cursor)
     230#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    184231{ @autoreleasepool
    185232{
     233#else
     234{
     235    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     236#endif
    186237    SDL_VideoDevice *device = SDL_GetVideoDevice();
    187238    SDL_Window *window = (device ? device->windows : NULL);
    188239    for (; window != NULL; window = window->next) {
     
    193244                                                waitUntilDone:NO];
    194245        }
    195246    }
     247#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     248    [pool release];
     249#endif
    196250    return 0;
     251#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    197252}}
     253#else
     254}
     255#endif
    198256
    199257static SDL_Window *
    200258SDL_FindWindowAtPoint(const int x, const int y)
     
    364422Cocoa_HandleMouseEvent(_THIS, NSEvent *event)
    365423{
    366424    switch ([event type]) {
     425#if !defined(MAC_OS_X_VERSION_10_12)
     426        case NSMouseMoved:
     427        case NSLeftMouseDragged:
     428        case NSRightMouseDragged:
     429        case NSOtherMouseDragged:
     430#else
    367431        case NSEventTypeMouseMoved:
    368432        case NSEventTypeLeftMouseDragged:
    369433        case NSEventTypeRightMouseDragged:
    370434        case NSEventTypeOtherMouseDragged:
     435#endif
    371436            break;
    372437
    373438        default:
  • src/video/cocoa/SDL_cocoaopengl.m

    diff -ru SDL2-2.0.8-orig/src/video/cocoa/SDL_cocoaopengl.m SDL2-2.0.8/src/video/cocoa/SDL_cocoaopengl.m
    old new  
    151151
    152152SDL_GLContext
    153153Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
     154#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    154155{ @autoreleasepool
    155156{
     157#else
     158{
     159    NSAutoreleasePool *pool;
     160#endif
    156161    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    157162    SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
     163#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1670
    158164    SDL_bool lion_or_later = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6;
     165#else
     166    SDL_bool lion_or_later = SDL_FALSE;
     167#endif
    159168    NSOpenGLPixelFormatAttribute attr[32];
    160169    NSOpenGLPixelFormat *fmt;
    161170    SDLOpenGLContext *context;
     
    195204
    196205    attr[i++] = NSOpenGLPFAAllowOfflineRenderers;
    197206
     207#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     208    pool = [[NSAutoreleasePool alloc] init];
     209#endif
    198210    /* specify a profile if we're on Lion (10.7) or later. */
     211#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    199212    if (lion_or_later) {
    200213        NSOpenGLPixelFormatAttribute profile = NSOpenGLProfileVersionLegacy;
    201214        if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) {
     
    204217        attr[i++] = NSOpenGLPFAOpenGLProfile;
    205218        attr[i++] = profile;
    206219    }
     220#endif
    207221
    208222    attr[i++] = NSOpenGLPFAColorSize;
    209223    attr[i++] = SDL_BYTESPERPIXEL(display->current_mode.format)*8;
     
    259273    fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
    260274    if (fmt == nil) {
    261275        SDL_SetError("Failed creating OpenGL pixel format");
     276#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     277        [pool release];
     278#endif
    262279        return NULL;
    263280    }
    264281
     
    272289
    273290    if (context == nil) {
    274291        SDL_SetError("Failed creating OpenGL context");
     292#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     293        [pool release];
     294#endif
    275295        return NULL;
    276296    }
    277297
    278298    if ( Cocoa_GL_MakeCurrent(_this, window, context) < 0 ) {
    279299        Cocoa_GL_DeleteContext(_this, context);
    280300        SDL_SetError("Failed making OpenGL context current");
     301#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     302        [pool release];
     303#endif
    281304        return NULL;
    282305    }
    283306
     
    292315        if (!glGetStringFunc) {
    293316            Cocoa_GL_DeleteContext(_this, context);
    294317            SDL_SetError ("Failed getting OpenGL glGetString entry point");
     318#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     319            [pool release];
     320#endif
    295321            return NULL;
    296322        }
    297323
     
    299325        if (glversion == NULL) {
    300326            Cocoa_GL_DeleteContext(_this, context);
    301327            SDL_SetError ("Failed getting OpenGL context version");
     328#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     329            [pool release];
     330#endif
    302331            return NULL;
    303332        }
    304333
    305334        if (SDL_sscanf(glversion, "%d.%d", &glversion_major, &glversion_minor) != 2) {
    306335            Cocoa_GL_DeleteContext(_this, context);
    307336            SDL_SetError ("Failed parsing OpenGL context version");
     337#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     338            [pool release];
     339#endif
    308340            return NULL;
    309341        }
    310342
     
    312344           ((glversion_major == _this->gl_config.major_version) && (glversion_minor < _this->gl_config.minor_version))) {
    313345            Cocoa_GL_DeleteContext(_this, context);
    314346            SDL_SetError ("Failed creating OpenGL context at version requested");
     347#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     348            [pool release];
     349#endif
    315350            return NULL;
    316351        }
    317352
     
    321356        /*_this->gl_config.major_version = glversion_major;*/
    322357        /*_this->gl_config.minor_version = glversion_minor;*/
    323358    }
     359#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     360    [pool release];
     361#endif
    324362    return context;
     363#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     364}
     365#else
    325366}}
     367#endif
    326368
    327369int
    328370Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
     371#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    329372{ @autoreleasepool
    330373{
     374#else
     375{
     376    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     377#endif
    331378    if (context) {
    332379        SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context;
    333380        [nscontext setWindow:window];
     
    337384        [NSOpenGLContext clearCurrentContext];
    338385    }
    339386
     387#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     388    [pool release];
     389#endif
    340390    return 0;
     391#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    341392}}
     393#else
     394}
     395#endif
    342396
    343397void
    344398Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
     
    349403
    350404    /* This gives us the correct viewport for a Retina-enabled view, only
    351405     * supported on 10.7+. */
     406#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    352407    if ([contentView respondsToSelector:@selector(convertRectToBacking:)]) {
    353408        viewport = [contentView convertRectToBacking:viewport];
    354409    }
     410#endif
    355411
    356412    if (w) {
    357413        *w = viewport.size.width;
     
    364420
    365421int
    366422Cocoa_GL_SetSwapInterval(_THIS, int interval)
     423#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    367424{ @autoreleasepool
     425#endif
    368426{
    369427    NSOpenGLContext *nscontext;
    370428    GLint value;
     
    373431    if (interval < 0) {  /* no extension for this on Mac OS X at the moment. */
    374432        return SDL_SetError("Late swap tearing currently unsupported");
    375433    }
     434#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     435    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     436#endif
    376437
    377438    nscontext = (NSOpenGLContext*)SDL_GL_GetCurrentContext();
    378439    if (nscontext != nil) {
     
    383444        status = SDL_SetError("No current OpenGL context");
    384445    }
    385446
     447#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     448    [pool release];
     449#endif
    386450    return status;
     451#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    387452}}
     453#else
     454}
     455#endif
    388456
    389457int
    390458Cocoa_GL_GetSwapInterval(_THIS)
     459#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    391460{ @autoreleasepool
    392461{
     462#else
     463{
     464    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     465#endif
    393466    NSOpenGLContext *nscontext;
    394467    GLint value;
    395468    int status = 0;
     
    400473        status = (int)value;
    401474    }
    402475
     476#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     477    [pool release];
     478#endif
    403479    return status;
     480#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    404481}}
     482#else
     483}
     484#endif
    405485
    406486int
    407487Cocoa_GL_SwapWindow(_THIS, SDL_Window * window)
     488#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    408489{ @autoreleasepool
    409490{
     491#else
     492{
     493    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     494#endif
    410495    SDLOpenGLContext* nscontext = (SDLOpenGLContext*)SDL_GL_GetCurrentContext();
    411496    [nscontext flushBuffer];
    412497    [nscontext updateIfNeeded];
     498#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     499    [pool release];
     500#endif
    413501    return 0;
     502#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    414503}}
     504#else
     505}
     506#endif
    415507
    416508void
    417509Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context)
     510#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    418511{ @autoreleasepool
    419512{
     513#else
     514{
     515    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     516#endif
    420517    SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context;
    421518
    422519    [nscontext setWindow:NULL];
    423520    [nscontext release];
     521#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    424522}}
     523#else
     524    [pool release];
     525}
     526#endif
    425527
    426528#endif /* SDL_VIDEO_OPENGL_CGL */
    427529
  • src/video/cocoa/SDL_cocoashape.m

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

    diff -ru SDL2-2.0.8-orig/src/video/cocoa/SDL_cocoavideo.h SDL2-2.0.8/src/video/cocoa/SDL_cocoavideo.h
    old new  
    5858DECLARE_EVENT(FlagsChanged);
    5959#undef DECLARE_EVENT
    6060
     61#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    6162static const NSEventMask NSEventMaskAny = NSAnyEventMask;
     63#endif
    6264
    6365#define DECLARE_MODIFIER_FLAG(name) static const NSUInteger NSEventModifierFlag##name = NS##name##KeyMask
    6466DECLARE_MODIFIER_FLAG(Shift);
     
    7981DECLARE_WINDOW_MASK(Resizable);
    8082DECLARE_WINDOW_MASK(TexturedBackground);
    8183DECLARE_WINDOW_MASK(UnifiedTitleAndToolbar);
     84#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    8285DECLARE_WINDOW_MASK(FullScreen);
     86#endif
    8387/*DECLARE_WINDOW_MASK(FullSizeContentView);*/ /* Not used, fails compile on older SDKs */
    8488static const unsigned int NSWindowStyleMaskUtilityWindow = NSUtilityWindowMask;
    8589static const unsigned int NSWindowStyleMaskDocModalWindow = NSDocModalWindowMask;
  • src/video/cocoa/SDL_cocoavideo.m

    diff -ru SDL2-2.0.8-orig/src/video/cocoa/SDL_cocoavideo.m SDL2-2.0.8/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"
     
    169176    Cocoa_InitKeyboard(_this);
    170177    Cocoa_InitMouse(_this);
    171178
     179#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    172180    data->allow_spaces = ((floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) && SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_TRUE));
    173181
    174182    /* The IOPM assertion API can disable the screensaver as of 10.7. */
    175183    data->screensaver_use_iopm = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6;
     184#else
     185    data->allow_spaces = 0;
     186    data->screensaver_use_iopm = 0;
     187#endif
    176188
    177189    return 0;
    178190}
  • src/video/cocoa/SDL_cocoawindow.h

    diff -ru SDL2-2.0.8-orig/src/video/cocoa/SDL_cocoawindow.h SDL2-2.0.8/src/video/cocoa/SDL_cocoawindow.h
    old new  
    3939    PENDING_OPERATION_MINIMIZE
    4040} PendingWindowOperation;
    4141
     42#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    4243@interface Cocoa_WindowListener : NSResponder <NSWindowDelegate> {
     44#else
     45@interface Cocoa_WindowListener : NSResponder {
     46#endif
    4347    SDL_WindowData *_data;
    4448    BOOL observingVisible;
    4549    BOOL wasCtrlLeft;
     
    7983-(void) windowDidEnterFullScreen:(NSNotification *) aNotification;
    8084-(void) windowWillExitFullScreen:(NSNotification *) aNotification;
    8185-(void) windowDidExitFullScreen:(NSNotification *) aNotification;
     86#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    8287-(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions;
     88#endif
    8389
    8490/* See if event is in a drag area, toggle on window dragging. */
    8591-(BOOL) processHitTest:(NSEvent *)theEvent;
     
    102108-(void) touchesCancelledWithEvent:(NSEvent *) theEvent;
    103109
    104110/* Touch event handling */
     111#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    105112-(void) handleTouches:(NSTouchPhase) phase withEvent:(NSEvent*) theEvent;
     113#else
     114typedef enum {
     115    COCOA_TOUCH_DOWN,
     116    COCOA_TOUCH_UP,
     117    COCOA_TOUCH_MOVE,
     118    COCOA_TOUCH_CANCELLED
     119} cocoaTouchType;
     120-(void) handleTouches:(cocoaTouchType)type withEvent:(NSEvent*) event;
     121#endif
    106122
    107123@end
    108124/* *INDENT-ON* */
  • src/video/cocoa/SDL_cocoawindow.m

    diff -ru SDL2-2.0.8-orig/src/video/cocoa/SDL_cocoawindow.m SDL2-2.0.8/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"
     
    5557#define FULLSCREEN_MASK (SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN)
    5658
    5759
     60#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     61@interface SDLWindow : NSWindow
     62#else
    5863@interface SDLWindow : NSWindow <NSDraggingDestination>
     64#endif
    5965/* These are needed for borderless/fullscreen windows */
    6066- (BOOL)canBecomeKeyWindow;
    6167- (BOOL)canBecomeMainWindow;
     
    137143}
    138144
    139145- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
     146#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    140147{ @autoreleasepool
    141148{
     149#else
     150{
     151    NSAutoreleasePool *pool;
     152#endif
    142153    NSPasteboard *pasteboard = [sender draggingPasteboard];
    143154    NSArray *types = [NSArray arrayWithObject:NSFilenamesPboardType];
    144155    NSString *desiredType = [pasteboard availableTypeFromArray:types];
     
    153164        return NO;
    154165    }
    155166
     167#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     168    pool = [[NSAutoreleasePool alloc] init];
     169#endif
     170
    156171    SDL_assert([desiredType isEqualToString:NSFilenamesPboardType]);
    157172    NSArray *array = [pasteboard propertyListForType:@"NSFilenamesPboardType"];
    158173
    159174    for (NSString *path in array) {
    160175        NSURL *fileURL = [NSURL fileURLWithPath:path];
     176#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    161177        NSNumber *isAlias = nil;
    162178
    163179        [fileURL getResourceValue:&isAlias forKey:NSURLIsAliasFileKey error:nil];
     
    178194                }
    179195            }
    180196        }
     197#endif
    181198
    182199        if (!SDL_SendDropFile(sdlwindow, [[fileURL path] UTF8String])) {
     200#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     201            [pool release];
     202#endif
    183203            return NO;
    184204        }
    185205    }
    186206
     207#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     208    [pool release];
     209#endif
    187210    SDL_SendDropComplete(sdlwindow);
    188211    return YES;
     212#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     213}
     214#else
    189215}}
     216#endif
    190217
    191218- (BOOL)wantsPeriodicDraggingUpdates
    192219{
     
    314341        [center addObserver:self selector:@selector(windowDidDeminiaturize:) name:NSWindowDidDeminiaturizeNotification object:window];
    315342        [center addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:window];
    316343        [center addObserver:self selector:@selector(windowDidResignKey:) name:NSWindowDidResignKeyNotification object:window];
     344#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    317345        [center addObserver:self selector:@selector(windowDidChangeBackingProperties:) name:NSWindowDidChangeBackingPropertiesNotification object:window];
    318346        [center addObserver:self selector:@selector(windowWillEnterFullScreen:) name:NSWindowWillEnterFullScreenNotification object:window];
    319347        [center addObserver:self selector:@selector(windowDidEnterFullScreen:) name:NSWindowDidEnterFullScreenNotification object:window];
    320348        [center addObserver:self selector:@selector(windowWillExitFullScreen:) name:NSWindowWillExitFullScreenNotification object:window];
    321349        [center addObserver:self selector:@selector(windowDidExitFullScreen:) name:NSWindowDidExitFullScreenNotification object:window];
     350#endif
    322351        [center addObserver:self selector:@selector(windowDidFailToEnterFullScreen:) name:@"NSWindowDidFailToEnterFullScreenNotification" object:window];
    323352        [center addObserver:self selector:@selector(windowDidFailToExitFullScreen:) name:@"NSWindowDidFailToExitFullScreenNotification" object:window];
    324353    } else {
     
    409438    inFullscreenTransition = YES;
    410439
    411440    /* you need to be FullScreenPrimary, or toggleFullScreen doesn't work. Unset it again in windowDidExitFullScreen. */
     441#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    412442    [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
     443#endif
    413444    [nswindow performSelectorOnMainThread: @selector(toggleFullScreen:) withObject:nswindow waitUntilDone:NO];
    414445    return YES;
    415446}
     
    445476        [center removeObserver:self name:NSWindowDidDeminiaturizeNotification object:window];
    446477        [center removeObserver:self name:NSWindowDidBecomeKeyNotification object:window];
    447478        [center removeObserver:self name:NSWindowDidResignKeyNotification object:window];
     479#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    448480        [center removeObserver:self name:NSWindowDidChangeBackingPropertiesNotification object:window];
    449481        [center removeObserver:self name:NSWindowWillEnterFullScreenNotification object:window];
    450482        [center removeObserver:self name:NSWindowDidEnterFullScreenNotification object:window];
    451483        [center removeObserver:self name:NSWindowWillExitFullScreenNotification object:window];
    452484        [center removeObserver:self name:NSWindowDidExitFullScreenNotification object:window];
     485#endif
    453486        [center removeObserver:self name:@"NSWindowDidFailToEnterFullScreenNotification" object:window];
    454487        [center removeObserver:self name:@"NSWindowDidFailToExitFullScreenNotification" object:window];
    455488    } else {
     
    629662        [NSMenu setMenuBarVisible:NO];
    630663    }
    631664
     665#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    632666    const unsigned int newflags = [NSEvent modifierFlags] & NSEventModifierFlagCapsLock;
    633667    _data->videodata->modifierFlags = (_data->videodata->modifierFlags & ~NSEventModifierFlagCapsLock) | newflags;
    634668    SDL_ToggleModState(KMOD_CAPS, newflags != 0);
     669#endif
    635670}
    636671
    637672- (void)windowDidResignKey:(NSNotification *)aNotification
     
    658693
    659694- (void)windowDidChangeBackingProperties:(NSNotification *)aNotification
    660695{
     696#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    661697    NSNumber *oldscale = [[aNotification userInfo] objectForKey:NSBackingPropertyOldScaleFactorKey];
    662698
    663699    if (inFullscreenTransition) {
     
    670706        _data->window->h = 0;
    671707        [self windowDidResize:aNotification];
    672708    }
     709#endif
    673710}
    674711
    675712- (void)windowWillEnterFullScreen:(NSNotification *)aNotification
     
    778815        [nswindow miniaturize:nil];
    779816    } else {
    780817        /* Adjust the fullscreen toggle button and readd menu now that we're here. */
     818#if MAC_OS_X_VERSION_MIN_REQUIRED > 1070
    781819        if (window->flags & SDL_WINDOW_RESIZABLE) {
    782820            /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
    783821            [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
    784822        } else {
    785823            [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged];
    786824        }
     825#endif
    787826        [NSMenu setMenuBarVisible:YES];
    788827
    789828        pendingWindowOperation = PENDING_OPERATION_NONE;
     
    826865    }
    827866}
    828867
     868#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    829869-(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions
    830870{
    831871    if ((_data->window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
     
    834874        return proposedOptions;
    835875    }
    836876}
     877#endif
    837878
    838879
    839880/* We'll respond to key events by doing nothing so we don't beep.
     
    10601101
    10611102- (void)touchesBeganWithEvent:(NSEvent *) theEvent
    10621103{
     1104#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    10631105    NSSet *touches = [theEvent touchesMatchingPhase:NSTouchPhaseAny inView:nil];
    10641106    int existingTouchCount = 0;
    10651107
     
    10801122
    10811123    DLog("Began Fingers: %lu .. existing: %d", (unsigned long)[touches count], existingTouchCount);
    10821124    [self handleTouches:NSTouchPhaseBegan withEvent:theEvent];
     1125#endif
    10831126}
    10841127
    10851128- (void)touchesMovedWithEvent:(NSEvent *) theEvent
    10861129{
     1130#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    10871131    [self handleTouches:NSTouchPhaseMoved withEvent:theEvent];
     1132#endif
    10881133}
    10891134
    10901135- (void)touchesEndedWithEvent:(NSEvent *) theEvent
    10911136{
     1137#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    10921138    [self handleTouches:NSTouchPhaseEnded withEvent:theEvent];
     1139#endif
    10931140}
    10941141
    10951142- (void)touchesCancelledWithEvent:(NSEvent *) theEvent
    10961143{
     1144#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    10971145    [self handleTouches:NSTouchPhaseCancelled withEvent:theEvent];
     1146#endif
    10981147}
    10991148
     1149#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
     1150#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
    11001151- (void)handleTouches:(NSTouchPhase) phase withEvent:(NSEvent *) theEvent
     1152#else
     1153- (void)handleTouches:(cocoaTouchType)type withEvent:(NSEvent *)event
     1154#endif
    11011155{
     1156#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1157    NSSet *touches = 0;
     1158    NSEnumerator *enumerator;
     1159    NSTouch *touch;
     1160
     1161    switch (type) {
     1162        case COCOA_TOUCH_DOWN:
     1163            touches = [event touchesMatchingPhase:NSTouchPhaseBegan inView:nil];
     1164            break;
     1165        case COCOA_TOUCH_UP:
     1166            touches = [event touchesMatchingPhase:NSTouchPhaseEnded inView:nil];
     1167            break;
     1168        case COCOA_TOUCH_CANCELLED:
     1169            touches = [event touchesMatchingPhase:NSTouchPhaseCancelled inView:nil];
     1170            break;
     1171        case COCOA_TOUCH_MOVE:
     1172            touches = [event touchesMatchingPhase:NSTouchPhaseMoved inView:nil];
     1173            break;
     1174    }
     1175
     1176    enumerator = [touches objectEnumerator];
     1177    touch = (NSTouch*)[enumerator nextObject];
     1178    while (touch) {
     1179        const SDL_TouchID touchId = (SDL_TouchID)(intptr_t)[touch device];
     1180        if (!SDL_GetTouch(touchId)) {
     1181            if (SDL_AddTouch(touchId, "") < 0) {
     1182                return;
     1183            }
     1184        }
     1185
     1186        const SDL_FingerID fingerId = (SDL_FingerID)(intptr_t)[touch identity];
     1187        float x = [touch normalizedPosition].x;
     1188        float y = [touch normalizedPosition].y;
     1189        /* Make the origin the upper left instead of the lower left */
     1190        y = 1.0f - y;
     1191
     1192        switch (type) {
     1193        case COCOA_TOUCH_DOWN:
     1194            SDL_SendTouch(touchId, fingerId, SDL_TRUE, x, y, 1.0f);
     1195            break;
     1196        case COCOA_TOUCH_UP:
     1197        case COCOA_TOUCH_CANCELLED:
     1198            SDL_SendTouch(touchId, fingerId, SDL_FALSE, x, y, 1.0f);
     1199            break;
     1200        case COCOA_TOUCH_MOVE:
     1201            SDL_SendTouchMotion(touchId, fingerId, x, y, 1.0f);
     1202            break;
     1203        }
     1204
     1205        touch = (NSTouch*)[enumerator nextObject];
     1206     }
     1207#else
    11021208    NSSet *touches = [theEvent touchesMatchingPhase:phase inView:nil];
    11031209
    11041210    for (NSTouch *touch in touches) {
     
    11281234            break;
    11291235        }
    11301236    }
     1237#endif
    11311238}
     1239#endif
    11321240
    11331241@end
    11341242
     
    12001308
    12011309static int
    12021310SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created)
     1311#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    12031312{ @autoreleasepool
    12041313{
     1314#else
     1315{
     1316    NSAutoreleasePool *pool;
     1317#endif
    12051318    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
    12061319    SDL_WindowData *data;
    12071320
     
    12161329    data->videodata = videodata;
    12171330    data->nscontexts = [[NSMutableArray alloc] init];
    12181331
     1332#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1333    pool = [[NSAutoreleasePool alloc] init];
     1334#endif
    12191335    /* Create an event listener for the window */
    12201336    data->listener = [[Cocoa_WindowListener alloc] init];
    12211337
     
    12761392     */
    12771393    [nswindow setOneShot:NO];
    12781394
     1395#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1396    [pool release];
     1397#endif
    12791398    /* All done! */
    12801399    window->driverdata = data;
    12811400    return 0;
     1401#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1402}
     1403#else
    12821404}}
     1405#endif
    12831406
    12841407int
    12851408Cocoa_CreateWindow(_THIS, SDL_Window * window)
     1409#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    12861410{ @autoreleasepool
    12871411{
     1412#else
     1413{
     1414    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1415#endif
    12881416    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
    12891417    NSWindow *nswindow;
    12901418    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
     
    13241452    }
    13251453
    13261454    if (videodata->allow_spaces) {
     1455#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    13271456        SDL_assert(floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6);
    13281457        SDL_assert([nswindow respondsToSelector:@selector(toggleFullScreen:)]);
    13291458        /* we put FULLSCREEN_DESKTOP windows in their own Space, without a toggle button or menubar, later */
     
    13311460            /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
    13321461            [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
    13331462        }
     1463#endif
    13341464    }
    13351465
    13361466    /* Create a default view for this window */
     
    13591489
    13601490    if (SetupWindowData(_this, window, nswindow, SDL_TRUE) < 0) {
    13611491        [nswindow release];
     1492#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1493        [pool release];
     1494#endif
    13621495        return -1;
    13631496    }
    13641497
    13651498    if (!(window->flags & SDL_WINDOW_OPENGL)) {
     1499#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1500        [pool release];
     1501#endif
    13661502        return 0;
    13671503    }
    13681504   
     
    13721508#if SDL_VIDEO_OPENGL_EGL
    13731509        if (Cocoa_GLES_SetupWindow(_this, window) < 0) {
    13741510            Cocoa_DestroyWindow(_this, window);
     1511#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1512            [pool release];
     1513#endif
    13751514            return -1;
    13761515        }
     1516#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1517        [pool release];
     1518#endif
    13771519        return 0;
    13781520#else
     1521#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1522        [pool release];
     1523#endif
    13791524        return SDL_SetError("Could not create GLES window surface (EGL support not configured)");
    13801525#endif /* SDL_VIDEO_OPENGL_EGL */
    13811526    }
    13821527#endif /* SDL_VIDEO_OPENGL_ES2 */
     1528#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1529    [pool release];
     1530#endif
    13831531    return 0;
     1532#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13841533}}
     1534#else
     1535}
     1536#endif
    13851537
    13861538int
    13871539Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
     1540#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13881541{ @autoreleasepool
    13891542{
     1543#else
     1544{
     1545    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1546#endif
    13901547    NSWindow *nswindow = (NSWindow *) data;
    13911548    NSString *title;
    13921549
     
    13971554    }
    13981555
    13991556    return SetupWindowData(_this, window, nswindow, SDL_FALSE);
     1557#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14001558}}
     1559#else
     1560    [pool release];
     1561}
     1562#endif
    14011563
    14021564void
    14031565Cocoa_SetWindowTitle(_THIS, SDL_Window * window)
     1566#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14041567{ @autoreleasepool
    14051568{
     1569#else
     1570{
     1571    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1572#endif
    14061573    const char *title = window->title ? window->title : "";
    14071574    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
    14081575    NSString *string = [[NSString alloc] initWithUTF8String:title];
    14091576    [nswindow setTitle:string];
    14101577    [string release];
     1578#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14111579}}
     1580#else
     1581    [pool release];
     1582}
     1583#endif
    14121584
    14131585void
    14141586Cocoa_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
     1587#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14151588{ @autoreleasepool
    14161589{
     1590#else
     1591{
     1592    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1593#endif
    14171594    NSImage *nsimage = Cocoa_CreateImage(icon);
    14181595
    14191596    if (nsimage) {
    14201597        [NSApp setApplicationIconImage:nsimage];
    14211598    }
     1599#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14221600}}
     1601#else
     1602    [pool release];
     1603}
     1604#endif
    14231605
    14241606void
    14251607Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
     1608#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14261609{ @autoreleasepool
    14271610{
     1611#else
     1612{
     1613    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1614#endif
    14281615    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    14291616    NSWindow *nswindow = windata->nswindow;
    14301617    NSRect rect;
     
    14421629    s_moveHack = moveHack;
    14431630
    14441631    ScheduleContextUpdates(windata);
     1632#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14451633}}
     1634#else
     1635    [pool release];
     1636}
     1637#endif
    14461638
    14471639void
    14481640Cocoa_SetWindowSize(_THIS, SDL_Window * window)
     1641#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14491642{ @autoreleasepool
    14501643{
     1644#else
     1645{
     1646    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1647#endif
    14511648    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    14521649    NSWindow *nswindow = windata->nswindow;
    14531650    NSRect rect;
     
    14691666    s_moveHack = moveHack;
    14701667
    14711668    ScheduleContextUpdates(windata);
     1669#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14721670}}
     1671#else
     1672    [pool release];
     1673}
     1674#endif
    14731675
    14741676void
    14751677Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window)
     1678#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14761679{ @autoreleasepool
    14771680{
     1681#else
     1682{
     1683    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1684#endif
    14781685    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    14791686
    14801687    NSSize minSize;
     
    14821689    minSize.height = window->min_h;
    14831690
    14841691    [windata->nswindow setContentMinSize:minSize];
     1692#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14851693}}
     1694#else
     1695    [pool release];
     1696}
     1697#endif
    14861698
    14871699void
    14881700Cocoa_SetWindowMaximumSize(_THIS, SDL_Window * window)
     1701#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14891702{ @autoreleasepool
    14901703{
     1704#else
     1705{
     1706    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1707#endif
    14911708    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    14921709
    14931710    NSSize maxSize;
     
    14951712    maxSize.height = window->max_h;
    14961713
    14971714    [windata->nswindow setContentMaxSize:maxSize];
     1715#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14981716}}
     1717#else
     1718    [pool release];
     1719}
     1720#endif
    14991721
    15001722void
    15011723Cocoa_ShowWindow(_THIS, SDL_Window * window)
     1724#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15021725{ @autoreleasepool
    15031726{
     1727#else
     1728{
     1729    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1730#endif
    15041731    SDL_WindowData *windowData = ((SDL_WindowData *) window->driverdata);
    15051732    NSWindow *nswindow = windowData->nswindow;
    15061733
     
    15091736        [nswindow makeKeyAndOrderFront:nil];
    15101737        [windowData->listener resumeVisibleObservation];
    15111738    }
     1739#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15121740}}
     1741#else
     1742    [pool release];
     1743}
     1744#endif
    15131745
    15141746void
    15151747Cocoa_HideWindow(_THIS, SDL_Window * window)
     1748#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15161749{ @autoreleasepool
    15171750{
     1751#else
     1752{
     1753    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1754#endif
    15181755    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
    15191756
    15201757    [nswindow orderOut:nil];
     1758#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15211759}}
     1760#else
     1761    [pool release];
     1762}
     1763#endif
    15221764
    15231765void
    15241766Cocoa_RaiseWindow(_THIS, SDL_Window * window)
     1767#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15251768{ @autoreleasepool
    15261769{
     1770#else
     1771{
     1772    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1773#endif
    15271774    SDL_WindowData *windowData = ((SDL_WindowData *) window->driverdata);
    15281775    NSWindow *nswindow = windowData->nswindow;
    15291776
     
    15361783        [nswindow makeKeyAndOrderFront:nil];
    15371784    }
    15381785    [windowData->listener resumeVisibleObservation];
     1786#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15391787}}
     1788#else
     1789    [pool release];
     1790}
     1791#endif
    15401792
    15411793void
    15421794Cocoa_MaximizeWindow(_THIS, SDL_Window * window)
     1795#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15431796{ @autoreleasepool
    15441797{
     1798#else
     1799{
     1800    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1801#endif
    15451802    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    15461803    NSWindow *nswindow = windata->nswindow;
    15471804
    15481805    [nswindow zoom:nil];
    15491806
    15501807    ScheduleContextUpdates(windata);
     1808#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15511809}}
     1810#else
     1811    [pool release];
     1812}
     1813#endif
    15521814
    15531815void
    15541816Cocoa_MinimizeWindow(_THIS, SDL_Window * window)
     1817#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15551818{ @autoreleasepool
    15561819{
     1820#else
     1821{
     1822    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1823#endif
    15571824    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    15581825    NSWindow *nswindow = data->nswindow;
    15591826
     
    15621829    } else {
    15631830        [nswindow miniaturize:nil];
    15641831    }
     1832#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15651833}}
     1834#else
     1835    [pool release];
     1836}
     1837#endif
    15661838
    15671839void
    15681840Cocoa_RestoreWindow(_THIS, SDL_Window * window)
     1841#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15691842{ @autoreleasepool
    15701843{
     1844#else
     1845{
     1846    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1847#endif
    15711848    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
    15721849
    15731850    if ([nswindow isMiniaturized]) {
     
    15751852    } else if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) {
    15761853        [nswindow zoom:nil];
    15771854    }
     1855#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15781856}}
     1857#else
     1858    [pool release];
     1859}
     1860#endif
    15791861
    15801862void
    15811863Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
     1864#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15821865{ @autoreleasepool
    15831866{
     1867#else
     1868{
     1869    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1870#endif
    15841871    if (SetWindowStyle(window, GetWindowStyle(window))) {
    15851872        if (bordered) {
    15861873            Cocoa_SetWindowTitle(_this, window);  /* this got blanked out. */
    15871874        }
    15881875    }
     1876#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15891877}}
     1878#else
     1879    [pool release];
     1880}
     1881#endif
     1882
    15901883
    15911884void
    15921885Cocoa_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable)
     1886#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15931887{ @autoreleasepool
    15941888{
     1889#else
     1890{
     1891    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1892#endif
    15951893    /* Don't set this if we're in a space!
    15961894     * The window will get permanently stuck if resizable is false.
    15971895     * -flibit
     
    16011899    if (![listener isInFullscreenSpace]) {
    16021900        SetWindowStyle(window, GetWindowStyle(window));
    16031901    }
     1902#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    16041903}}
     1904#else
     1905    [pool release];
     1906}
     1907#endif
     1908
    16051909
    16061910void
    16071911Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
     1912#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    16081913{ @autoreleasepool
    16091914{
     1915#else
     1916{
     1917    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1918#endif
    16101919    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    16111920    NSWindow *nswindow = data->nswindow;
    16121921    NSRect rect;
     
    16771986    }
    16781987
    16791988    ScheduleContextUpdates(data);
     1989#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    16801990}}
     1991#else
     1992    [pool release];
     1993}
     1994#endif
    16811995
    16821996int
    16831997Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp)
     
    17672081
    17682082void
    17692083Cocoa_DestroyWindow(_THIS, SDL_Window * window)
     2084#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    17702085{ @autoreleasepool
    17712086{
     2087#else
     2088{
     2089    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     2090#endif
    17722091    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    17732092
    17742093    if (data) {
     
    17912110        SDL_free(data);
    17922111    }
    17932112    window->driverdata = NULL;
     2113#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    17942114}}
     2115#else
     2116    [pool release];
     2117}
     2118#endif
    17952119
    17962120SDL_bool
    17972121Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
     
    18232147
    18242148SDL_bool
    18252149Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state)
     2150#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    18262151{ @autoreleasepool
    18272152{
     2153#else
     2154{
     2155    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     2156#endif
    18282157    SDL_bool succeeded = SDL_FALSE;
    18292158    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    18302159
     
    18552184        succeeded = SDL_TRUE;
    18562185    }
    18572186
     2187#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     2188    [pool release];
     2189#endif
    18582190    return succeeded;
     2191#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    18592192}}
     2193#else
     2194}
     2195#endif
    18602196
    18612197int
    18622198Cocoa_SetWindowHitTest(SDL_Window * window, SDL_bool enabled)