Ticket #52210: SDL2-2.0.6_OSX_105.patch

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

Patch to build SDL 2.0.6 on OS X 10.5.8 leopard

  • include/SDL_config.h

    Only in SDL2-2.0.6: Makefile
    Only in SDL2-2.0.6: Makefile.rules
    Only in SDL2-2.0.6: build
    Only in SDL2-2.0.6: config.log
    Only in SDL2-2.0.6: config.status
    diff -ru SDL2-2.0.6-orig/include/SDL_config.h SDL2-2.0.6/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-2017 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
     80/* C library functions */
     81#define HAVE_MALLOC 1
     82#define HAVE_CALLOC 1
     83#define HAVE_REALLOC 1
     84#define HAVE_FREE 1
     85#define HAVE_ALLOCA 1
     86#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */
     87#define HAVE_GETENV 1
     88#define HAVE_SETENV 1
     89#define HAVE_PUTENV 1
     90#define HAVE_UNSETENV 1
    5191#endif
     92#define HAVE_QSORT 1
     93#define HAVE_ABS 1
     94#define HAVE_BCOPY 1
     95#define HAVE_MEMSET 1
     96#define HAVE_MEMCPY 1
     97#define HAVE_MEMMOVE 1
     98#define HAVE_MEMCMP 1
     99#define HAVE_WCSLEN 1
     100/* #undef HAVE_WCSLCPY */
     101/* #undef HAVE_WCSLCAT */
     102#define HAVE_WCSCMP 1
     103#define HAVE_STRLEN 1
     104#define HAVE_STRLCPY 1
     105#define HAVE_STRLCAT 1
     106#define HAVE_STRDUP 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_ATAN 1
     140#define HAVE_ATAN2 1
     141#define HAVE_ACOS 1
     142#define HAVE_ASIN 1
     143#define HAVE_CEIL 1
     144#define HAVE_COPYSIGN 1
     145#define HAVE_COS 1
     146#define HAVE_COSF 1
     147#define HAVE_FABS 1
     148#define HAVE_FLOOR 1
     149#define HAVE_LOG 1
     150#define HAVE_POW 1
     151#define HAVE_SCALBN 1
     152#define HAVE_SIN 1
     153#define HAVE_SINF 1
     154#define HAVE_SQRT 1
     155#define HAVE_SQRTF 1
     156#define HAVE_TAN 1
     157#define HAVE_TANF 1
     158/* #undef HAVE_FOPEN64 */
     159#define HAVE_FSEEKO 1
     160/* #undef HAVE_FSEEKO64 */
     161#define HAVE_SIGACTION 1
     162#define HAVE_SA_SIGACTION 1
     163#define HAVE_SETJMP 1
     164#define HAVE_NANOSLEEP 1
     165#define HAVE_SYSCONF 1
     166#define HAVE_SYSCTLBYNAME 1
     167/* #undef HAVE_CLOCK_GETTIME */
     168/* #undef HAVE_GETPAGESIZE */
     169#define HAVE_MPROTECT 1
     170#define HAVE_ICONV 1
     171/* #undef HAVE_PTHREAD_SETNAME_NP */
     172/* #undef HAVE_PTHREAD_SET_NAME_NP */
     173/* #undef HAVE_SEM_TIMEDWAIT */
     174/* #undef HAVE_GETAUXVAL */
     175#define HAVE_POLL 1
     176
     177#else
     178#define HAVE_STDARG_H 1
     179#define HAVE_STDDEF_H 1
     180#define HAVE_STDINT_H 1
     181#endif /* HAVE_LIBC */
     182
     183#define HAVE_ALTIVEC_H 1
     184/* #undef HAVE_LIBUDEV_H */
     185/* #undef HAVE_DBUS_DBUS_H */
     186/* #undef HAVE_IBUS_IBUS_H */
     187/* #undef HAVE_FCITX_FRONTEND_H */
     188/* #undef HAVE_LIBSAMPLERATE_H */
     189
     190/* #undef HAVE_DDRAW_H */
     191/* #undef HAVE_DINPUT_H */
     192/* #undef HAVE_DSOUND_H */
     193/* #undef HAVE_DXGI_H */
     194/* #undef HAVE_XINPUT_H */
     195/* #undef HAVE_XINPUT_GAMEPAD_EX */
     196/* #undef HAVE_XINPUT_STATE_EX */
     197
     198/* SDL internal assertion support */
     199/* #undef SDL_DEFAULT_ASSERT_LEVEL */
     200
     201/* Allow disabling of core subsystems */
     202/* #undef SDL_ATOMIC_DISABLED */
     203/* #undef SDL_AUDIO_DISABLED */
     204/* #undef SDL_CPUINFO_DISABLED */
     205/* #undef SDL_EVENTS_DISABLED */
     206/* #undef SDL_FILE_DISABLED */
     207/* #undef SDL_JOYSTICK_DISABLED */
     208/* #undef SDL_HAPTIC_DISABLED */
     209/* #undef SDL_LOADSO_DISABLED */
     210/* #undef SDL_RENDER_DISABLED */
     211/* #undef SDL_THREADS_DISABLED */
     212/* #undef SDL_TIMERS_DISABLED */
     213/* #undef SDL_VIDEO_DISABLED */
     214/* #undef SDL_POWER_DISABLED */
     215/* #undef SDL_FILESYSTEM_DISABLED */
     216
     217/* Enable various audio drivers */
     218/* #undef SDL_AUDIO_DRIVER_ALSA */
     219/* #undef SDL_AUDIO_DRIVER_ALSA_DYNAMIC */
     220/* #undef SDL_AUDIO_DRIVER_ANDROID */
     221/* #undef SDL_AUDIO_DRIVER_ARTS */
     222/* #undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC */
     223#define SDL_AUDIO_DRIVER_COREAUDIO 1
     224#define SDL_AUDIO_DRIVER_DISK 1
     225/* #undef SDL_AUDIO_DRIVER_DSOUND */
     226#define SDL_AUDIO_DRIVER_DUMMY 1
     227/* #undef SDL_AUDIO_DRIVER_EMSCRIPTEN */
     228/* #undef SDL_AUDIO_DRIVER_ESD */
     229/* #undef SDL_AUDIO_DRIVER_ESD_DYNAMIC */
     230/* #undef SDL_AUDIO_DRIVER_FUSIONSOUND */
     231/* #undef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC */
     232/* #undef SDL_AUDIO_DRIVER_HAIKU */
     233/* #undef SDL_AUDIO_DRIVER_JACK */
     234/* #undef SDL_AUDIO_DRIVER_JACK_DYNAMIC */
     235/* #undef SDL_AUDIO_DRIVER_NACL */
     236/* #undef SDL_AUDIO_DRIVER_NAS */
     237/* #undef SDL_AUDIO_DRIVER_NAS_DYNAMIC */
     238/* #undef SDL_AUDIO_DRIVER_NETBSD */
     239/* #undef SDL_AUDIO_DRIVER_OSS */
     240/* #undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H */
     241/* #undef SDL_AUDIO_DRIVER_PAUDIO */
     242/* #undef SDL_AUDIO_DRIVER_PULSEAUDIO */
     243/* #undef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC */
     244/* #undef SDL_AUDIO_DRIVER_QSA */
     245/* #undef SDL_AUDIO_DRIVER_SNDIO */
     246/* #undef SDL_AUDIO_DRIVER_SNDIO_DYNAMIC */
     247/* #undef SDL_AUDIO_DRIVER_SUNAUDIO */
     248/* #undef SDL_AUDIO_DRIVER_WASAPI */
     249/* #undef SDL_AUDIO_DRIVER_WINMM */
     250/* #undef SDL_AUDIO_DRIVER_XAUDIO2 */
     251
     252/* Enable various input drivers */
     253/* #undef SDL_INPUT_LINUXEV */
     254/* #undef SDL_INPUT_LINUXKD */
     255/* #undef SDL_INPUT_TSLIB */
     256/* #undef SDL_JOYSTICK_HAIKU */
     257/* #undef SDL_JOYSTICK_DINPUT */
     258/* #undef SDL_JOYSTICK_XINPUT */
     259/* #undef SDL_JOYSTICK_DUMMY */
     260#define SDL_JOYSTICK_IOKIT 1
     261/* #undef SDL_JOYSTICK_LINUX */
     262/* #undef SDL_JOYSTICK_ANDROID */
     263/* #undef SDL_JOYSTICK_WINMM */
     264/* #undef SDL_JOYSTICK_USBHID */
     265/* #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H */
     266/* #undef SDL_JOYSTICK_EMSCRIPTEN */
     267/* #undef SDL_HAPTIC_DUMMY */
     268/* #undef SDL_HAPTIC_LINUX */
     269#define SDL_HAPTIC_IOKIT 1
     270/* #undef SDL_HAPTIC_DINPUT */
     271/* #undef SDL_HAPTIC_XINPUT */
     272
     273/* Enable various shared object loading systems */
     274#define SDL_LOADSO_DLOPEN 1
     275/* #undef SDL_LOADSO_DUMMY */
     276/* #undef SDL_LOADSO_LDG */
     277/* #undef SDL_LOADSO_WINDOWS */
     278
     279/* Enable various threading systems */
     280#define SDL_THREAD_PTHREAD 1
     281#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
     282/* #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP */
     283/* #undef SDL_THREAD_WINDOWS */
     284
     285/* Enable various timer systems */
     286/* #undef SDL_TIMER_HAIKU */
     287/* #undef SDL_TIMER_DUMMY */
     288#define SDL_TIMER_UNIX 1
     289/* #undef SDL_TIMER_WINDOWS */
     290
     291/* Enable various video drivers */
     292/* #undef SDL_VIDEO_DRIVER_HAIKU */
     293#define SDL_VIDEO_DRIVER_COCOA 1
     294/* #undef SDL_VIDEO_DRIVER_DIRECTFB */
     295/* #undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC */
     296#define SDL_VIDEO_DRIVER_DUMMY 1
     297/* #undef SDL_VIDEO_DRIVER_WINDOWS */
     298/* #undef SDL_VIDEO_DRIVER_WAYLAND */
     299/* #undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
     300/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC */
     301/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL */
     302/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR */
     303/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON */
     304/* #undef SDL_VIDEO_DRIVER_MIR */
     305/* #undef SDL_VIDEO_DRIVER_MIR_DYNAMIC */
     306/* #undef SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON */
     307#define SDL_VIDEO_DRIVER_X11 1
     308/* #undef SDL_VIDEO_DRIVER_RPI */
     309/* #undef SDL_VIDEO_DRIVER_KMSDRM */
     310/* #undef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC */
     311/* #undef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM */
     312/* #undef SDL_VIDEO_DRIVER_ANDROID */
     313/* #undef SDL_VIDEO_DRIVER_EMSCRIPTEN */
     314#define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib"
     315#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib"
     316#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR "/usr/X11R6/lib/libXcursor.1.dylib"
     317#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/usr/X11R6/lib/libXinerama.1.dylib"
     318/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 */
     319/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR */
     320#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/usr/X11R6/lib/libXss.1.dylib"
     321#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "/usr/X11R6/lib/libXxf86vm.1.dylib"
     322#define SDL_VIDEO_DRIVER_X11_XCURSOR 1
     323#define SDL_VIDEO_DRIVER_X11_XDBE 1
     324#define SDL_VIDEO_DRIVER_X11_XINERAMA 1
     325/* #undef SDL_VIDEO_DRIVER_X11_XINPUT2 */
     326/* #undef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH */
     327/* #undef SDL_VIDEO_DRIVER_X11_XRANDR */
     328#define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1
     329#define SDL_VIDEO_DRIVER_X11_XSHAPE 1
     330#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1
     331/* #undef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS */
     332/* #undef SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY */
     333#define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1
     334/* #undef SDL_VIDEO_DRIVER_NACL */
     335/* #undef SDL_VIDEO_DRIVER_VIVANTE */
     336/* #undef SDL_VIDEO_DRIVER_VIVANTE_VDK */
     337/* #undef SDL_VIDEO_DRIVER_QNX */
     338
     339/* #undef SDL_VIDEO_RENDER_D3D */
     340/* #undef SDL_VIDEO_RENDER_D3D11 */
     341#define SDL_VIDEO_RENDER_OGL 1
     342/* #undef SDL_VIDEO_RENDER_OGL_ES */
     343/* #undef SDL_VIDEO_RENDER_OGL_ES2 */
     344/* #undef SDL_VIDEO_RENDER_DIRECTFB */
     345
     346/* Enable OpenGL support */
     347#define SDL_VIDEO_OPENGL 1
     348/* #undef SDL_VIDEO_OPENGL_ES */
     349/* #undef SDL_VIDEO_OPENGL_ES2 */
     350/* #undef SDL_VIDEO_OPENGL_BGL */
     351#define SDL_VIDEO_OPENGL_CGL 1
     352/* #undef SDL_VIDEO_OPENGL_EGL */
     353#define SDL_VIDEO_OPENGL_GLX 1
     354/* #undef SDL_VIDEO_OPENGL_WGL */
     355/* #undef SDL_VIDEO_OPENGL_OSMESA */
     356/* #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC */
     357
     358/* Enable Vulkan support */
     359/* #undef SDL_VIDEO_VULKAN */
     360
     361/* Enable system power support */
     362/* #undef SDL_POWER_LINUX */
     363/* #undef SDL_POWER_WINDOWS */
     364#define SDL_POWER_MACOSX 1
     365/* #undef SDL_POWER_HAIKU */
     366/* #undef SDL_POWER_ANDROID */
     367/* #undef SDL_POWER_EMSCRIPTEN */
     368/* #undef SDL_POWER_HARDWIRED */
     369
     370/* Enable system filesystem support */
     371/* #undef SDL_FILESYSTEM_HAIKU */
     372#define SDL_FILESYSTEM_COCOA 1
     373/* #undef SDL_FILESYSTEM_DUMMY */
     374/* #undef SDL_FILESYSTEM_UNIX */
     375/* #undef SDL_FILESYSTEM_WINDOWS */
     376/* #undef SDL_FILESYSTEM_NACL */
     377/* #undef SDL_FILESYSTEM_ANDROID */
     378/* #undef SDL_FILESYSTEM_EMSCRIPTEN */
     379
     380/* Enable assembly routines */
     381#define SDL_ASSEMBLY_ROUTINES 1
     382#define SDL_ALTIVEC_BLITTERS 1
     383
     384/* Enable ime support */
     385/* #undef SDL_USE_IME */
     386
     387/* Enable dynamic udev support */
     388/* #undef SDL_UDEV_DYNAMIC */
     389
     390/* Enable dynamic libsamplerate support */
     391/* #undef SDL_LIBSAMPLERATE_DYNAMIC */
    52392
    53393#endif /* SDL_config_h_ */
  • include/SDL_platform.h

    diff -ru SDL2-2.0.6-orig/include/SDL_platform.h SDL2-2.0.6/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.6-orig/include/SDL_syswm.h SDL2-2.0.6/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.6: libtool
    Only in SDL2-2.0.6: sdl2-config
    Only in SDL2-2.0.6: sdl2-config.cmake
    Only in SDL2-2.0.6: sdl2.pc
    diff -ru SDL2-2.0.6-orig/src/atomic/SDL_spinlock.c SDL2-2.0.6/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.6-orig/src/file/cocoa/SDL_rwopsbundlesupport.m SDL2-2.0.6/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.6-orig/src/filesystem/cocoa/SDL_sysfilesystem.m SDL2-2.0.6/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.6-orig/src/joystick/darwin/SDL_sysjoystick.c SDL2-2.0.6/src/joystick/darwin/SDL_sysjoystick.c
    old new  
    459459    device->instance_id = ++s_joystick_instance_id;
    460460
    461461    /* We have to do some storage of the io_service_t for SDL_HapticOpenFromJoystick */
     462    #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    462463    ioservice = IOHIDDeviceGetService(ioHIDDeviceObject);
     464    #else
     465    ioservice = 0;
     466    #endif
    463467#if SDL_HAPTIC_IOKIT
    464468    if ((ioservice) && (FFIsForceFeedback(ioservice) == FF_OK)) {
    465469        device->ffservice = ioservice;
  • src/video/cocoa/SDL_cocoaclipboard.m

    diff -ru SDL2-2.0.6-orig/src/video/cocoa/SDL_cocoaclipboard.m SDL2-2.0.6/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.6-orig/src/video/cocoa/SDL_cocoaevents.m SDL2-2.0.6/src/video/cocoa/SDL_cocoaevents.m
    old new  
    5555    SDL_VideoDevice *_this = SDL_GetVideoDevice();
    5656
    5757    switch ([theEvent type]) {
     58#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     59        case NSLeftMouseDown:
     60        case NSOtherMouseDown:
     61        case NSRightMouseDown:
     62        case NSLeftMouseUp:
     63        case NSOtherMouseUp:
     64        case NSRightMouseUp:
     65        case NSLeftMouseDragged:
     66        case NSRightMouseDragged:
     67        case NSOtherMouseDragged: /* usually middle mouse dragged */
     68        case NSMouseMoved:
     69        case NSScrollWheel:
     70#else
    5871        case NSEventTypeLeftMouseDown:
    5972        case NSEventTypeOtherMouseDown:
    6073        case NSEventTypeRightMouseDown:
     
    6679        case NSEventTypeOtherMouseDragged: /* usually middle mouse dragged */
    6780        case NSEventTypeMouseMoved:
    6881        case NSEventTypeScrollWheel:
     82#endif
    6983            Cocoa_HandleMouseEvent(_this, theEvent);
    7084            break;
     85#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     86        case NSKeyDown:
     87        case NSKeyUp:
     88        case NSFlagsChanged:
     89#else
    7190        case NSEventTypeKeyDown:
    7291        case NSEventTypeKeyUp:
    7392        case NSEventTypeFlagsChanged:
     93#endif
    7494            Cocoa_HandleKeyEvent(_this, theEvent);
    7595            break;
    7696        default:
     
    97117- (void)setAppleMenu:(NSMenu *)menu;
    98118@end
    99119
     120#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    100121@interface SDLAppDelegate : NSObject <NSApplicationDelegate> {
     122#else
     123@interface SDLAppDelegate : NSObject {
     124#endif
    101125@public
    102126    BOOL seenFirstActivate;
    103127}
     
    157181     */
    158182    for (NSWindow *window in [NSApp orderedWindows]) {
    159183        if (window != win && [window canBecomeKeyWindow]) {
    160             if (![window isOnActiveSpace]) {
    161                 continue;
     184            if ([window respondsToSelector:@selector(isOnActiveSpace)]) {
     185                if (![window isOnActiveSpace]) {
     186                    continue;
     187                }
    162188            }
    163189            [window makeKeyAndOrderFront:self];
    164190            return;
     
    328354    [windowMenu release];
    329355
    330356
     357#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    331358    /* Add the fullscreen view toggle menu option, if supported */
    332359    if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
    333360        /* Create the view menu */
     
    345372
    346373        [viewMenu release];
    347374    }
     375#endif
    348376}
    349377
    350378void
    351379Cocoa_RegisterApp(void)
     380#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    352381{ @autoreleasepool
    353382{
     383#else
     384{
     385    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     386#endif
    354387    /* This can get called more than once! Be careful what you initialize! */
    355388
    356389    if (NSApp == nil) {
     
    360393        s_bShouldHandleEventsInSDLApplication = SDL_TRUE;
    361394
    362395        if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, SDL_FALSE)) {
     396#if defined(MAC_OS_X_VERSION_10_6)
     397#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
    363398            [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
     399#endif
     400#endif
    364401            [NSApp activateIgnoringOtherApps:YES];
    365402                }
    366403               
     
    388425            appDelegate->seenFirstActivate = YES;
    389426        }
    390427    }
     428#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    391429}}
     430#else
     431    [pool release];
     432}
     433#endif
    392434
    393435void
    394436Cocoa_PumpEvents(_THIS)
     437#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    395438{ @autoreleasepool
    396439{
     440#else
     441{
     442    NSAutoreleasePool *pool;
     443#endif
    397444#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
    398445    /* Update activity every 30 seconds to prevent screensaver */
    399446    SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
     
    407454    }
    408455#endif
    409456
     457#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     458    pool = [[NSAutoreleasePool alloc] init];
     459#endif
    410460    for ( ; ; ) {
     461#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     462        NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
     463#else
    411464        NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
     465#endif
    412466        if ( event == nil ) {
    413467            break;
    414468        }
     
    420474        // Pass events down to SDLApplication to be handled in sendEvent:
    421475        [NSApp sendEvent:event];
    422476    }
     477#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    423478}}
     479#else
     480    [pool release];
     481}
     482#endif
    424483
    425484void
    426485Cocoa_SuspendScreenSaver(_THIS)
     486#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    427487{ @autoreleasepool
    428488{
    429489    SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
     
    450510                                           &data->screensaver_assertion);
    451511    }
    452512}}
     513#else
     514{
     515}
     516#endif
    453517
    454518#endif /* SDL_VIDEO_DRIVER_COCOA */
    455519
  • src/video/cocoa/SDL_cocoakeyboard.m

    Only in SDL2-2.0.6/src/video/cocoa: SDL_cocoaevents.m.rej
    diff -ru SDL2-2.0.6-orig/src/video/cocoa/SDL_cocoakeyboard.m SDL2-2.0.6/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.6-orig/src/video/cocoa/SDL_cocoamessagebox.m SDL2-2.0.6/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.6-orig/src/video/cocoa/SDL_cocoamodes.h SDL2-2.0.6/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.6-orig/src/video/cocoa/SDL_cocoamodes.m SDL2-2.0.6/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, CFArrayRef modelist, CVDisplayLinkRef link, SDL_DisplayMode *mode)
     105#else
     106GetDisplayMode(_THIS, const void *moderef, CFArrayRef modelist, CVDisplayLinkRef link, SDL_DisplayMode *mode)
     107#endif
    104108{
    105109    SDL_DisplayModeData *data;
     110#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    106111    int width = (int) CGDisplayModeGetWidth(vidmode);
    107112    int height = (int) CGDisplayModeGetHeight(vidmode);
    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    /* Ignore this mode if it's low-dpi (@1x) and we have a high-dpi mode in the
    113124     * list with the same size in points.
     
    145156    if (!data) {
    146157        return SDL_FALSE;
    147158    }
     159#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    148160    data->moderef = vidmode;
     161#else
     162    data->moderef = moderef;
     163#endif
    149164
     165#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    150166    fmt = CGDisplayModeCopyPixelEncoding(vidmode);
    151167    refreshRate = (int) (CGDisplayModeGetRefreshRate(vidmode) + 0.5);
    152168
     
    164180    }
    165181
    166182    CFRelease(fmt);
     183#else
     184    {
     185        CFNumberRef number;
     186        double refresh;
     187        CFDictionaryRef vidmode = (CFDictionaryRef) moderef;
     188        number = CFDictionaryGetValue(vidmode, kCGDisplayWidth);
     189        CFNumberGetValue(number, kCFNumberLongType, &width);
     190        number = CFDictionaryGetValue(vidmode, kCGDisplayHeight);
     191        CFNumberGetValue(number, kCFNumberLongType, &height);
     192        number = CFDictionaryGetValue(vidmode, kCGDisplayBitsPerPixel);
     193        CFNumberGetValue(number, kCFNumberLongType, &bpp);
     194        number = CFDictionaryGetValue(vidmode, kCGDisplayRefreshRate);
     195        CFNumberGetValue(number, kCFNumberDoubleType, &refresh);
     196        refreshRate = (long) (refresh + 0.5);
     197    }
     198#endif
    167199
    168200    /* CGDisplayModeGetRefreshRate returns 0 for many non-CRT displays. */
    169201    if (refreshRate == 0 && link != NULL) {
     
    212244
    213245void
    214246Cocoa_InitModes(_THIS)
     247#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    215248{ @autoreleasepool
    216249{
     250#else
     251{
     252    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     253#endif
    217254    CGDisplayErr result;
    218255    CGDirectDisplayID *displays;
    219256    CGDisplayCount numDisplays;
     
    222259    result = CGGetOnlineDisplayList(0, NULL, &numDisplays);
    223260    if (result != kCGErrorSuccess) {
    224261        CG_SetError("CGGetOnlineDisplayList()", result);
     262#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     263        [pool release];
     264#endif
    225265        return;
    226266    }
    227267    displays = SDL_stack_alloc(CGDirectDisplayID, numDisplays);
     
    229269    if (result != kCGErrorSuccess) {
    230270        CG_SetError("CGGetOnlineDisplayList()", result);
    231271        SDL_stack_free(displays);
     272#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     273        [pool release];
     274#endif
    232275        return;
    233276    }
    234277
     
    238281            SDL_VideoDisplay display;
    239282            SDL_DisplayData *displaydata;
    240283            SDL_DisplayMode mode;
     284#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    241285            CGDisplayModeRef moderef = NULL;
     286#else
     287            const void *moderef = NULL;
     288#endif
    242289            CVDisplayLinkRef link = NULL;
    243290
    244291            if (pass == 0) {
     
    255302                continue;
    256303            }
    257304
     305            #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    258306            moderef = CGDisplayCopyDisplayMode(displays[i]);
     307            #else
     308            moderef = CGDisplayCurrentMode(displays[i]);
     309            #endif
    259310
    260311            if (!moderef) {
    261312                continue;
     
    263314
    264315            displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
    265316            if (!displaydata) {
     317            #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    266318                CGDisplayModeRelease(moderef);
     319            #endif
    267320                continue;
    268321            }
    269322            displaydata->display = displays[i];
     
    275328            display.name = (char *)Cocoa_GetDisplayName(displays[i]);
    276329            if (!GetDisplayMode(_this, moderef, NULL, link, &mode)) {
    277330                CVDisplayLinkRelease(link);
     331            #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    278332                CGDisplayModeRelease(moderef);
     333            #endif
    279334                SDL_free(display.name);
    280335                SDL_free(displaydata);
    281336                continue;
     
    291346        }
    292347    }
    293348    SDL_stack_free(displays);
     349#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     350    [pool release];
     351}
     352#else
    294353}}
     354#endif
    295355
    296356int
    297357Cocoa_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect)
     
    391451    }
    392452#endif
    393453
     454#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    394455    modes = CGDisplayCopyAllDisplayModes(data->display, dict);
     456#else
     457    modes = CGDisplayAvailableModes(data->display);
     458#endif
    395459
    396460    if (dict != NULL) {
    397461        CFRelease(dict);
     
    405469        CVDisplayLinkCreateWithCGDisplay(data->display, &link);
    406470
    407471        for (i = 0; i < count; i++) {
     472#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    408473            CGDisplayModeRef moderef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
     474#else
     475            const void *moderef = CFArrayGetValueAtIndex(modes, i);
     476#endif
    409477            SDL_DisplayMode mode;
    410478            if (GetDisplayMode(_this, moderef, modes, link, &mode)) {
     479                #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    411480                CGDisplayModeRetain(moderef);
     481                #endif
    412482                SDL_AddDisplayMode(display, &mode);
    413483            }
    414484        }
     
    433503
    434504    if (data == display->desktop_mode.driverdata) {
    435505        /* Restoring desktop mode */
     506#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    436507        CGDisplaySetDisplayMode(displaydata->display, data->moderef, NULL);
     508#else
     509        CGDisplaySwitchToMode(displaydata->display, data->moderef);
     510#endif
    437511
    438512        if (CGDisplayIsMain(displaydata->display)) {
    439513            CGReleaseAllDisplays();
     
    458532        }
    459533
    460534        /* Do the physical switch */
     535#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    461536        result = CGDisplaySetDisplayMode(displaydata->display, data->moderef, NULL);
     537#else
     538        result = CGDisplaySwitchToMode(displaydata->display, data->moderef);
     539#endif
    462540        if (result != kCGErrorSuccess) {
    463541            CG_SetError("CGDisplaySwitchToMode()", result);
    464542            goto ERR_NO_SWITCH;
     
    503581        }
    504582
    505583        mode = (SDL_DisplayModeData *) display->desktop_mode.driverdata;
     584        #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    506585        CGDisplayModeRelease(mode->moderef);
     586        #endif
    507587
    508588        for (j = 0; j < display->num_display_modes; j++) {
    509589            mode = (SDL_DisplayModeData*) display->display_modes[j].driverdata;
     590        #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    510591            CGDisplayModeRelease(mode->moderef);
     592        #endif
    511593        }
    512594
    513595    }
  • src/video/cocoa/SDL_cocoamouse.m

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

    diff -ru SDL2-2.0.6-orig/src/video/cocoa/SDL_cocoashape.m SDL2-2.0.6/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.6-orig/src/video/cocoa/SDL_cocoavideo.h SDL2-2.0.6/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.6-orig/src/video/cocoa/SDL_cocoavideo.m SDL2-2.0.6/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"
     
    159166    Cocoa_InitKeyboard(_this);
    160167    Cocoa_InitMouse(_this);
    161168
     169#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    162170    data->allow_spaces = ((floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) && SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_TRUE));
    163171
    164172    /* The IOPM assertion API can disable the screensaver as of 10.7. */
    165173    data->screensaver_use_iopm = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6;
     174#else
     175    data->allow_spaces = 0;
     176    data->screensaver_use_iopm = 0;
     177#endif
    166178
    167179    return 0;
    168180}
  • src/video/cocoa/SDL_cocoawindow.h

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

    diff -ru SDL2-2.0.6-orig/src/video/cocoa/SDL_cocoawindow.m SDL2-2.0.6/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"
     
    5456#define FULLSCREEN_MASK (SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN)
    5557
    5658
     59#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     60@interface SDLWindow : NSWindow
     61#else
    5762@interface SDLWindow : NSWindow <NSDraggingDestination>
     63#endif
    5864/* These are needed for borderless/fullscreen windows */
    5965- (BOOL)canBecomeKeyWindow;
    6066- (BOOL)canBecomeMainWindow;
     
    136142}
    137143
    138144- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
     145#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    139146{ @autoreleasepool
    140147{
     148#else
     149{
     150    NSAutoreleasePool *pool;
     151#endif
    141152    NSPasteboard *pasteboard = [sender draggingPasteboard];
    142153    NSArray *types = [NSArray arrayWithObject:NSFilenamesPboardType];
    143154    NSString *desiredType = [pasteboard availableTypeFromArray:types];
     
    152163        return NO;
    153164    }
    154165
     166#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     167    pool = [[NSAutoreleasePool alloc] init];
     168#endif
     169
    155170    SDL_assert([desiredType isEqualToString:NSFilenamesPboardType]);
    156171    NSArray *array = [pasteboard propertyListForType:@"NSFilenamesPboardType"];
    157172
    158173    for (NSString *path in array) {
    159174        NSURL *fileURL = [NSURL fileURLWithPath:path];
     175#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    160176        NSNumber *isAlias = nil;
    161177
    162178        [fileURL getResourceValue:&isAlias forKey:NSURLIsAliasFileKey error:nil];
     
    177193                }
    178194            }
    179195        }
     196#endif
    180197
    181198        if (!SDL_SendDropFile(sdlwindow, [[fileURL path] UTF8String])) {
     199#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     200            [pool release];
     201#endif
    182202            return NO;
    183203        }
    184204    }
    185205
     206#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     207    [pool release];
     208#endif
    186209    SDL_SendDropComplete(sdlwindow);
    187210    return YES;
     211#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     212}
     213#else
    188214}}
     215#endif
    189216
    190217- (BOOL)wantsPeriodicDraggingUpdates
    191218{
     
    313340        [center addObserver:self selector:@selector(windowDidDeminiaturize:) name:NSWindowDidDeminiaturizeNotification object:window];
    314341        [center addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:window];
    315342        [center addObserver:self selector:@selector(windowDidResignKey:) name:NSWindowDidResignKeyNotification object:window];
     343#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    316344        [center addObserver:self selector:@selector(windowDidChangeBackingProperties:) name:NSWindowDidChangeBackingPropertiesNotification object:window];
    317345        [center addObserver:self selector:@selector(windowWillEnterFullScreen:) name:NSWindowWillEnterFullScreenNotification object:window];
    318346        [center addObserver:self selector:@selector(windowDidEnterFullScreen:) name:NSWindowDidEnterFullScreenNotification object:window];
    319347        [center addObserver:self selector:@selector(windowWillExitFullScreen:) name:NSWindowWillExitFullScreenNotification object:window];
    320348        [center addObserver:self selector:@selector(windowDidExitFullScreen:) name:NSWindowDidExitFullScreenNotification object:window];
     349#endif
    321350        [center addObserver:self selector:@selector(windowDidFailToEnterFullScreen:) name:@"NSWindowDidFailToEnterFullScreenNotification" object:window];
    322351        [center addObserver:self selector:@selector(windowDidFailToExitFullScreen:) name:@"NSWindowDidFailToExitFullScreenNotification" object:window];
    323352    } else {
     
    408437    inFullscreenTransition = YES;
    409438
    410439    /* you need to be FullScreenPrimary, or toggleFullScreen doesn't work. Unset it again in windowDidExitFullScreen. */
     440#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    411441    [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
     442#endif
    412443    [nswindow performSelectorOnMainThread: @selector(toggleFullScreen:) withObject:nswindow waitUntilDone:NO];
    413444    return YES;
    414445}
     
    444475        [center removeObserver:self name:NSWindowDidDeminiaturizeNotification object:window];
    445476        [center removeObserver:self name:NSWindowDidBecomeKeyNotification object:window];
    446477        [center removeObserver:self name:NSWindowDidResignKeyNotification object:window];
     478#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    447479        [center removeObserver:self name:NSWindowDidChangeBackingPropertiesNotification object:window];
    448480        [center removeObserver:self name:NSWindowWillEnterFullScreenNotification object:window];
    449481        [center removeObserver:self name:NSWindowDidEnterFullScreenNotification object:window];
    450482        [center removeObserver:self name:NSWindowWillExitFullScreenNotification object:window];
    451483        [center removeObserver:self name:NSWindowDidExitFullScreenNotification object:window];
     484#endif
    452485        [center removeObserver:self name:@"NSWindowDidFailToEnterFullScreenNotification" object:window];
    453486        [center removeObserver:self name:@"NSWindowDidFailToExitFullScreenNotification" object:window];
    454487    } else {
     
    628661        [NSMenu setMenuBarVisible:NO];
    629662    }
    630663
     664#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    631665    const unsigned int newflags = [NSEvent modifierFlags] & NSEventModifierFlagCapsLock;
    632666    _data->videodata->modifierFlags = (_data->videodata->modifierFlags & ~NSEventModifierFlagCapsLock) | newflags;
    633667    SDL_ToggleModState(KMOD_CAPS, newflags != 0);
     668#endif
    634669}
    635670
    636671- (void)windowDidResignKey:(NSNotification *)aNotification
     
    657692
    658693- (void)windowDidChangeBackingProperties:(NSNotification *)aNotification
    659694{
     695#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    660696    NSNumber *oldscale = [[aNotification userInfo] objectForKey:NSBackingPropertyOldScaleFactorKey];
    661697
    662698    if (inFullscreenTransition) {
     
    669705        _data->window->h = 0;
    670706        [self windowDidResize:aNotification];
    671707    }
     708#endif
    672709}
    673710
    674711- (void)windowWillEnterFullScreen:(NSNotification *)aNotification
     
    777814        [nswindow miniaturize:nil];
    778815    } else {
    779816        /* Adjust the fullscreen toggle button and readd menu now that we're here. */
     817#if MAC_OS_X_VERSION_MIN_REQUIRED > 1070
    780818        if (window->flags & SDL_WINDOW_RESIZABLE) {
    781819            /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
    782820            [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
    783821        } else {
    784822            [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged];
    785823        }
     824#endif
    786825        [NSMenu setMenuBarVisible:YES];
    787826
    788827        pendingWindowOperation = PENDING_OPERATION_NONE;
     
    825864    }
    826865}
    827866
     867#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    828868-(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions
    829869{
    830870    if ((_data->window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
     
    833873        return proposedOptions;
    834874    }
    835875}
     876#endif
    836877
    837878
    838879/* We'll respond to key events by doing nothing so we don't beep.
     
    10591100
    10601101- (void)touchesBeganWithEvent:(NSEvent *) theEvent
    10611102{
     1103#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    10621104    NSSet *touches = [theEvent touchesMatchingPhase:NSTouchPhaseAny inView:nil];
    10631105    int existingTouchCount = 0;
    10641106
     
    10791121
    10801122    DLog("Began Fingers: %lu .. existing: %d", (unsigned long)[touches count], existingTouchCount);
    10811123    [self handleTouches:NSTouchPhaseBegan withEvent:theEvent];
     1124#endif
    10821125}
    10831126
    10841127- (void)touchesMovedWithEvent:(NSEvent *) theEvent
    10851128{
     1129#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    10861130    [self handleTouches:NSTouchPhaseMoved withEvent:theEvent];
     1131#endif
    10871132}
    10881133
    10891134- (void)touchesEndedWithEvent:(NSEvent *) theEvent
    10901135{
     1136#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    10911137    [self handleTouches:NSTouchPhaseEnded withEvent:theEvent];
     1138#endif
    10921139}
    10931140
    10941141- (void)touchesCancelledWithEvent:(NSEvent *) theEvent
    10951142{
     1143#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    10961144    [self handleTouches:NSTouchPhaseCancelled withEvent:theEvent];
     1145#endif
    10971146}
    10981147
     1148#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
     1149#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
    10991150- (void)handleTouches:(NSTouchPhase) phase withEvent:(NSEvent *) theEvent
     1151#else
     1152- (void)handleTouches:(cocoaTouchType)type withEvent:(NSEvent *)event
     1153#endif
    11001154{
     1155#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1156    NSSet *touches = 0;
     1157    NSEnumerator *enumerator;
     1158    NSTouch *touch;
     1159
     1160    switch (type) {
     1161        case COCOA_TOUCH_DOWN:
     1162            touches = [event touchesMatchingPhase:NSTouchPhaseBegan inView:nil];
     1163            break;
     1164        case COCOA_TOUCH_UP:
     1165            touches = [event touchesMatchingPhase:NSTouchPhaseEnded inView:nil];
     1166            break;
     1167        case COCOA_TOUCH_CANCELLED:
     1168            touches = [event touchesMatchingPhase:NSTouchPhaseCancelled inView:nil];
     1169            break;
     1170        case COCOA_TOUCH_MOVE:
     1171            touches = [event touchesMatchingPhase:NSTouchPhaseMoved inView:nil];
     1172            break;
     1173    }
     1174
     1175    enumerator = [touches objectEnumerator];
     1176    touch = (NSTouch*)[enumerator nextObject];
     1177    while (touch) {
     1178        const SDL_TouchID touchId = (SDL_TouchID)(intptr_t)[touch device];
     1179        if (!SDL_GetTouch(touchId)) {
     1180            if (SDL_AddTouch(touchId, "") < 0) {
     1181                return;
     1182            }
     1183        }
     1184
     1185        const SDL_FingerID fingerId = (SDL_FingerID)(intptr_t)[touch identity];
     1186        float x = [touch normalizedPosition].x;
     1187        float y = [touch normalizedPosition].y;
     1188        /* Make the origin the upper left instead of the lower left */
     1189        y = 1.0f - y;
     1190
     1191        switch (type) {
     1192        case COCOA_TOUCH_DOWN:
     1193            SDL_SendTouch(touchId, fingerId, SDL_TRUE, x, y, 1.0f);
     1194            break;
     1195        case COCOA_TOUCH_UP:
     1196        case COCOA_TOUCH_CANCELLED:
     1197            SDL_SendTouch(touchId, fingerId, SDL_FALSE, x, y, 1.0f);
     1198            break;
     1199        case COCOA_TOUCH_MOVE:
     1200            SDL_SendTouchMotion(touchId, fingerId, x, y, 1.0f);
     1201            break;
     1202        }
     1203
     1204        touch = (NSTouch*)[enumerator nextObject];
     1205     }
     1206#else
    11011207    NSSet *touches = [theEvent touchesMatchingPhase:phase inView:nil];
    11021208
    11031209    for (NSTouch *touch in touches) {
     
    11271233            break;
    11281234        }
    11291235    }
     1236#endif
    11301237}
     1238#endif
    11311239
    11321240@end
    11331241
     
    11941302
    11951303static int
    11961304SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created)
     1305#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    11971306{ @autoreleasepool
    11981307{
     1308#else
     1309{
     1310    NSAutoreleasePool *pool;
     1311#endif
    11991312    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
    12001313    SDL_WindowData *data;
    12011314
     
    12101323    data->videodata = videodata;
    12111324    data->nscontexts = [[NSMutableArray alloc] init];
    12121325
     1326#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1327    pool = [[NSAutoreleasePool alloc] init];
     1328#endif
    12131329    /* Create an event listener for the window */
    12141330    data->listener = [[Cocoa_WindowListener alloc] init];
    12151331
     
    12701386     */
    12711387    [nswindow setOneShot:NO];
    12721388
     1389#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1390    [pool release];
     1391#endif
    12731392    /* All done! */
    12741393    window->driverdata = data;
    12751394    return 0;
     1395#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1396}
     1397#else
    12761398}}
     1399#endif
    12771400
    12781401int
    12791402Cocoa_CreateWindow(_THIS, SDL_Window * window)
     1403#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    12801404{ @autoreleasepool
    12811405{
     1406#else
     1407{
     1408    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1409#endif
    12821410    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
    12831411    NSWindow *nswindow;
    12841412    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
     
    13191447    [nswindow setBackgroundColor:[NSColor blackColor]];
    13201448
    13211449    if (videodata->allow_spaces) {
     1450#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    13221451        SDL_assert(floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6);
    13231452        SDL_assert([nswindow respondsToSelector:@selector(toggleFullScreen:)]);
    13241453        /* we put FULLSCREEN_DESKTOP windows in their own Space, without a toggle button or menubar, later */
     
    13261455            /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
    13271456            [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
    13281457        }
     1458#endif
    13291459    }
    13301460
    13311461    /* Create a default view for this window */
     
    13441474
    13451475    /* Allow files and folders to be dragged onto the window by users */
    13461476    [nswindow registerForDraggedTypes:[NSArray arrayWithObject:(NSString *)kUTTypeFileURL]];
     1477#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1478    [pool release];
     1479#endif
    13471480
    13481481    if (SetupWindowData(_this, window, nswindow, SDL_TRUE) < 0) {
    13491482        [nswindow release];
    13501483        return -1;
    13511484    }
    13521485    return 0;
     1486#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13531487}}
     1488#else
     1489}
     1490#endif
    13541491
    13551492int
    13561493Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
     1494#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13571495{ @autoreleasepool
    13581496{
     1497#else
     1498{
     1499    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1500#endif
    13591501    NSWindow *nswindow = (NSWindow *) data;
    13601502    NSString *title;
    13611503
     
    13661508    }
    13671509
    13681510    return SetupWindowData(_this, window, nswindow, SDL_FALSE);
     1511#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13691512}}
     1513#else
     1514    [pool release];
     1515}
     1516#endif
    13701517
    13711518void
    13721519Cocoa_SetWindowTitle(_THIS, SDL_Window * window)
     1520#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13731521{ @autoreleasepool
    13741522{
     1523#else
     1524{
     1525    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1526#endif
    13751527    const char *title = window->title ? window->title : "";
    13761528    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
    13771529    NSString *string = [[NSString alloc] initWithUTF8String:title];
    13781530    [nswindow setTitle:string];
    13791531    [string release];
     1532#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13801533}}
     1534#else
     1535    [pool release];
     1536}
     1537#endif
    13811538
    13821539void
    13831540Cocoa_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
     1541#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13841542{ @autoreleasepool
    13851543{
     1544#else
     1545{
     1546    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1547#endif
    13861548    NSImage *nsimage = Cocoa_CreateImage(icon);
    13871549
    13881550    if (nsimage) {
    13891551        [NSApp setApplicationIconImage:nsimage];
    13901552    }
     1553#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13911554}}
     1555#else
     1556    [pool release];
     1557}
     1558#endif
    13921559
    13931560void
    13941561Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
     1562#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13951563{ @autoreleasepool
    13961564{
     1565#else
     1566{
     1567    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1568#endif
    13971569    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    13981570    NSWindow *nswindow = windata->nswindow;
    13991571    NSRect rect;
     
    14111583    s_moveHack = moveHack;
    14121584
    14131585    ScheduleContextUpdates(windata);
     1586#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14141587}}
     1588#else
     1589    [pool release];
     1590}
     1591#endif
    14151592
    14161593void
    14171594Cocoa_SetWindowSize(_THIS, SDL_Window * window)
     1595#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14181596{ @autoreleasepool
    14191597{
     1598#else
     1599{
     1600    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1601#endif
    14201602    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    14211603    NSWindow *nswindow = windata->nswindow;
    14221604    NSRect rect;
     
    14381620    s_moveHack = moveHack;
    14391621
    14401622    ScheduleContextUpdates(windata);
     1623#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14411624}}
     1625#else
     1626    [pool release];
     1627}
     1628#endif
    14421629
    14431630void
    14441631Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window)
     1632#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14451633{ @autoreleasepool
    14461634{
     1635#else
     1636{
     1637    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1638#endif
    14471639    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    14481640
    14491641    NSSize minSize;
     
    14511643    minSize.height = window->min_h;
    14521644
    14531645    [windata->nswindow setContentMinSize:minSize];
     1646#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14541647}}
     1648#else
     1649    [pool release];
     1650}
     1651#endif
    14551652
    14561653void
    14571654Cocoa_SetWindowMaximumSize(_THIS, SDL_Window * window)
     1655#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14581656{ @autoreleasepool
    14591657{
     1658#else
     1659{
     1660    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1661#endif
    14601662    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    14611663
    14621664    NSSize maxSize;
     
    14641666    maxSize.height = window->max_h;
    14651667
    14661668    [windata->nswindow setContentMaxSize:maxSize];
     1669#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14671670}}
     1671#else
     1672    [pool release];
     1673}
     1674#endif
    14681675
    14691676void
    14701677Cocoa_ShowWindow(_THIS, SDL_Window * window)
     1678#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14711679{ @autoreleasepool
    14721680{
     1681#else
     1682{
     1683    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1684#endif
    14731685    SDL_WindowData *windowData = ((SDL_WindowData *) window->driverdata);
    14741686    NSWindow *nswindow = windowData->nswindow;
    14751687
     
    14781690        [nswindow makeKeyAndOrderFront:nil];
    14791691        [windowData->listener resumeVisibleObservation];
    14801692    }
     1693#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14811694}}
     1695#else
     1696    [pool release];
     1697}
     1698#endif
    14821699
    14831700void
    14841701Cocoa_HideWindow(_THIS, SDL_Window * window)
     1702#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14851703{ @autoreleasepool
    14861704{
     1705#else
     1706{
     1707    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1708#endif
    14871709    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
    14881710
    14891711    [nswindow orderOut:nil];
     1712#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14901713}}
     1714#else
     1715    [pool release];
     1716}
     1717#endif
    14911718
    14921719void
    14931720Cocoa_RaiseWindow(_THIS, SDL_Window * window)
     1721#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14941722{ @autoreleasepool
    14951723{
     1724#else
     1725{
     1726    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1727#endif
    14961728    SDL_WindowData *windowData = ((SDL_WindowData *) window->driverdata);
    14971729    NSWindow *nswindow = windowData->nswindow;
    14981730
     
    15051737        [nswindow makeKeyAndOrderFront:nil];
    15061738    }
    15071739    [windowData->listener resumeVisibleObservation];
     1740#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15081741}}
     1742#else
     1743    [pool release];
     1744}
     1745#endif
    15091746
    15101747void
    15111748Cocoa_MaximizeWindow(_THIS, SDL_Window * window)
     1749#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15121750{ @autoreleasepool
    15131751{
     1752#else
     1753{
     1754    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1755#endif
    15141756    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    15151757    NSWindow *nswindow = windata->nswindow;
    15161758
    15171759    [nswindow zoom:nil];
    15181760
    15191761    ScheduleContextUpdates(windata);
     1762#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15201763}}
     1764#else
     1765    [pool release];
     1766}
     1767#endif
    15211768
    15221769void
    15231770Cocoa_MinimizeWindow(_THIS, SDL_Window * window)
     1771#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15241772{ @autoreleasepool
    15251773{
     1774#else
     1775{
     1776    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1777#endif
    15261778    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    15271779    NSWindow *nswindow = data->nswindow;
    15281780
     
    15311783    } else {
    15321784        [nswindow miniaturize:nil];
    15331785    }
     1786#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15341787}}
     1788#else
     1789    [pool release];
     1790}
     1791#endif
    15351792
    15361793void
    15371794Cocoa_RestoreWindow(_THIS, SDL_Window * window)
     1795#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15381796{ @autoreleasepool
    15391797{
     1798#else
     1799{
     1800    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1801#endif
    15401802    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
    15411803
    15421804    if ([nswindow isMiniaturized]) {
     
    15441806    } else if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) {
    15451807        [nswindow zoom:nil];
    15461808    }
     1809#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15471810}}
     1811#else
     1812    [pool release];
     1813}
     1814#endif
    15481815
    15491816void
    15501817Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
     1818#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15511819{ @autoreleasepool
    15521820{
     1821#else
     1822{
     1823    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1824#endif
    15531825    if (SetWindowStyle(window, GetWindowStyle(window))) {
    15541826        if (bordered) {
    15551827            Cocoa_SetWindowTitle(_this, window);  /* this got blanked out. */
    15561828        }
    15571829    }
     1830#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15581831}}
     1832#else
     1833    [pool release];
     1834}
     1835#endif
     1836
    15591837
    15601838void
    15611839Cocoa_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable)
     1840#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15621841{ @autoreleasepool
    15631842{
     1843#else
     1844{
     1845    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1846#endif
    15641847    /* Don't set this if we're in a space!
    15651848     * The window will get permanently stuck if resizable is false.
    15661849     * -flibit
     
    15701853    if (![listener isInFullscreenSpace]) {
    15711854        SetWindowStyle(window, GetWindowStyle(window));
    15721855    }
     1856#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15731857}}
     1858#else
     1859    [pool release];
     1860}
     1861#endif
     1862
    15741863
    15751864void
    15761865Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
     1866#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15771867{ @autoreleasepool
    15781868{
     1869#else
     1870{
     1871    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1872#endif
    15791873    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    15801874    NSWindow *nswindow = data->nswindow;
    15811875    NSRect rect;
     
    16461940    }
    16471941
    16481942    ScheduleContextUpdates(data);
     1943#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    16491944}}
     1945#else
     1946    [pool release];
     1947}
     1948#endif
    16501949
    16511950int
    16521951Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp)
     
    17362035
    17372036void
    17382037Cocoa_DestroyWindow(_THIS, SDL_Window * window)
     2038#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    17392039{ @autoreleasepool
    17402040{
     2041#else
     2042{
     2043    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     2044#endif
    17412045    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    17422046
    17432047    if (data) {
     
    17602064        SDL_free(data);
    17612065    }
    17622066    window->driverdata = NULL;
     2067#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    17632068}}
     2069#else
     2070    [pool release];
     2071}
     2072#endif
    17642073
    17652074SDL_bool
    17662075Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
     
    17922101
    17932102SDL_bool
    17942103Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state)
     2104#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    17952105{ @autoreleasepool
    17962106{
     2107#else
     2108{
     2109    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     2110#endif
    17972111    SDL_bool succeeded = SDL_FALSE;
    17982112    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    17992113
     
    18242138        succeeded = SDL_TRUE;
    18252139    }
    18262140
     2141#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     2142    [pool release];
     2143#endif
    18272144    return succeeded;
     2145#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    18282146}}
     2147#else
     2148}
     2149#endif
    18292150
    18302151int
    18312152Cocoa_SetWindowHitTest(SDL_Window * window, SDL_bool enabled)