Ticket #52210: SDL2-2.0.6_OSX_104.patch

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

Patch to build SDL 2.0.6 on Tiget 10.4.11 - tested to work !

  • configure

    Only in SDL2-2.0.6-tiger: Makefile
    Only in SDL2-2.0.6-tiger: Makefile.rules
    Only in SDL2-2.0.6-tiger: build
    Only in SDL2-2.0.6-tiger: config.log
    Only in SDL2-2.0.6-tiger: config.status
    diff -ru SDL2-2.0.6-orig/configure SDL2-2.0.6-tiger/configure
    old new  
    2433924339$as_echo "#define SDL_AUDIO_DRIVER_COREAUDIO 1" >>confdefs.h
    2434024340
    2434124341            SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.m"
    24342             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox"
     24342            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit"
    2434324343            SUMMARY_audio="${SUMMARY_audio} coreaudio"
    2434424344            have_audio=yes
    2434524345        fi
  • configure.in

    diff -ru SDL2-2.0.6-orig/configure.in SDL2-2.0.6-tiger/configure.in
    old new  
    37223722        if test x$enable_audio = xyes; then
    37233723            AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO, 1, [ ])
    37243724            SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.m"
    3725             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox"
     3725            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit"
    37263726            SUMMARY_audio="${SUMMARY_audio} coreaudio"
    37273727            have_audio=yes
    37283728        fi
  • include/SDL_config.h

    diff -ru SDL2-2.0.6-orig/include/SDL_config.h SDL2-2.0.6-tiger/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#define HAVE_GCC_ATOMICS 1
     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#define SDL_JOYSTICK_DISABLED 1
     208#define SDL_HAPTIC_DISABLED 1
     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/* #undef SDL_JOYSTICK_IOKIT */
     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/* #undef SDL_HAPTIC_IOKIT */
     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-tiger/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-tiger/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-tiger: libtool
    Only in SDL2-2.0.6-tiger: sdl2-config
    Only in SDL2-2.0.6-tiger: sdl2-config.cmake
    Only in SDL2-2.0.6-tiger: sdl2.pc
    diff -ru SDL2-2.0.6-orig/src/atomic/SDL_spinlock.c SDL2-2.0.6-tiger/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/audio/coreaudio/SDL_coreaudio.h

    diff -ru SDL2-2.0.6-orig/src/audio/coreaudio/SDL_coreaudio.h SDL2-2.0.6-tiger/src/audio/coreaudio/SDL_coreaudio.h
    old new  
    2929#define MACOSX_COREAUDIO 1
    3030#endif
    3131
     32#if defined(__ALTIVEC__) && !defined(MAC_OS_X_VERSION_10_5)
     33/* to cricumvent a bug in Mac OS X 10.4 SDK */
     34#define vector __vector
     35#include <CoreServices/CoreServices.h>
     36#undef vector
     37#endif
     38
    3239#if MACOSX_COREAUDIO
    3340#include <CoreAudio/CoreAudio.h>
    3441#include <CoreServices/CoreServices.h>
     
    4653struct SDL_PrivateAudioData
    4754{
    4855    SDL_Thread *thread;
     56#if defined(MAC_OS_X_VERSION_10_5)
    4957    AudioQueueRef audioQueue;
    5058    AudioQueueBufferRef *audioBuffer;
     59#else
     60    AudioUnit audioUnit;
     61    int audioUnitOpened;
     62#endif
    5163    void *buffer;
    5264    UInt32 bufferOffset;
    5365    UInt32 bufferSize;
  • src/audio/coreaudio/SDL_coreaudio.m

    diff -ru SDL2-2.0.6-orig/src/audio/coreaudio/SDL_coreaudio.m SDL2-2.0.6-tiger/src/audio/coreaudio/SDL_coreaudio.m
    old new  
    4141    }
    4242
    4343#if MACOSX_COREAUDIO
     44#if !defined(MAC_OS_X_VERSION_10_5)
     45#if 0
     46typedef void (*addDevFn)(const char *name, AudioDeviceID devId, void *data);
     47
     48static void
     49addToDevList(const char *name, AudioDeviceID devId, void *data)
     50{
     51    SDL_AddAudioDevice addfn = (SDL_AddAudioDevice) data;
     52    addfn(name);
     53}
     54#endif
     55
     56typedef struct
     57{
     58    const char *findname;
     59    AudioDeviceID devId;
     60    int found;
     61} FindDevIdData;
     62 
     63static void
     64findDevId(const char *name, const int iscapture, AudioDeviceID devId, void *_data)
     65{
     66    FindDevIdData *data = (FindDevIdData *) _data;
     67    if (!data->found) {
     68        if (SDL_strcmp(name, data->findname) == 0) {
     69            data->found = 1;
     70            data->devId = devId;
     71        }
     72    }
     73}
     74#endif
     75
    4476static const AudioObjectPropertyAddress devlist_address = {
    4577    kAudioHardwarePropertyDevices,
    4678    kAudioObjectPropertyScopeGlobal,
     
    213245    build_device_list(SDL_FALSE, addToDevList, NULL);
    214246}
    215247
     248
     249#if !defined(MAC_OS_X_VERSION_10_5)
     250static int
     251find_device_by_name(_THIS, const char *devname, int iscapture)
     252{
     253    AudioDeviceID devid = 0;
     254    OSStatus result = noErr;
     255    UInt32 size = 0;
     256    UInt32 alive = 0;
     257    pid_t pid = 0;
     258
     259    AudioObjectPropertyAddress addr = {
     260        0,
     261        kAudioObjectPropertyScopeGlobal,
     262        kAudioObjectPropertyElementMaster
     263    };
     264
     265    if (devname == NULL) {
     266        size = sizeof (AudioDeviceID);
     267        addr.mSelector =
     268            ((iscapture) ? kAudioHardwarePropertyDefaultInputDevice :
     269            kAudioHardwarePropertyDefaultOutputDevice);
     270        result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr,
     271                                            0, NULL, &size, &devid);
     272        CHECK_RESULT("AudioHardwareGetProperty (default device)");
     273    } else {
     274        FindDevIdData data;
     275        SDL_zero(data);
     276        data.findname = devname;
     277        build_device_list(iscapture, findDevId, &data);
     278        if (!data.found) {
     279            SDL_SetError("CoreAudio: No such audio device.");
     280            return 0;
     281        }
     282        devid = data.devId;
     283    }
     284
     285    addr.mSelector = kAudioDevicePropertyDeviceIsAlive;
     286    addr.mScope = iscapture ? kAudioDevicePropertyScopeInput :
     287                    kAudioDevicePropertyScopeOutput;
     288
     289    size = sizeof (alive);
     290    result = AudioObjectGetPropertyData(devid, &addr, 0, NULL, &size, &alive);
     291    CHECK_RESULT
     292        ("AudioDeviceGetProperty (kAudioDevicePropertyDeviceIsAlive)");
     293
     294    if (!alive) {
     295        SDL_SetError("CoreAudio: requested device exists, but isn't alive.");
     296        return 0;
     297    }
     298
     299    addr.mSelector = kAudioDevicePropertyHogMode;
     300    size = sizeof (pid);
     301    result = AudioObjectGetPropertyData(devid, &addr, 0, NULL, &size, &pid);
     302
     303    /* some devices don't support this property, so errors are fine here. */
     304    if ((result == noErr) && (pid != -1)) {
     305        SDL_SetError("CoreAudio: requested device is being hogged.");
     306        return 0;
     307    }
     308
     309    this->hidden->deviceID = devid;
     310    return 1;
     311}
     312#endif
     313
    216314static void
    217315build_device_change_list(const char *name, const int iscapture, AudioDeviceID devId, void *data)
    218316{
     
    404502#endif
    405503
    406504
     505#if defined(MAC_OS_X_VERSION_10_5)
    407506/* The AudioQueue callback */
    408507static void
    409508outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer)
     
    486585    AudioQueueEnqueueBuffer(this->hidden->audioQueue, inBuffer, 0, NULL);
    487586}
    488587
     588#else
     589/* OS X 10.4 stuff */
     590/* The CoreAudio callback */
     591static OSStatus
     592outputCallback(void *inRefCon,
     593               AudioUnitRenderActionFlags * ioActionFlags,
     594               const AudioTimeStamp * inTimeStamp,
     595               UInt32 inBusNumber, UInt32 inNumberFrames,
     596               AudioBufferList * ioData)
     597{
     598    SDL_AudioDevice *this = (SDL_AudioDevice *) inRefCon;
     599    AudioBuffer *abuf;
     600    UInt32 remaining, len;
     601    void *ptr;
     602    UInt32 i;
     603
     604    /* Only do anything if audio is enabled and not paused */
     605    if (!SDL_AtomicGet(&this->enabled) || SDL_AtomicGet(&this->paused)) {
     606    /*if (!this->enabled || this->paused) {*/
     607        for (i = 0; i < ioData->mNumberBuffers; i++) {
     608            abuf = &ioData->mBuffers[i];
     609            SDL_memset(abuf->mData, this->spec.silence, abuf->mDataByteSize);
     610        }
     611        return 0;
     612    }
     613
     614    /* No SDL conversion should be needed here, ever, since we accept
     615       any input format in OpenAudio, and leave the conversion to CoreAudio.
     616     */
     617    /*
     618       SDL_assert(!this->convert.needed);
     619       SDL_assert(this->spec.channels == ioData->mNumberChannels);
     620     */
     621
     622    for (i = 0; i < ioData->mNumberBuffers; i++) {
     623        abuf = &ioData->mBuffers[i];
     624        remaining = abuf->mDataByteSize;
     625        ptr = abuf->mData;
     626        while (remaining > 0) {
     627            if (this->hidden->bufferOffset >= this->hidden->bufferSize) {
     628                /* Generate the data */
     629                SDL_LockMutex(this->mixer_lock);
     630                (*this->spec.callback)(this->spec.userdata,
     631                            this->hidden->buffer, this->hidden->bufferSize);
     632                SDL_UnlockMutex(this->mixer_lock);
     633                this->hidden->bufferOffset = 0;
     634            }
     635
     636            len = this->hidden->bufferSize - this->hidden->bufferOffset;
     637            if (len > remaining)
     638                len = remaining;
     639            SDL_memcpy(ptr, (char *)this->hidden->buffer +
     640                       this->hidden->bufferOffset, len);
     641            ptr = (char *)ptr + len;
     642            remaining -= len;
     643            this->hidden->bufferOffset += len;
     644        }
     645    }
     646
     647    return 0;
     648}
     649
     650static OSStatus
     651inputCallback(void *inRefCon,
     652              AudioUnitRenderActionFlags * ioActionFlags,
     653              const AudioTimeStamp * inTimeStamp,
     654              UInt32 inBusNumber, UInt32 inNumberFrames,
     655              AudioBufferList * ioData)
     656{
     657    /* err = AudioUnitRender(afr->fAudioUnit, ioActionFlags, inTimeStamp, inBusNumber, inNumberFrames, afr->fAudioBuffer); */
     658    /* !!! FIXME: write me! */
     659    return noErr;
     660}
     661#endif
     662
    489663
    490664#if MACOSX_COREAUDIO
    491665static const AudioObjectPropertyAddress alive_address =
     
    528702static void
    529703COREAUDIO_CloseDevice(_THIS)
    530704{
     705#if defined(MAC_OS_X_VERSION_10_5)
    531706    const SDL_bool iscapture = this->iscapture;
    532707
    533708/* !!! FIXME: what does iOS do when a bluetooth audio device vanishes? Headphones unplugged? */
     
    565740    } else {
    566741        open_playback_devices--;
    567742    }
     743#else
     744    if (this->hidden != NULL) {
     745        if (this->hidden->audioUnitOpened) {
     746            OSStatus result = noErr;
     747            AURenderCallbackStruct callback;
     748            const AudioUnitElement output_bus = 0;
     749            const AudioUnitElement input_bus = 1;
     750            const int iscapture = this->iscapture;
     751            const AudioUnitElement bus =
     752                ((iscapture) ? input_bus : output_bus);
     753            const AudioUnitScope scope =
     754                ((iscapture) ? kAudioUnitScope_Output :
     755                 kAudioUnitScope_Input);
     756
     757            /* stop processing the audio unit */
     758            result = AudioOutputUnitStop(this->hidden->audioUnit);
     759
     760            /* Remove the input callback */
     761            SDL_memset(&callback, 0, sizeof(AURenderCallbackStruct));
     762            result = AudioUnitSetProperty(this->hidden->audioUnit,
     763                                          kAudioUnitProperty_SetRenderCallback,
     764                                          scope, bus, &callback,
     765                                          sizeof(callback));
     766
     767            #if MACOSX_COREAUDIO
     768            CloseComponent(this->hidden->audioUnit);
     769            #else
     770            AudioComponentInstanceDispose(this->hidden->audioUnit);
     771            #endif
     772
     773            this->hidden->audioUnitOpened = 0;
     774        }
     775        SDL_free(this->hidden->buffer);
     776        SDL_free(this->hidden);
     777        this->hidden = NULL;
     778    }
     779#endif
    568780}
    569781
    570782#if MACOSX_COREAUDIO
     
    620832    this->hidden->deviceID = devid;
    621833    return 1;
    622834}
     835
     836#if !defined(MAC_OS_X_VERSION_10_5)
     837static int
     838prepare_audiounit(_THIS, const char *devname, int iscapture,
     839                  const AudioStreamBasicDescription * strdesc)
     840{
     841    OSStatus result = noErr;
     842    AURenderCallbackStruct callback;
     843#if MACOSX_COREAUDIO
     844    ComponentDescription desc;
     845    Component comp = NULL;
     846#else
     847    AudioComponentDescription desc;
     848    AudioComponent comp = NULL;
     849#endif
     850    const AudioUnitElement output_bus = 0;
     851    const AudioUnitElement input_bus = 1;
     852    const AudioUnitElement bus = ((iscapture) ? input_bus : output_bus);
     853    const AudioUnitScope scope = ((iscapture) ? kAudioUnitScope_Output :
     854                                  kAudioUnitScope_Input);
     855
     856#if MACOSX_COREAUDIO
     857    if (!find_device_by_name(this, devname, iscapture)) {
     858        SDL_SetError("Couldn't find requested CoreAudio device");
     859        return 0;
     860    }
     861#endif
     862
     863    SDL_zero(desc);
     864    desc.componentType = kAudioUnitType_Output;
     865    desc.componentManufacturer = kAudioUnitManufacturer_Apple;
     866
     867#if MACOSX_COREAUDIO
     868    desc.componentSubType = kAudioUnitSubType_DefaultOutput;
     869    comp = FindNextComponent(NULL, &desc);
     870#else
     871    desc.componentSubType = kAudioUnitSubType_RemoteIO;
     872    comp = AudioComponentFindNext(NULL, &desc);
     873#endif
     874
     875    if (comp == NULL) {
     876        SDL_SetError("Couldn't find requested CoreAudio component");
     877        return 0;
     878    }
     879
     880    /* Open & initialize the audio unit */
     881#if MACOSX_COREAUDIO
     882    result = OpenAComponent(comp, &this->hidden->audioUnit);
     883    CHECK_RESULT("OpenAComponent");
     884#else
     885    /*
     886       AudioComponentInstanceNew only available on iPhone OS 2.0 and Mac OS X 10.6
     887       We can't use OpenAComponent on iPhone because it is not present
     888     */
     889    result = AudioComponentInstanceNew(comp, &this->hidden->audioUnit);
     890    CHECK_RESULT("AudioComponentInstanceNew");
     891#endif
     892
     893    this->hidden->audioUnitOpened = 1;
     894
     895#if MACOSX_COREAUDIO
     896    result = AudioUnitSetProperty(this->hidden->audioUnit,
     897                                  kAudioOutputUnitProperty_CurrentDevice,
     898                                  kAudioUnitScope_Global, 0,
     899                                  &this->hidden->deviceID,
     900                                  sizeof(AudioDeviceID));
     901    CHECK_RESULT
     902        ("AudioUnitSetProperty (kAudioOutputUnitProperty_CurrentDevice)");
     903#endif
     904
     905    /* Set the data format of the audio unit. */
     906    result = AudioUnitSetProperty(this->hidden->audioUnit,
     907                                  kAudioUnitProperty_StreamFormat,
     908                                  scope, bus, strdesc, sizeof(*strdesc));
     909    CHECK_RESULT("AudioUnitSetProperty (kAudioUnitProperty_StreamFormat)");
     910
     911    /* Set the audio callback */
     912    SDL_memset(&callback, 0, sizeof(AURenderCallbackStruct));
     913    callback.inputProc = ((iscapture) ? inputCallback : outputCallback);
     914    callback.inputProcRefCon = this;
     915    result = AudioUnitSetProperty(this->hidden->audioUnit,
     916                                  kAudioUnitProperty_SetRenderCallback,
     917                                  scope, bus, &callback, sizeof(callback));
     918    CHECK_RESULT
     919        ("AudioUnitSetProperty (kAudioUnitProperty_SetRenderCallback)");
     920
     921    /* Calculate the final parameters for this audio specification */
     922    SDL_CalculateAudioSpec(&this->spec);
     923
     924    /* Allocate a sample buffer */
     925    this->hidden->bufferOffset = this->hidden->bufferSize = this->spec.size;
     926    this->hidden->buffer = SDL_malloc(this->hidden->bufferSize);
     927
     928    result = AudioUnitInitialize(this->hidden->audioUnit);
     929    CHECK_RESULT("AudioUnitInitialize");
     930
     931    /* Finally, start processing of the audio unit */
     932    result = AudioOutputUnitStart(this->hidden->audioUnit);
     933    CHECK_RESULT("AudioOutputUnitStart");
     934
     935    /* We're running! */
     936    return 1;
     937}
     938#endif
    623939#endif
    624940
     941#if defined(MAC_OS_X_VERSION_10_5)
    625942static int
    626943prepare_audioqueue(_THIS)
    627944{
     
    7411058
    7421059    return 0;
    7431060}
     1061#endif
    7441062
    7451063static int
    7461064COREAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
     
    8201138    strdesc->mBytesPerFrame = strdesc->mBitsPerChannel * strdesc->mChannelsPerFrame / 8;
    8211139    strdesc->mBytesPerPacket = strdesc->mBytesPerFrame * strdesc->mFramesPerPacket;
    8221140
     1141#if defined(MAC_OS_X_VERSION_10_5)
    8231142#if MACOSX_COREAUDIO
    8241143    if (!prepare_device(this, handle, iscapture)) {
    8251144        return -1;
     
    8481167    }
    8491168
    8501169    return (this->hidden->thread != NULL) ? 0 : -1;
     1170#else
     1171    if (!prepare_audiounit(this, devname, iscapture, strdesc)) {
     1172        COREAUDIO_CloseDevice(this);
     1173        return -1;      /* prepare_audiounit() will call SDL_SetError()... */
     1174    }
     1175
     1176    return 0;   /* good to go. */
     1177#endif
    8511178}
    8521179
    8531180static void
     
    8701197
    8711198#if MACOSX_COREAUDIO
    8721199    impl->DetectDevices = COREAUDIO_DetectDevices;
     1200#if defined(MAC_OS_X_VERSION_10_5)
    8731201    AudioObjectAddPropertyListener(kAudioObjectSystemObject, &devlist_address, device_list_changed, NULL);
     1202#endif
    8741203#else
    8751204    impl->OnlyHasDefaultOutputDevice = 1;
    8761205    impl->OnlyHasDefaultCaptureDevice = 1;
    8771206#endif
    8781207
    8791208    impl->ProvidesOwnCallbackThread = 1;
     1209#if defined(MAC_OS_X_VERSION_10_5)
    8801210    impl->HasCaptureSupport = 1;
     1211#endif
    8811212
    8821213    return 1;   /* this audio target is available. */
    8831214}
  • src/file/cocoa/SDL_rwopsbundlesupport.m

    diff -ru SDL2-2.0.6-orig/src/file/cocoa/SDL_rwopsbundlesupport.m SDL2-2.0.6-tiger/src/file/cocoa/SDL_rwopsbundlesupport.m
    old new  
    2121#include "../../SDL_internal.h"
    2222
    2323#ifdef __APPLE__
     24
     25#if defined(__ALTIVEC__) && !defined(MAC_OS_X_VERSION_10_5)
     26/* to cricumvent a bug in Mac OS X 10.4 SDK */
     27#define vector __vector
     28#include <CoreServices/CoreServices.h>
     29#undef vector
     30#endif
     31
    2432#import <Foundation/Foundation.h>
    2533
    2634#include "SDL_rwopsbundlesupport.h"
     
    3341 Also, note the bundle layouts are different for iPhone and Mac.
    3442*/
    3543FILE* SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode)
     44#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    3645{ @autoreleasepool
     46#endif
    3747{
    3848    FILE* fp = NULL;
    3949
     
    4252        return fopen(file, mode);
    4353    }
    4454
     55#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     56    NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
     57#endif
    4558    NSFileManager* file_manager = [NSFileManager defaultManager];
    4659    NSString* resource_path = [[NSBundle mainBundle] resourcePath];
    4760
     
    5467        fp = fopen(file, mode);
    5568    }
    5669
     70#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     71    [autorelease_pool drain];
     72#endif
    5773    return fp;
     74#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     75}
     76#else
    5877}}
     78#endif
    5979
    6080#endif /* __APPLE__ */
    6181
  • src/filesystem/cocoa/SDL_sysfilesystem.m

    diff -ru SDL2-2.0.6-orig/src/filesystem/cocoa/SDL_sysfilesystem.m SDL2-2.0.6-tiger/src/filesystem/cocoa/SDL_sysfilesystem.m
    old new  
    2525/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    2626/* System dependent filesystem routines                                */
    2727
     28#if defined(__ALTIVEC__) && !defined(MAC_OS_X_VERSION_10_5)
     29/* to cricumvent a bug in Mac OS X 10.4 SDK */
     30#define vector __vector
     31#include <CoreServices/CoreServices.h>
     32#undef vector
     33#endif
     34
    2835#include <Foundation/Foundation.h>
    2936#include <sys/stat.h>
    3037#include <sys/types.h>
     
    3542
    3643char *
    3744SDL_GetBasePath(void)
     45#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    3846{ @autoreleasepool
    3947{
     48#else
     49{
     50    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     51#endif
    4052    NSBundle *bundle = [NSBundle mainBundle];
    4153    const char* baseType = [[[bundle infoDictionary] objectForKey:@"SDL_FILESYSTEM_BASE_DIR_TYPE"] UTF8String];
    4254    const char *base = NULL;
     
    6476        }
    6577    }
    6678
     79#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    6780    return retval;
    6881}}
     82#else
     83    [pool release];
     84    return retval;
     85}
     86#endif
    6987
    7088char *
    7189SDL_GetPrefPath(const char *org, const char *app)
     90#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    7291{ @autoreleasepool
    7392{
     93#else
     94{
     95    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     96#endif
    7497    if (!app) {
    7598        SDL_InvalidParamError("app");
    7699        return NULL;
     
    109132        }
    110133    }
    111134
     135#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    112136    return retval;
    113137}}
     138#else
     139    [pool release];
     140    return retval;
     141}
     142#endif
    114143
    115144#endif /* SDL_FILESYSTEM_COCOA */
    116145
  • src/joystick/darwin/SDL_sysjoystick.c

    diff -ru SDL2-2.0.6-orig/src/joystick/darwin/SDL_sysjoystick.c SDL2-2.0.6-tiger/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-tiger/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-tiger/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}
     
    141165- (void)windowWillClose:(NSNotification *)notification;
    142166{
    143167    NSWindow *win = (NSWindow*)[notification object];
     168#if !defined(MAC_OS_X_VERSION_10_5)
     169    int i;
     170#endif
    144171
    145172    if (![win isKeyWindow]) {
    146173        return;
     
    155182     * want to try its list first since the behavior in other apps is to only
    156183     * make the 'About' window key if no other windows are on-screen.
    157184     */
     185#if defined(MAC_OS_X_VERSION_10_5)
    158186    for (NSWindow *window in [NSApp orderedWindows]) {
     187#else
     188    /* old way to iterate */
     189    for (i = 0; i < [[NSApp orderedWindows] count]; i++) {
     190        NSWindow *window = [[NSApp orderedWindows] objectAtIndex:i];
     191#endif
    159192        if (window != win && [window canBecomeKeyWindow]) {
    160             if (![window isOnActiveSpace]) {
    161                 continue;
     193            if ([window respondsToSelector:@selector(isOnActiveSpace)]) {
     194                if (![window isOnActiveSpace]) {
     195                    continue;
     196                }
    162197            }
    163198            [window makeKeyAndOrderFront:self];
    164199            return;
     
    169204     * the active Space in z-order (including the 'About' window, if it's shown)
    170205     * and make the first one key.
    171206     */
     207    if ([NSWindow respondsToSelector:@selector(windowNumbersWithOptions:)]) {
     208#if defined(MAC_OS_X_VERSION_10_5)
    172209    for (NSNumber *num in [NSWindow windowNumbersWithOptions:0]) {
     210#else
     211    /* old way to iterate */
     212    for (i = 0; i < [[NSWindow windowNumbersWithOptions:0] count]; i++) {
     213        NSNumber *num = [[NSWindow windowNumbersWithOptions:0] objectAtIndex:i];
     214#endif
     215        if([num respondsToSelector:@selector(integerValue)]) {
    173216        NSWindow *window = [NSApp windowWithWindowNumber:[num integerValue]];
    174217        if (window && window != win && [window canBecomeKeyWindow]) {
    175218            [window makeKeyAndOrderFront:self];
    176219            return;
    177220        }
     221        }
     222    }
    178223    }
    179224}
    180225
    181226- (void)focusSomeWindow:(NSNotification *)aNotification
    182227{
     228    SDL_VideoDevice *device;
     229
    183230    /* HACK: Ignore the first call. The application gets a
    184231     * applicationDidBecomeActive: a little bit after the first window is
    185232     * created, and if we don't ignore it, a window that has been created with
     
    190237        return;
    191238    }
    192239
    193     SDL_VideoDevice *device = SDL_GetVideoDevice();
     240    device = SDL_GetVideoDevice();
    194241    if (device && device->windows) {
    195242        SDL_Window *window = device->windows;
    196243        int i;
     
    328375    [windowMenu release];
    329376
    330377
     378#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    331379    /* Add the fullscreen view toggle menu option, if supported */
    332380    if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
    333381        /* Create the view menu */
     
    345393
    346394        [viewMenu release];
    347395    }
     396#endif
    348397}
    349398
    350399void
    351400Cocoa_RegisterApp(void)
     401#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    352402{ @autoreleasepool
    353403{
     404#else
     405{
     406    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     407#endif
    354408    /* This can get called more than once! Be careful what you initialize! */
     409#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
     410    ProcessSerialNumber psn;
     411
     412    if (!GetCurrentProcess(&psn)) {
     413        TransformProcessType(&psn, kProcessTransformToForegroundApplication);
     414        SetFrontProcess(&psn);
     415    }
     416#endif
    355417
    356418    if (NSApp == nil) {
     419        NSDictionary *appDefaults;
    357420        [SDLApplication sharedApplication];
    358421        SDL_assert(NSApp != nil);
    359422
    360423        s_bShouldHandleEventsInSDLApplication = SDL_TRUE;
    361424
    362425        if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, SDL_FALSE)) {
     426#if defined(MAC_OS_X_VERSION_10_6)
    363427            [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
     428#endif
    364429            [NSApp activateIgnoringOtherApps:YES];
    365430                }
    366431               
     
    368433            CreateApplicationMenus();
    369434        }
    370435        [NSApp finishLaunching];
    371         NSDictionary *appDefaults = [[NSDictionary alloc] initWithObjectsAndKeys:
     436        appDefaults = [[NSDictionary alloc] initWithObjectsAndKeys:
    372437            [NSNumber numberWithBool:NO], @"AppleMomentumScrollSupported",
    373438            [NSNumber numberWithBool:NO], @"ApplePressAndHoldEnabled",
    374439            [NSNumber numberWithBool:YES], @"ApplePersistenceIgnoreState",
     
    388453            appDelegate->seenFirstActivate = YES;
    389454        }
    390455    }
     456#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    391457}}
     458#else
     459    [pool release];
     460}
     461#endif
    392462
    393463void
    394464Cocoa_PumpEvents(_THIS)
     465#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    395466{ @autoreleasepool
    396467{
     468#else
     469{
     470    NSAutoreleasePool *pool;
     471#endif
    397472#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
    398473    /* Update activity every 30 seconds to prevent screensaver */
    399474    SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
     
    407482    }
    408483#endif
    409484
     485#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     486    pool = [[NSAutoreleasePool alloc] init];
     487#endif
    410488    for ( ; ; ) {
     489#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     490        NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
     491#else
    411492        NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
     493#endif
    412494        if ( event == nil ) {
    413495            break;
    414496        }
     
    420502        // Pass events down to SDLApplication to be handled in sendEvent:
    421503        [NSApp sendEvent:event];
    422504    }
     505#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    423506}}
     507#else
     508    [pool release];
     509}
     510#endif
    424511
    425512void
    426513Cocoa_SuspendScreenSaver(_THIS)
     514#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    427515{ @autoreleasepool
    428516{
    429517    SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
     
    450538                                           &data->screensaver_assertion);
    451539    }
    452540}}
     541#else
     542{
     543}
     544#endif
    453545
    454546#endif /* SDL_VIDEO_DRIVER_COCOA */
    455547
  • src/video/cocoa/SDL_cocoakeyboard.m

    diff -ru SDL2-2.0.6-orig/src/video/cocoa/SDL_cocoakeyboard.m SDL2-2.0.6-tiger/src/video/cocoa/SDL_cocoakeyboard.m
    old new  
    3434/*#define DEBUG_IME NSLog */
    3535#define DEBUG_IME(...)
    3636
     37#if defined(MAC_OS_X_VERSION_10_5)
    3738@interface SDLTranslatorResponder : NSView <NSTextInputClient> {
     39#else
     40@interface SDLTranslatorResponder : NSView {
     41#endif
    3842    NSString *_markedText;
    3943    NSRange   _markedRange;
    4044    NSRange   _selectedRange;
     
    9397    return _selectedRange;
    9498}
    9599
     100- (void)unmarkText
     101{
     102    [_markedText release];
     103    _markedText = nil;
     104
     105    SDL_SendEditingText("", 0, 0);
     106}
     107
    96108- (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange;
    97109{
    98110    if ([aString isKindOfClass:[NSAttributedString class]]) {
     
    119131          selRange.location, selRange.length);
    120132}
    121133
    122 - (void)unmarkText
    123 {
    124     [_markedText release];
    125     _markedText = nil;
    126 
    127     SDL_SendEditingText("", 0, 0);
    128 }
    129 
    130134- (NSRect)firstRectForCharacterRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange;
    131135{
    132136    NSWindow *window = [self window];
     
    144148            NSStringFromRect(rect));
    145149
    146150#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     151#if defined(MAC_OS_X_VERSION_10_7)
    147152    if (![window respondsToSelector:@selector(convertRectToScreen:)]) {
     153#endif
    148154        rect.origin = [window convertBaseToScreen:rect.origin];
     155#if defined(MAC_OS_X_VERSION_10_7)
    149156    } else
    150157#endif
     158#endif
    151159    {
     160#if defined(MAC_OS_X_VERSION_10_7)
    152161        rect = [window convertRectToScreen:rect];
     162#endif
    153163    }
    154164
    155165    return rect;
     
    193203http://stackoverflow.com/questions/7190852/using-iohidmanager-to-get-modifier-key-events
    194204*/
    195205
     206#if defined(MAC_OS_X_VERSION_10_5)
    196207static IOHIDManagerRef s_hidManager = NULL;
    197208
    198209static void
     
    296307        CFRelease(keyboard);
    297308    }
    298309}
     310#endif
    299311
    300312/* This is a helper function for HandleModifierSide. This
    301313 * function reverts back to behavior before the distinction between
     
    504516static void
    505517UpdateKeymap(SDL_VideoData *data, SDL_bool send_event)
    506518{
     519#if defined(MAC_OS_X_VERSION_10_5)
    507520    TISInputSourceRef key_layout;
    508521    const void *chr_data;
    509522    int i;
     
    566579
    567580cleanup:
    568581    CFRelease(key_layout);
     582#endif
    569583}
    570584
    571585void
     
    583597    SDL_SetScancodeName(SDL_SCANCODE_RALT, "Right Option");
    584598    SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Command");
    585599
     600    if([NSEvent respondsToSelector:@selector(modifierFlags)]) {
    586601    data->modifierFlags = [NSEvent modifierFlags];
     602    } else {
     603    data->modifierFlags = 0;
     604    }
    587605    SDL_ToggleModState(KMOD_CAPS, (data->modifierFlags & NSEventModifierFlagCapsLock) != 0);
    588606
     607#if defined(MAC_OS_X_VERSION_10_5)
    589608    InitHIDCallback();
     609#endif
    590610}
    591611
    592612void
    593613Cocoa_StartTextInput(_THIS)
     614#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    594615{ @autoreleasepool
    595616{
     617#else
     618{
     619    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     620#endif
    596621    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    597622    SDL_Window *window = SDL_GetKeyboardFocus();
    598623    NSWindow *nswindow = nil;
     624    NSView *parentView;
    599625    if (window) {
    600626        nswindow = ((SDL_WindowData*)window->driverdata)->nswindow;
    601627    }
    602628
    603     NSView *parentView = [nswindow contentView];
     629    parentView = [nswindow contentView];
    604630
    605631    /* We only keep one field editor per process, since only the front most
    606632     * window can receive text input events, so it make no sense to keep more
     
    618644        [parentView addSubview: data->fieldEdit];
    619645        [nswindow makeFirstResponder: data->fieldEdit];
    620646    }
     647#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    621648}}
     649#else
     650    [pool release];
     651}
     652#endif
    622653
    623654void
    624655Cocoa_StopTextInput(_THIS)
     656#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    625657{ @autoreleasepool
     658#endif
    626659{
    627660    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    628661
    629662    if (data && data->fieldEdit) {
     663#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     664        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     665#endif
    630666        [data->fieldEdit removeFromSuperview];
    631667        [data->fieldEdit release];
    632668        data->fieldEdit = nil;
     669#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     670        [pool release];
     671#endif
    633672    }
     673#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    634674}}
     675#else
     676}
     677#endif
    635678
    636679void
    637680Cocoa_SetTextInputRect(_THIS, SDL_Rect *rect)
     
    649692void
    650693Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
    651694{
     695    unsigned short scancode;
     696    SDL_Scancode code;
     697#if 0
     698    const char *text;
     699#endif
    652700    SDL_VideoData *data = _this ? ((SDL_VideoData *) _this->driverdata) : NULL;
    653701    if (!data) {
    654702        return;  /* can happen when returning from fullscreen Space on shutdown */
    655703    }
    656704
    657     unsigned short scancode = [event keyCode];
    658     SDL_Scancode code;
    659 #if 0
    660     const char *text;
    661 #endif
     705    scancode = [event keyCode];
    662706
    663707    if ((scancode == 10 || scancode == 50) && KBGetLayoutType(LMGetKbdType()) == kKeyboardISO) {
    664708        /* see comments in SDL_cocoakeys.h */
     
    673717    }
    674718
    675719    switch ([event type]) {
     720#if !defined(MAC_OS_X_VERSION_10_12)
     721    case NSKeyDown:
     722#else
    676723    case NSEventTypeKeyDown:
     724#endif
    677725        if (![event isARepeat]) {
    678726            /* See if we need to rebuild the keyboard layout */
    679727            UpdateKeymap(data, SDL_TRUE);
     
    697745#endif
    698746        }
    699747        break;
     748#if !defined(MAC_OS_X_VERSION_10_12)
     749    case NSKeyUp:
     750#else
    700751    case NSEventTypeKeyUp:
     752#endif
    701753        SDL_SendKeyboardKey(SDL_RELEASED, code);
    702754        break;
     755#if !defined(MAC_OS_X_VERSION_10_12)
     756    case NSFlagsChanged:
     757#else
    703758    case NSEventTypeFlagsChanged:
     759#endif
    704760        /* FIXME CW 2007-08-14: check if this whole mess that takes up half of this file is really necessary */
    705761        HandleModifiers(_this, scancode, [event modifierFlags]);
    706762        break;
     
    712768void
    713769Cocoa_QuitKeyboard(_THIS)
    714770{
     771#if defined(MAC_OS_X_VERSION_10_5)
    715772    QuitHIDCallback();
     773#endif
    716774}
    717775
    718776#endif /* SDL_VIDEO_DRIVER_COCOA */
  • src/video/cocoa/SDL_cocoamessagebox.m

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

    diff -ru SDL2-2.0.6-orig/src/video/cocoa/SDL_cocoametalview.h SDL2-2.0.6-tiger/src/video/cocoa/SDL_cocoametalview.h
    old new  
    2929#ifndef SDL_cocoametalview_h_
    3030#define SDL_cocoametalview_h_
    3131
    32 #import "../SDL_sysvideo.h"
    33 #import "SDL_cocoawindow.h"
     32#include "../SDL_sysvideo.h"
     33#include "SDL_cocoawindow.h"
    3434
    3535#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_COCOA
    3636
  • src/video/cocoa/SDL_cocoametalview.m

    diff -ru SDL2-2.0.6-orig/src/video/cocoa/SDL_cocoametalview.m SDL2-2.0.6-tiger/src/video/cocoa/SDL_cocoametalview.m
    old new  
    2626 * how to add a CAMetalLayer backed view.
    2727 */
    2828
    29 #import "SDL_cocoametalview.h"
     29#include "SDL_cocoametalview.h"
    3030
    3131#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_COCOA
    3232
  • src/video/cocoa/SDL_cocoamodes.h

    diff -ru SDL2-2.0.6-orig/src/video/cocoa/SDL_cocoamodes.h SDL2-2.0.6-tiger/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-tiger/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)
     
    316376    NSScreen *screen = nil;
    317377
    318378    /* !!! FIXME: maybe track the NSScreen in SDL_DisplayData? */
     379#if defined(MAC_OS_X_VERSION_10_5)
    319380    for (NSScreen *i in screens) {
     381#else
     382    /* old way to iterate */
     383    int j;
     384    for (j = 0; j < [screens count]; j++) {
     385        NSScreen *i = [screens objectAtIndex:j];
     386#endif
    320387        const CGDirectDisplayID thisDisplay = (CGDirectDisplayID) [[[i deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue];
    321388        if (thisDisplay == cgdisplay) {
    322389            screen = i;
     
    329396        return -1;
    330397    }
    331398
     399    {
    332400    const CGRect cgrect = CGDisplayBounds(cgdisplay);
    333401    const NSRect frame = [screen visibleFrame];
    334402
     
    338406    rect->y = (int)(cgrect.origin.y + frame.origin.y);
    339407    rect->w = (int)frame.size.width;
    340408    rect->h = (int)frame.size.height;
     409    }
    341410
    342411    return 0;
    343412}
     
    391460    }
    392461#endif
    393462
     463#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    394464    modes = CGDisplayCopyAllDisplayModes(data->display, dict);
     465#else
     466    modes = CGDisplayAvailableModes(data->display);
     467#endif
    395468
    396469    if (dict != NULL) {
    397470        CFRelease(dict);
     
    405478        CVDisplayLinkCreateWithCGDisplay(data->display, &link);
    406479
    407480        for (i = 0; i < count; i++) {
     481#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    408482            CGDisplayModeRef moderef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
     483#else
     484            const void *moderef = CFArrayGetValueAtIndex(modes, i);
     485#endif
    409486            SDL_DisplayMode mode;
    410487            if (GetDisplayMode(_this, moderef, modes, link, &mode)) {
     488                #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    411489                CGDisplayModeRetain(moderef);
     490                #endif
    412491                SDL_AddDisplayMode(display, &mode);
    413492            }
    414493        }
     
    433512
    434513    if (data == display->desktop_mode.driverdata) {
    435514        /* Restoring desktop mode */
     515#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    436516        CGDisplaySetDisplayMode(displaydata->display, data->moderef, NULL);
     517#else
     518        CGDisplaySwitchToMode(displaydata->display, data->moderef);
     519#endif
    437520
    438521        if (CGDisplayIsMain(displaydata->display)) {
    439522            CGReleaseAllDisplays();
     
    458541        }
    459542
    460543        /* Do the physical switch */
     544#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    461545        result = CGDisplaySetDisplayMode(displaydata->display, data->moderef, NULL);
     546#else
     547        result = CGDisplaySwitchToMode(displaydata->display, data->moderef);
     548#endif
    462549        if (result != kCGErrorSuccess) {
    463550            CG_SetError("CGDisplaySwitchToMode()", result);
    464551            goto ERR_NO_SWITCH;
     
    503590        }
    504591
    505592        mode = (SDL_DisplayModeData *) display->desktop_mode.driverdata;
     593        #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    506594        CGDisplayModeRelease(mode->moderef);
     595        #endif
    507596
    508597        for (j = 0; j < display->num_display_modes; j++) {
    509598            mode = (SDL_DisplayModeData*) display->display_modes[j].driverdata;
     599        #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    510600            CGDisplayModeRelease(mode->moderef);
     601        #endif
    511602        }
    512603
    513604    }
  • src/video/cocoa/SDL_cocoamouse.h

    diff -ru SDL2-2.0.6-orig/src/video/cocoa/SDL_cocoamouse.h SDL2-2.0.6-tiger/src/video/cocoa/SDL_cocoamouse.h
    old new  
    2525
    2626#include "SDL_cocoavideo.h"
    2727
     28#if !defined(MAC_OS_X_VERSION_10_5)
     29typedef float CGFloat;
     30#endif
     31
    2832extern void Cocoa_InitMouse(_THIS);
    2933extern void Cocoa_HandleMouseEvent(_THIS, NSEvent * event);
    3034extern void Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent * event);
  • src/video/cocoa/SDL_cocoamouse.m

    diff -ru SDL2-2.0.6-orig/src/video/cocoa/SDL_cocoamouse.m SDL2-2.0.6-tiger/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
     
    147176        nscursor = [NSCursor closedHandCursor];
    148177        break;
    149178    case SDL_SYSTEM_CURSOR_NO:
     179        if ([NSCursor respondsToSelector:@selector(operationNotAllowedCursor)]) {
    150180        nscursor = [NSCursor operationNotAllowedCursor];
     181        }
    151182        break;
    152183    case SDL_SYSTEM_CURSOR_HAND:
    153184        nscursor = [NSCursor pointingHandCursor];
     
    166197        }
    167198    }
    168199
     200#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     201    [pool release];
     202#endif
    169203    return cursor;
     204#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    170205}}
     206#else
     207}
     208#endif
    171209
    172210static void
    173211Cocoa_FreeCursor(SDL_Cursor * cursor)
     212#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    174213{ @autoreleasepool
    175214{
     215#else
     216{
     217    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     218#endif
    176219    NSCursor *nscursor = (NSCursor *)cursor->driverdata;
    177220
    178221    [nscursor release];
    179222    SDL_free(cursor);
     223#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    180224}}
     225#else
     226    [pool release];
     227}
     228#endif
    181229
    182230static int
    183231Cocoa_ShowCursor(SDL_Cursor * cursor)
     232#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    184233{ @autoreleasepool
    185234{
     235#else
     236{
     237    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     238#endif
    186239    SDL_VideoDevice *device = SDL_GetVideoDevice();
    187240    SDL_Window *window = (device ? device->windows : NULL);
    188241    for (; window != NULL; window = window->next) {
     
    193246                                                waitUntilDone:NO];
    194247        }
    195248    }
     249#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     250    [pool release];
     251#endif
    196252    return 0;
     253#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    197254}}
     255#else
     256}
     257#endif
    198258
    199259static SDL_Window *
    200260SDL_FindWindowAtPoint(const int x, const int y)
     
    214274static int
    215275Cocoa_WarpMouseGlobal(int x, int y)
    216276{
     277    const CGPoint point = CGPointMake((float)x, (float)y);
    217278    SDL_Mouse *mouse = SDL_GetMouse();
    218279    if (mouse->focus) {
    219280        SDL_WindowData *data = (SDL_WindowData *) mouse->focus->driverdata;
     
    223284            return 0;
    224285        }
    225286    }
    226     const CGPoint point = CGPointMake((float)x, (float)y);
    227287
    228288    Cocoa_HandleMouseWarp(point.x, point.y);
    229289
     
    261321static int
    262322Cocoa_SetRelativeMouseMode(SDL_bool enabled)
    263323{
     324    CGError result;
     325    SDL_WindowData *data;
    264326    /* We will re-apply the relative mode when the window gets focus, if it
    265327     * doesn't have focus right now.
    266328     */
     
    272334    /* We will re-apply the relative mode when the window finishes being moved,
    273335     * if it is being moved right now.
    274336     */
    275     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     337    data = (SDL_WindowData *) window->driverdata;
    276338    if ([data->listener isMoving]) {
    277339        return 0;
    278340    }
    279341
    280     CGError result;
    281342    if (enabled) {
    282343        DLog("Turning on.");
    283344        result = CGAssociateMouseAndMouseCursorPosition(NO);
     
    311372static Uint32
    312373Cocoa_GetGlobalMouseState(int *x, int *y)
    313374{
    314     const NSUInteger cocoaButtons = [NSEvent pressedMouseButtons];
     375    NSUInteger cocoaButtons = 0;
    315376    const NSPoint cocoaLocation = [NSEvent mouseLocation];
    316377    Uint32 retval = 0;
     378#if !defined(MAC_OS_X_VERSION_10_5)
     379    int i;
     380#endif
    317381
     382    if ([NSEvent respondsToSelector:@selector(pressedMouseButtons)]) {
     383        cocoaButtons = [NSEvent pressedMouseButtons];
     384    }
     385
     386#if defined(MAC_OS_X_VERSION_10_5)
    318387    for (NSScreen *screen in [NSScreen screens]) {
     388#else
     389    /* old way to iterate */
     390    for (i = 0; i < [[NSScreen screens] count]; i++) {
     391        NSScreen *screen = [[NSScreen screens] objectAtIndex:i];
     392#endif
    319393        NSRect frame = [screen frame];
    320394        if (NSMouseInRect(cocoaLocation, frame, NO)) {
    321395            *x = (int) cocoaLocation.x;
     
    336410void
    337411Cocoa_InitMouse(_THIS)
    338412{
     413    SDL_MouseData *driverdata;
     414    NSPoint location;
    339415    SDL_Mouse *mouse = SDL_GetMouse();
    340416
    341417    mouse->driverdata = SDL_calloc(1, sizeof(SDL_MouseData));
     
    354430
    355431    Cocoa_InitMouseEventTap(mouse->driverdata);
    356432
    357     SDL_MouseData *driverdata = (SDL_MouseData*)mouse->driverdata;
    358     const NSPoint location =  [NSEvent mouseLocation];
     433    driverdata = (SDL_MouseData*)mouse->driverdata;
     434    location =  [NSEvent mouseLocation];
    359435    driverdata->lastMoveX = location.x;
    360436    driverdata->lastMoveY = location.y;
    361437}
     
    363439void
    364440Cocoa_HandleMouseEvent(_THIS, NSEvent *event)
    365441{
     442    SDL_Mouse *mouse;
     443    SDL_MouseData *driverdata;
     444    SDL_bool seenWarp;
    366445    switch ([event type]) {
     446#if !defined(MAC_OS_X_VERSION_10_12)
     447        case NSMouseMoved:
     448        case NSLeftMouseDragged:
     449        case NSRightMouseDragged:
     450        case NSOtherMouseDragged:
     451#else
    367452        case NSEventTypeMouseMoved:
    368453        case NSEventTypeLeftMouseDragged:
    369454        case NSEventTypeRightMouseDragged:
    370455        case NSEventTypeOtherMouseDragged:
     456#endif
    371457            break;
    372458
    373459        default:
     
    375461            return;
    376462    }
    377463
    378     SDL_Mouse *mouse = SDL_GetMouse();
    379     SDL_MouseData *driverdata = (SDL_MouseData*)mouse->driverdata;
     464    mouse = SDL_GetMouse();
     465    driverdata = (SDL_MouseData*)mouse->driverdata;
    380466    if (!driverdata) {
    381467        return;  /* can happen when returning from fullscreen Space on shutdown */
    382468    }
    383469
    384     const SDL_bool seenWarp = driverdata->seenWarp;
     470    seenWarp = driverdata->seenWarp;
    385471    driverdata->seenWarp = NO;
    386472
     473    {
     474    float deltaX;
     475    float deltaY;
    387476    const NSPoint location =  [NSEvent mouseLocation];
    388477    const CGFloat lastMoveX = driverdata->lastMoveX;
    389478    const CGFloat lastMoveY = driverdata->lastMoveY;
     
    404493        }
    405494    }
    406495
    407     float deltaX = [event deltaX];
    408     float deltaY = [event deltaY];
     496    deltaX = [event deltaX];
     497    deltaY = [event deltaY];
    409498
    410499    if (seenWarp) {
    411500        deltaX += (lastMoveX - driverdata->lastWarpX);
     
    415504    }
    416505
    417506    SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 1, (int)deltaX, (int)deltaY);
     507    }
    418508}
    419509
    420510void
  • src/video/cocoa/SDL_cocoaopengl.m

    diff -ru SDL2-2.0.6-orig/src/video/cocoa/SDL_cocoaopengl.m SDL2-2.0.6-tiger/src/video/cocoa/SDL_cocoaopengl.m
    old new  
    150150
    151151SDL_GLContext
    152152Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
     153#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    153154{ @autoreleasepool
    154155{
     156#else
     157{
     158    NSAutoreleasePool *pool;
     159#endif
    155160    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    156161    SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
     162#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1670
    157163    SDL_bool lion_or_later = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6;
     164#else
     165    SDL_bool lion_or_later = SDL_FALSE;
     166#endif
    158167    NSOpenGLPixelFormatAttribute attr[32];
    159168    NSOpenGLPixelFormat *fmt;
    160169    SDLOpenGLContext *context;
     
    173182        return NULL;
    174183    }
    175184
     185#if defined(MAC_OS_X_VERSION_10_5)
    176186    attr[i++] = NSOpenGLPFAAllowOfflineRenderers;
     187#endif
    177188
     189#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     190    pool = [[NSAutoreleasePool alloc] init];
     191#endif
    178192    /* specify a profile if we're on Lion (10.7) or later. */
     193#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    179194    if (lion_or_later) {
    180195        NSOpenGLPixelFormatAttribute profile = NSOpenGLProfileVersionLegacy;
    181196        if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) {
     
    184199        attr[i++] = NSOpenGLPFAOpenGLProfile;
    185200        attr[i++] = profile;
    186201    }
     202#endif
    187203
    188204    attr[i++] = NSOpenGLPFAColorSize;
    189205    attr[i++] = SDL_BYTESPERPIXEL(display->current_mode.format)*8;
     
    239255    fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
    240256    if (fmt == nil) {
    241257        SDL_SetError("Failed creating OpenGL pixel format");
     258#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     259        [pool release];
     260#endif
    242261        return NULL;
    243262    }
    244263
     
    252271
    253272    if (context == nil) {
    254273        SDL_SetError("Failed creating OpenGL context");
     274#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     275        [pool release];
     276#endif
    255277        return NULL;
    256278    }
    257279
    258280    if ( Cocoa_GL_MakeCurrent(_this, window, context) < 0 ) {
    259281        Cocoa_GL_DeleteContext(_this, context);
    260282        SDL_SetError("Failed making OpenGL context current");
     283#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     284        [pool release];
     285#endif
    261286        return NULL;
    262287    }
    263288
     
    272297        if (!glGetStringFunc) {
    273298            Cocoa_GL_DeleteContext(_this, context);
    274299            SDL_SetError ("Failed getting OpenGL glGetString entry point");
     300#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     301            [pool release];
     302#endif
    275303            return NULL;
    276304        }
    277305
     
    279307        if (glversion == NULL) {
    280308            Cocoa_GL_DeleteContext(_this, context);
    281309            SDL_SetError ("Failed getting OpenGL context version");
     310#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     311            [pool release];
     312#endif
    282313            return NULL;
    283314        }
    284315
    285316        if (SDL_sscanf(glversion, "%d.%d", &glversion_major, &glversion_minor) != 2) {
    286317            Cocoa_GL_DeleteContext(_this, context);
    287318            SDL_SetError ("Failed parsing OpenGL context version");
     319#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     320            [pool release];
     321#endif
    288322            return NULL;
    289323        }
    290324
     
    292326           ((glversion_major == _this->gl_config.major_version) && (glversion_minor < _this->gl_config.minor_version))) {
    293327            Cocoa_GL_DeleteContext(_this, context);
    294328            SDL_SetError ("Failed creating OpenGL context at version requested");
     329#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     330            [pool release];
     331#endif
    295332            return NULL;
    296333        }
    297334
     
    301338        /*_this->gl_config.major_version = glversion_major;*/
    302339        /*_this->gl_config.minor_version = glversion_minor;*/
    303340    }
     341#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     342    [pool release];
     343#endif
    304344    return context;
     345#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     346}
     347#else
    305348}}
     349#endif
    306350
    307351int
    308352Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
     353#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    309354{ @autoreleasepool
    310355{
     356#else
     357{
     358    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     359#endif
    311360    if (context) {
    312361        SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context;
    313362        [nscontext setWindow:window];
     
    317366        [NSOpenGLContext clearCurrentContext];
    318367    }
    319368
     369#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     370    [pool release];
     371#endif
    320372    return 0;
     373#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    321374}}
     375#else
     376}
     377#endif
    322378
    323379void
    324380Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
     
    329385
    330386    /* This gives us the correct viewport for a Retina-enabled view, only
    331387     * supported on 10.7+. */
     388#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    332389    if ([contentView respondsToSelector:@selector(convertRectToBacking:)]) {
    333390        viewport = [contentView convertRectToBacking:viewport];
    334391    }
     392#endif
    335393
    336394    if (w) {
    337395        *w = viewport.size.width;
     
    344402
    345403int
    346404Cocoa_GL_SetSwapInterval(_THIS, int interval)
     405#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    347406{ @autoreleasepool
     407#endif
    348408{
    349409    NSOpenGLContext *nscontext;
    350410    GLint value;
     
    353413    if (interval < 0) {  /* no extension for this on Mac OS X at the moment. */
    354414        return SDL_SetError("Late swap tearing currently unsupported");
    355415    }
     416#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     417    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     418#endif
    356419
    357420    nscontext = (NSOpenGLContext*)SDL_GL_GetCurrentContext();
    358421    if (nscontext != nil) {
     
    363426        status = SDL_SetError("No current OpenGL context");
    364427    }
    365428
     429#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     430    [pool release];
     431#endif
    366432    return status;
     433#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    367434}}
     435#else
     436}
     437#endif
    368438
    369439int
    370440Cocoa_GL_GetSwapInterval(_THIS)
     441#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    371442{ @autoreleasepool
    372443{
     444#else
     445{
     446    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     447#endif
    373448    NSOpenGLContext *nscontext;
    374449    GLint value;
    375450    int status = 0;
     
    380455        status = (int)value;
    381456    }
    382457
     458#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     459    [pool release];
     460#endif
    383461    return status;
     462#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    384463}}
     464#else
     465}
     466#endif
    385467
    386468int
    387469Cocoa_GL_SwapWindow(_THIS, SDL_Window * window)
     470#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    388471{ @autoreleasepool
    389472{
     473#else
     474{
     475    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     476#endif
    390477    SDLOpenGLContext* nscontext = (SDLOpenGLContext*)SDL_GL_GetCurrentContext();
    391478    [nscontext flushBuffer];
    392479    [nscontext updateIfNeeded];
     480#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     481    [pool release];
     482#endif
    393483    return 0;
     484#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    394485}}
     486#else
     487}
     488#endif
    395489
    396490void
    397491Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context)
     492#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    398493{ @autoreleasepool
    399494{
     495#else
     496{
     497    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     498#endif
    400499    SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context;
    401500
    402501    [nscontext setWindow:NULL];
    403502    [nscontext release];
     503#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    404504}}
     505#else
     506    [pool release];
     507}
     508#endif
    405509
    406510#endif /* SDL_VIDEO_OPENGL_CGL */
    407511
  • src/video/cocoa/SDL_cocoashape.m

    diff -ru SDL2-2.0.6-orig/src/video/cocoa/SDL_cocoashape.m SDL2-2.0.6-tiger/src/video/cocoa/SDL_cocoashape.m
    old new  
    3535    SDL_WindowData* windata = (SDL_WindowData*)window->driverdata;
    3636    [windata->nswindow setOpaque:NO];
    3737
     38    if ([windata->nswindow respondsToSelector:@selector(setStyleMask:)]) {
    3839    [windata->nswindow setStyleMask:NSWindowStyleMaskBorderless];
     40    }
    3941
    4042    SDL_WindowShaper* result = result = malloc(sizeof(SDL_WindowShaper));
    4143    result->window = window;
     
    7375
    7476int
    7577Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode)
     78#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    7679{ @autoreleasepool
    7780{
     81#else
     82{
     83    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     84#endif
    7885    SDL_ShapeData* data = (SDL_ShapeData*)shaper->driverdata;
    7986    SDL_WindowData* windata = (SDL_WindowData*)shaper->window->driverdata;
    8087    SDL_CocoaClosure closure;
     
    97104    SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure);
    98105    [closure.path addClip];
    99106
     107#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     108    [pool release];
     109#endif
    100110    return 0;
     111#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    101112}}
     113#else
     114}
     115#endif
    102116
    103117int
    104118Cocoa_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-tiger/src/video/cocoa/SDL_cocoavideo.h
    old new  
    2525
    2626#include "SDL_opengl.h"
    2727
     28#if defined(__ALTIVEC__) && !defined(MAC_OS_X_VERSION_10_5)
     29/* to cricumvent a bug in Mac OS X 10.4 SDK */
     30#define vector __vector
     31#include <CoreServices/CoreServices.h>
     32#undef vector
     33#endif
    2834#include <ApplicationServices/ApplicationServices.h>
    2935#include <IOKit/pwr_mgt/IOPMLib.h>
    3036#include <Cocoa/Cocoa.h>
     
    4046#include "SDL_cocoaopengl.h"
    4147#include "SDL_cocoawindow.h"
    4248
     49#if !defined(MAC_OS_X_VERSION_10_5)
     50typedef long int NSInteger;
     51typedef unsigned int NSUInteger;
     52#endif
     53
    4354#ifndef MAC_OS_X_VERSION_10_12
    4455#define DECLARE_EVENT(name) static const NSEventType NSEventType##name = NS##name
    4556DECLARE_EVENT(LeftMouseDown);
     
    5869DECLARE_EVENT(FlagsChanged);
    5970#undef DECLARE_EVENT
    6071
     72#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    6173static const NSEventMask NSEventMaskAny = NSAnyEventMask;
     74#endif
    6275
    6376#define DECLARE_MODIFIER_FLAG(name) static const NSUInteger NSEventModifierFlag##name = NS##name##KeyMask
    6477DECLARE_MODIFIER_FLAG(Shift);
     
    7992DECLARE_WINDOW_MASK(Resizable);
    8093DECLARE_WINDOW_MASK(TexturedBackground);
    8194DECLARE_WINDOW_MASK(UnifiedTitleAndToolbar);
     95#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    8296DECLARE_WINDOW_MASK(FullScreen);
     97#endif
    8398/*DECLARE_WINDOW_MASK(FullSizeContentView);*/ /* Not used, fails compile on older SDKs */
    8499static const unsigned int NSWindowStyleMaskUtilityWindow = NSUtilityWindowMask;
    85100static const unsigned int NSWindowStyleMaskDocModalWindow = NSDocModalWindowMask;
     101#if defined(MAC_OS_X_VERSION_10_5)
    86102static const unsigned int NSWindowStyleMaskHUDWindow = NSHUDWindowMask;
     103#endif
    87104#undef DECLARE_WINDOW_MASK
    88105
    89106#define DECLARE_ALERT_STYLE(name) static const NSUInteger NSAlertStyle##name = NS##name##AlertStyle
     
    106123    NSInteger clipboard_count;
    107124    Uint32 screensaver_activity;
    108125    BOOL screensaver_use_iopm;
     126#if defined(MAC_OS_X_VERSION_10_5)
    109127    IOPMAssertionID screensaver_assertion;
     128#endif
    110129
    111130} SDL_VideoData;
    112131
  • src/video/cocoa/SDL_cocoavideo.m

    diff -ru SDL2-2.0.6-orig/src/video/cocoa/SDL_cocoavideo.m SDL2-2.0.6-tiger/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-tiger/src/video/cocoa/SDL_cocoawindow.h
    old new  
    2323#ifndef SDL_cocoawindow_h_
    2424#define SDL_cocoawindow_h_
    2525
     26#if defined(__ALTIVEC__) && !defined(MAC_OS_X_VERSION_10_5)
     27/* to cricumvent a bug in Mac OS X 10.4 SDK */
     28#define vector __vector
     29#include <CoreServices/CoreServices.h>
     30#undef vector
     31#endif
     32
    2633#import <Cocoa/Cocoa.h>
    2734
    2835typedef struct SDL_WindowData SDL_WindowData;
     
    3542    PENDING_OPERATION_MINIMIZE
    3643} PendingWindowOperation;
    3744
     45#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    3846@interface Cocoa_WindowListener : NSResponder <NSWindowDelegate> {
     47#else
     48@interface Cocoa_WindowListener : NSResponder {
     49#endif
    3950    SDL_WindowData *_data;
    4051    BOOL observingVisible;
    4152    BOOL wasCtrlLeft;
     
    7586-(void) windowDidEnterFullScreen:(NSNotification *) aNotification;
    7687-(void) windowWillExitFullScreen:(NSNotification *) aNotification;
    7788-(void) windowDidExitFullScreen:(NSNotification *) aNotification;
     89#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    7890-(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions;
     91#endif
    7992
    8093/* See if event is in a drag area, toggle on window dragging. */
    8194-(BOOL) processHitTest:(NSEvent *)theEvent;
     
    98111-(void) touchesCancelledWithEvent:(NSEvent *) theEvent;
    99112
    100113/* Touch event handling */
     114#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    101115-(void) handleTouches:(NSTouchPhase) phase withEvent:(NSEvent*) theEvent;
     116#else
     117typedef enum {
     118    COCOA_TOUCH_DOWN,
     119    COCOA_TOUCH_UP,
     120    COCOA_TOUCH_MOVE,
     121    COCOA_TOUCH_CANCELLED
     122} cocoaTouchType;
     123-(void) handleTouches:(cocoaTouchType)type withEvent:(NSEvent*) event;
     124#endif
    102125
    103126@end
    104127/* *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-tiger/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];
    144155    SDL_Window *sdlwindow = [self findSDLWindow];
     156    NSData *data;
     157#if !defined(MAC_OS_X_VERSION_10_5)
     158    NSArray *array;
     159    int i;
     160#endif
    145161
    146162    if (desiredType == nil) {
    147163        return NO;  /* can't accept anything that's being dropped here. */
    148164    }
    149165
    150     NSData *data = [pasteboard dataForType:desiredType];
     166    data = [pasteboard dataForType:desiredType];
    151167    if (data == nil) {
    152168        return NO;
    153169    }
    154170
     171#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     172    pool = [[NSAutoreleasePool alloc] init];
     173#endif
     174
    155175    SDL_assert([desiredType isEqualToString:NSFilenamesPboardType]);
     176#if defined(MAC_OS_X_VERSION_10_5)
    156177    NSArray *array = [pasteboard propertyListForType:@"NSFilenamesPboardType"];
    157178
    158179    for (NSString *path in array) {
     180#else
     181    array = [pasteboard propertyListForType:@"NSFilenamesPboardType"];
     182    /* old way to iterate */
     183    for (i = 0; i < [array count]; i++) {
     184        NSString *path = [array objectAtIndex:i];
     185#endif
    159186        NSURL *fileURL = [NSURL fileURLWithPath:path];
     187#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    160188        NSNumber *isAlias = nil;
    161189
    162190        [fileURL getResourceValue:&isAlias forKey:NSURLIsAliasFileKey error:nil];
     
    177205                }
    178206            }
    179207        }
     208#endif
    180209
    181210        if (!SDL_SendDropFile(sdlwindow, [[fileURL path] UTF8String])) {
     211#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     212            [pool release];
     213#endif
    182214            return NO;
    183215        }
    184216    }
    185217
     218#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     219    [pool release];
     220#endif
    186221    SDL_SendDropComplete(sdlwindow);
    187222    return YES;
     223#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     224}
     225#else
    188226}}
     227#endif
    189228
    190229- (BOOL)wantsPeriodicDraggingUpdates
    191230{
     
    226265    NSOpenGLContext *currentContext = [NSOpenGLContext currentContext];
    227266    NSMutableArray *contexts = data->nscontexts;
    228267    @synchronized (contexts) {
     268#if defined(MAC_OS_X_VERSION_10_5)
    229269        for (SDLOpenGLContext *context in contexts) {
     270#else
     271        /* old way to iterate */
     272        int i;
     273        for (i = 0; i < [contexts count]; i++) {
     274            SDLOpenGLContext *context = [contexts objectAtIndex:i];
     275#endif
    230276            if (context == currentContext) {
    231277                [context update];
    232278            } else {
     
    274320        [[nswindow contentView] setNextResponder:nil];
    275321    }
    276322
     323    if ([nswindow respondsToSelector:@selector(setStyleMask:)]) {
    277324    [nswindow setStyleMask:style];
     325    }
    278326
    279327    /* The view responder chain gets messed with during setStyleMask */
    280328    if ([[nswindow contentView] nextResponder] != data->listener) {
     
    313361        [center addObserver:self selector:@selector(windowDidDeminiaturize:) name:NSWindowDidDeminiaturizeNotification object:window];
    314362        [center addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:window];
    315363        [center addObserver:self selector:@selector(windowDidResignKey:) name:NSWindowDidResignKeyNotification object:window];
     364#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    316365        [center addObserver:self selector:@selector(windowDidChangeBackingProperties:) name:NSWindowDidChangeBackingPropertiesNotification object:window];
    317366        [center addObserver:self selector:@selector(windowWillEnterFullScreen:) name:NSWindowWillEnterFullScreenNotification object:window];
    318367        [center addObserver:self selector:@selector(windowDidEnterFullScreen:) name:NSWindowDidEnterFullScreenNotification object:window];
    319368        [center addObserver:self selector:@selector(windowWillExitFullScreen:) name:NSWindowWillExitFullScreenNotification object:window];
    320369        [center addObserver:self selector:@selector(windowDidExitFullScreen:) name:NSWindowDidExitFullScreenNotification object:window];
     370#endif
    321371        [center addObserver:self selector:@selector(windowDidFailToEnterFullScreen:) name:@"NSWindowDidFailToEnterFullScreenNotification" object:window];
    322372        [center addObserver:self selector:@selector(windowDidFailToExitFullScreen:) name:@"NSWindowDidFailToExitFullScreenNotification" object:window];
    323373    } else {
     
    338388
    339389    [view setNextResponder:self];
    340390
     391    if ([view respondsToSelector:@selector(setAcceptsTouchEvents:)]) {
    341392    [view setAcceptsTouchEvents:YES];
     393    }
    342394}
    343395
    344396- (void)observeValueForKeyPath:(NSString *)keyPath
     
    408460    inFullscreenTransition = YES;
    409461
    410462    /* you need to be FullScreenPrimary, or toggleFullScreen doesn't work. Unset it again in windowDidExitFullScreen. */
     463#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    411464    [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
     465#endif
    412466    [nswindow performSelectorOnMainThread: @selector(toggleFullScreen:) withObject:nswindow waitUntilDone:NO];
    413467    return YES;
    414468}
     
    444498        [center removeObserver:self name:NSWindowDidDeminiaturizeNotification object:window];
    445499        [center removeObserver:self name:NSWindowDidBecomeKeyNotification object:window];
    446500        [center removeObserver:self name:NSWindowDidResignKeyNotification object:window];
     501#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    447502        [center removeObserver:self name:NSWindowDidChangeBackingPropertiesNotification object:window];
    448503        [center removeObserver:self name:NSWindowWillEnterFullScreenNotification object:window];
    449504        [center removeObserver:self name:NSWindowDidEnterFullScreenNotification object:window];
    450505        [center removeObserver:self name:NSWindowWillExitFullScreenNotification object:window];
    451506        [center removeObserver:self name:NSWindowDidExitFullScreenNotification object:window];
     507#endif
    452508        [center removeObserver:self name:@"NSWindowDidFailToEnterFullScreenNotification" object:window];
    453509        [center removeObserver:self name:@"NSWindowDidFailToExitFullScreenNotification" object:window];
    454510    } else {
     
    628684        [NSMenu setMenuBarVisible:NO];
    629685    }
    630686
     687#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    631688    const unsigned int newflags = [NSEvent modifierFlags] & NSEventModifierFlagCapsLock;
    632689    _data->videodata->modifierFlags = (_data->videodata->modifierFlags & ~NSEventModifierFlagCapsLock) | newflags;
    633690    SDL_ToggleModState(KMOD_CAPS, newflags != 0);
     691#endif
    634692}
    635693
    636694- (void)windowDidResignKey:(NSNotification *)aNotification
     
    657715
    658716- (void)windowDidChangeBackingProperties:(NSNotification *)aNotification
    659717{
     718#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    660719    NSNumber *oldscale = [[aNotification userInfo] objectForKey:NSBackingPropertyOldScaleFactorKey];
    661720
    662721    if (inFullscreenTransition) {
     
    669728        _data->window->h = 0;
    670729        [self windowDidResize:aNotification];
    671730    }
     731#endif
    672732}
    673733
    674734- (void)windowWillEnterFullScreen:(NSNotification *)aNotification
     
    777837        [nswindow miniaturize:nil];
    778838    } else {
    779839        /* Adjust the fullscreen toggle button and readd menu now that we're here. */
     840#if MAC_OS_X_VERSION_MIN_REQUIRED > 1070
    780841        if (window->flags & SDL_WINDOW_RESIZABLE) {
    781842            /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
    782843            [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
    783844        } else {
    784845            [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged];
    785846        }
     847#endif
    786848        [NSMenu setMenuBarVisible:YES];
    787849
    788850        pendingWindowOperation = PENDING_OPERATION_NONE;
     
    825887    }
    826888}
    827889
     890#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    828891-(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions
    829892{
    830893    if ((_data->window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
     
    833896        return proposedOptions;
    834897    }
    835898}
     899#endif
    836900
    837901
    838902/* We'll respond to key events by doing nothing so we don't beep.
     
    10591123
    10601124- (void)touchesBeganWithEvent:(NSEvent *) theEvent
    10611125{
     1126#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    10621127    NSSet *touches = [theEvent touchesMatchingPhase:NSTouchPhaseAny inView:nil];
    10631128    int existingTouchCount = 0;
    10641129
     
    10791144
    10801145    DLog("Began Fingers: %lu .. existing: %d", (unsigned long)[touches count], existingTouchCount);
    10811146    [self handleTouches:NSTouchPhaseBegan withEvent:theEvent];
     1147#endif
    10821148}
    10831149
    10841150- (void)touchesMovedWithEvent:(NSEvent *) theEvent
    10851151{
     1152#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    10861153    [self handleTouches:NSTouchPhaseMoved withEvent:theEvent];
     1154#endif
    10871155}
    10881156
    10891157- (void)touchesEndedWithEvent:(NSEvent *) theEvent
    10901158{
     1159#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    10911160    [self handleTouches:NSTouchPhaseEnded withEvent:theEvent];
     1161#endif
    10921162}
    10931163
    10941164- (void)touchesCancelledWithEvent:(NSEvent *) theEvent
    10951165{
     1166#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    10961167    [self handleTouches:NSTouchPhaseCancelled withEvent:theEvent];
     1168#endif
    10971169}
    10981170
     1171#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
     1172#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
    10991173- (void)handleTouches:(NSTouchPhase) phase withEvent:(NSEvent *) theEvent
     1174#else
     1175- (void)handleTouches:(cocoaTouchType)type withEvent:(NSEvent *)event
     1176#endif
    11001177{
     1178#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1179    NSSet *touches = 0;
     1180    NSEnumerator *enumerator;
     1181    NSTouch *touch;
     1182
     1183    switch (type) {
     1184        case COCOA_TOUCH_DOWN:
     1185            touches = [event touchesMatchingPhase:NSTouchPhaseBegan inView:nil];
     1186            break;
     1187        case COCOA_TOUCH_UP:
     1188            touches = [event touchesMatchingPhase:NSTouchPhaseEnded inView:nil];
     1189            break;
     1190        case COCOA_TOUCH_CANCELLED:
     1191            touches = [event touchesMatchingPhase:NSTouchPhaseCancelled inView:nil];
     1192            break;
     1193        case COCOA_TOUCH_MOVE:
     1194            touches = [event touchesMatchingPhase:NSTouchPhaseMoved inView:nil];
     1195            break;
     1196    }
     1197
     1198    enumerator = [touches objectEnumerator];
     1199    touch = (NSTouch*)[enumerator nextObject];
     1200    while (touch) {
     1201        const SDL_TouchID touchId = (SDL_TouchID)(intptr_t)[touch device];
     1202        if (!SDL_GetTouch(touchId)) {
     1203            if (SDL_AddTouch(touchId, "") < 0) {
     1204                return;
     1205            }
     1206        }
     1207
     1208        const SDL_FingerID fingerId = (SDL_FingerID)(intptr_t)[touch identity];
     1209        float x = [touch normalizedPosition].x;
     1210        float y = [touch normalizedPosition].y;
     1211        /* Make the origin the upper left instead of the lower left */
     1212        y = 1.0f - y;
     1213
     1214        switch (type) {
     1215        case COCOA_TOUCH_DOWN:
     1216            SDL_SendTouch(touchId, fingerId, SDL_TRUE, x, y, 1.0f);
     1217            break;
     1218        case COCOA_TOUCH_UP:
     1219        case COCOA_TOUCH_CANCELLED:
     1220            SDL_SendTouch(touchId, fingerId, SDL_FALSE, x, y, 1.0f);
     1221            break;
     1222        case COCOA_TOUCH_MOVE:
     1223            SDL_SendTouchMotion(touchId, fingerId, x, y, 1.0f);
     1224            break;
     1225        }
     1226
     1227        touch = (NSTouch*)[enumerator nextObject];
     1228     }
     1229#else
    11011230    NSSet *touches = [theEvent touchesMatchingPhase:phase inView:nil];
    11021231
    11031232    for (NSTouch *touch in touches) {
     
    11271256            break;
    11281257        }
    11291258    }
     1259#endif
    11301260}
     1261#endif
    11311262
    11321263@end
    11331264
     
    11941325
    11951326static int
    11961327SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created)
     1328#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    11971329{ @autoreleasepool
    11981330{
     1331#else
     1332{
     1333    NSAutoreleasePool *pool;
     1334#endif
    11991335    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
    12001336    SDL_WindowData *data;
    12011337
     
    12101346    data->videodata = videodata;
    12111347    data->nscontexts = [[NSMutableArray alloc] init];
    12121348
     1349#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1350    pool = [[NSAutoreleasePool alloc] init];
     1351#endif
    12131352    /* Create an event listener for the window */
    12141353    data->listener = [[Cocoa_WindowListener alloc] init];
    12151354
     
    12701409     */
    12711410    [nswindow setOneShot:NO];
    12721411
     1412#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1413    [pool release];
     1414#endif
    12731415    /* All done! */
    12741416    window->driverdata = data;
    12751417    return 0;
     1418#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1419}
     1420#else
    12761421}}
     1422#endif
    12771423
    12781424int
    12791425Cocoa_CreateWindow(_THIS, SDL_Window * window)
     1426#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    12801427{ @autoreleasepool
    12811428{
     1429#else
     1430{
     1431    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1432#endif
    12821433    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
    12831434    NSWindow *nswindow;
    12841435    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
     
    12861437    SDL_Rect bounds;
    12871438    NSUInteger style;
    12881439    NSArray *screens = [NSScreen screens];
     1440#if !defined(MAC_OS_X_VERSION_10_5)
     1441    NSScreen *screen = nil;
     1442    int i;
     1443#endif
    12891444
    12901445    Cocoa_GetDisplayBounds(_this, display, &bounds);
    12911446    rect.origin.x = window->x;
     
    12971452    style = GetWindowStyle(window);
    12981453
    12991454    /* Figure out which screen to place this window */
     1455#if defined(MAC_OS_X_VERSION_10_5)
    13001456    NSScreen *screen = nil;
    13011457    for (NSScreen *candidate in screens) {
     1458#else
     1459    /* old way to iterate */
     1460    for (i = 0; i < [screens count]; i++) {
     1461        NSScreen *candidate = [screens objectAtIndex:i];
     1462#endif
    13021463        NSRect screenRect = [candidate frame];
    13031464        if (rect.origin.x >= screenRect.origin.x &&
    13041465            rect.origin.x < screenRect.origin.x + screenRect.size.width &&
     
    13191480    [nswindow setBackgroundColor:[NSColor blackColor]];
    13201481
    13211482    if (videodata->allow_spaces) {
     1483#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
    13221484        SDL_assert(floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6);
    13231485        SDL_assert([nswindow respondsToSelector:@selector(toggleFullScreen:)]);
    13241486        /* we put FULLSCREEN_DESKTOP windows in their own Space, without a toggle button or menubar, later */
     
    13261488            /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
    13271489            [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
    13281490        }
     1491#endif
    13291492    }
    13301493
    13311494    /* Create a default view for this window */
     
    13441507
    13451508    /* Allow files and folders to be dragged onto the window by users */
    13461509    [nswindow registerForDraggedTypes:[NSArray arrayWithObject:(NSString *)kUTTypeFileURL]];
     1510#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1511    [pool release];
     1512#endif
    13471513
    13481514    if (SetupWindowData(_this, window, nswindow, SDL_TRUE) < 0) {
    13491515        [nswindow release];
    13501516        return -1;
    13511517    }
    13521518    return 0;
     1519#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13531520}}
     1521#else
     1522}
     1523#endif
    13541524
    13551525int
    13561526Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
     1527#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13571528{ @autoreleasepool
    13581529{
     1530#else
     1531{
     1532    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1533#endif
    13591534    NSWindow *nswindow = (NSWindow *) data;
    13601535    NSString *title;
    13611536
     
    13661541    }
    13671542
    13681543    return SetupWindowData(_this, window, nswindow, SDL_FALSE);
     1544#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13691545}}
     1546#else
     1547    [pool release];
     1548}
     1549#endif
    13701550
    13711551void
    13721552Cocoa_SetWindowTitle(_THIS, SDL_Window * window)
     1553#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13731554{ @autoreleasepool
    13741555{
     1556#else
     1557{
     1558    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1559#endif
    13751560    const char *title = window->title ? window->title : "";
    13761561    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
    13771562    NSString *string = [[NSString alloc] initWithUTF8String:title];
    13781563    [nswindow setTitle:string];
    13791564    [string release];
     1565#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13801566}}
     1567#else
     1568    [pool release];
     1569}
     1570#endif
    13811571
    13821572void
    13831573Cocoa_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
     1574#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13841575{ @autoreleasepool
    13851576{
     1577#else
     1578{
     1579    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1580#endif
    13861581    NSImage *nsimage = Cocoa_CreateImage(icon);
    13871582
    13881583    if (nsimage) {
    13891584        [NSApp setApplicationIconImage:nsimage];
    13901585    }
     1586#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13911587}}
     1588#else
     1589    [pool release];
     1590}
     1591#endif
    13921592
    13931593void
    13941594Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
     1595#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    13951596{ @autoreleasepool
    13961597{
     1598#else
     1599{
     1600    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1601#endif
    13971602    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    13981603    NSWindow *nswindow = windata->nswindow;
    13991604    NSRect rect;
     
    14111616    s_moveHack = moveHack;
    14121617
    14131618    ScheduleContextUpdates(windata);
     1619#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14141620}}
     1621#else
     1622    [pool release];
     1623}
     1624#endif
    14151625
    14161626void
    14171627Cocoa_SetWindowSize(_THIS, SDL_Window * window)
     1628#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14181629{ @autoreleasepool
    14191630{
     1631#else
     1632{
     1633    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1634#endif
    14201635    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    14211636    NSWindow *nswindow = windata->nswindow;
    14221637    NSRect rect;
     
    14381653    s_moveHack = moveHack;
    14391654
    14401655    ScheduleContextUpdates(windata);
     1656#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14411657}}
     1658#else
     1659    [pool release];
     1660}
     1661#endif
    14421662
    14431663void
    14441664Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window)
     1665#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14451666{ @autoreleasepool
    14461667{
     1668#else
     1669{
     1670    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1671#endif
    14471672    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    14481673
    14491674    NSSize minSize;
     
    14511676    minSize.height = window->min_h;
    14521677
    14531678    [windata->nswindow setContentMinSize:minSize];
     1679#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14541680}}
     1681#else
     1682    [pool release];
     1683}
     1684#endif
    14551685
    14561686void
    14571687Cocoa_SetWindowMaximumSize(_THIS, SDL_Window * window)
     1688#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14581689{ @autoreleasepool
    14591690{
     1691#else
     1692{
     1693    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1694#endif
    14601695    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    14611696
    14621697    NSSize maxSize;
     
    14641699    maxSize.height = window->max_h;
    14651700
    14661701    [windata->nswindow setContentMaxSize:maxSize];
     1702#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14671703}}
     1704#else
     1705    [pool release];
     1706}
     1707#endif
    14681708
    14691709void
    14701710Cocoa_ShowWindow(_THIS, SDL_Window * window)
     1711#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14711712{ @autoreleasepool
    14721713{
     1714#else
     1715{
     1716    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1717#endif
    14731718    SDL_WindowData *windowData = ((SDL_WindowData *) window->driverdata);
    14741719    NSWindow *nswindow = windowData->nswindow;
    14751720
     
    14781723        [nswindow makeKeyAndOrderFront:nil];
    14791724        [windowData->listener resumeVisibleObservation];
    14801725    }
     1726#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14811727}}
     1728#else
     1729    [pool release];
     1730}
     1731#endif
    14821732
    14831733void
    14841734Cocoa_HideWindow(_THIS, SDL_Window * window)
     1735#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14851736{ @autoreleasepool
    14861737{
     1738#else
     1739{
     1740    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1741#endif
    14871742    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
    14881743
    14891744    [nswindow orderOut:nil];
     1745#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14901746}}
     1747#else
     1748    [pool release];
     1749}
     1750#endif
    14911751
    14921752void
    14931753Cocoa_RaiseWindow(_THIS, SDL_Window * window)
     1754#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    14941755{ @autoreleasepool
    14951756{
     1757#else
     1758{
     1759    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1760#endif
    14961761    SDL_WindowData *windowData = ((SDL_WindowData *) window->driverdata);
    14971762    NSWindow *nswindow = windowData->nswindow;
    14981763
     
    15051770        [nswindow makeKeyAndOrderFront:nil];
    15061771    }
    15071772    [windowData->listener resumeVisibleObservation];
     1773#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15081774}}
     1775#else
     1776    [pool release];
     1777}
     1778#endif
    15091779
    15101780void
    15111781Cocoa_MaximizeWindow(_THIS, SDL_Window * window)
     1782#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15121783{ @autoreleasepool
    15131784{
     1785#else
     1786{
     1787    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1788#endif
    15141789    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    15151790    NSWindow *nswindow = windata->nswindow;
    15161791
    15171792    [nswindow zoom:nil];
    15181793
    15191794    ScheduleContextUpdates(windata);
     1795#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15201796}}
     1797#else
     1798    [pool release];
     1799}
     1800#endif
    15211801
    15221802void
    15231803Cocoa_MinimizeWindow(_THIS, SDL_Window * window)
     1804#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15241805{ @autoreleasepool
    15251806{
     1807#else
     1808{
     1809    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1810#endif
    15261811    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    15271812    NSWindow *nswindow = data->nswindow;
    15281813
     
    15311816    } else {
    15321817        [nswindow miniaturize:nil];
    15331818    }
     1819#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15341820}}
     1821#else
     1822    [pool release];
     1823}
     1824#endif
    15351825
    15361826void
    15371827Cocoa_RestoreWindow(_THIS, SDL_Window * window)
     1828#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15381829{ @autoreleasepool
    15391830{
     1831#else
     1832{
     1833    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1834#endif
    15401835    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
    15411836
    15421837    if ([nswindow isMiniaturized]) {
     
    15441839    } else if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) {
    15451840        [nswindow zoom:nil];
    15461841    }
     1842#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15471843}}
     1844#else
     1845    [pool release];
     1846}
     1847#endif
    15481848
    15491849void
    15501850Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
     1851#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15511852{ @autoreleasepool
    15521853{
     1854#else
     1855{
     1856    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1857#endif
    15531858    if (SetWindowStyle(window, GetWindowStyle(window))) {
    15541859        if (bordered) {
    15551860            Cocoa_SetWindowTitle(_this, window);  /* this got blanked out. */
    15561861        }
    15571862    }
     1863#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15581864}}
     1865#else
     1866    [pool release];
     1867}
     1868#endif
     1869
    15591870
    15601871void
    15611872Cocoa_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable)
     1873#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15621874{ @autoreleasepool
    15631875{
     1876#else
     1877{
     1878    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1879#endif
    15641880    /* Don't set this if we're in a space!
    15651881     * The window will get permanently stuck if resizable is false.
    15661882     * -flibit
     
    15701886    if (![listener isInFullscreenSpace]) {
    15711887        SetWindowStyle(window, GetWindowStyle(window));
    15721888    }
     1889#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15731890}}
     1891#else
     1892    [pool release];
     1893}
     1894#endif
     1895
    15741896
    15751897void
    15761898Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
     1899#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    15771900{ @autoreleasepool
    15781901{
     1902#else
     1903{
     1904    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1905#endif
    15791906    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    15801907    NSWindow *nswindow = data->nswindow;
    15811908    NSRect rect;
     
    15871914
    15881915    if (fullscreen) {
    15891916        SDL_Rect bounds;
     1917        NSRect screenRect;
    15901918
    15911919        Cocoa_GetDisplayBounds(_this, display, &bounds);
    15921920        rect.origin.x = bounds.x;
     
    15961924        ConvertNSRect([nswindow screen], fullscreen, &rect);
    15971925
    15981926        /* Hack to fix origin on Mac OS X 10.4 */
    1599         NSRect screenRect = [[nswindow screen] frame];
     1927        screenRect = [[nswindow screen] frame];
    16001928        if (screenRect.size.height >= 1.0f) {
    16011929            rect.origin.y += (screenRect.size.height - rect.size.height);
    16021930        }
    16031931
     1932        if ([nswindow respondsToSelector:@selector(setStyleMask:)]) {
    16041933        [nswindow setStyleMask:NSWindowStyleMaskBorderless];
     1934        }
    16051935    } else {
    16061936        rect.origin.x = window->windowed.x;
    16071937        rect.origin.y = window->windowed.y;
     
    16091939        rect.size.height = window->windowed.h;
    16101940        ConvertNSRect([nswindow screen], fullscreen, &rect);
    16111941
     1942        if ([nswindow respondsToSelector:@selector(setStyleMask:)]) {
    16121943        [nswindow setStyleMask:GetWindowStyle(window)];
     1944        }
    16131945
    16141946        /* Hack to restore window decorations on Mac OS X 10.10 */
    16151947        NSRect frameRect = [nswindow frame];
     
    16461978    }
    16471979
    16481980    ScheduleContextUpdates(data);
     1981#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    16491982}}
     1983#else
     1984    [pool release];
     1985}
     1986#endif
    16501987
    16511988int
    16521989Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp)
     
    17362073
    17372074void
    17382075Cocoa_DestroyWindow(_THIS, SDL_Window * window)
     2076#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    17392077{ @autoreleasepool
    17402078{
     2079#else
     2080{
     2081    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     2082#endif
    17412083    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    17422084
    17432085    if (data) {
     2086#if !defined(MAC_OS_X_VERSION_10_5)
     2087        int i;
     2088        NSArray *contexts;
     2089#endif
    17442090        if ([data->listener isInFullscreenSpace]) {
    17452091            [NSMenu setMenuBarVisible:YES];
    17462092        }
     
    17502096            [data->nswindow close];
    17512097        }
    17522098
     2099#if defined(MAC_OS_X_VERSION_10_5)
    17532100        NSArray *contexts = [[data->nscontexts copy] autorelease];
    17542101        for (SDLOpenGLContext *context in contexts) {
     2102#else
     2103        contexts = [[data->nscontexts copy] autorelease];
     2104        /* old way to iterate */
     2105        for (i = 0; i < [contexts count]; i++) {
     2106            SDLOpenGLContext *context = [contexts objectAtIndex:i];
     2107#endif
    17552108            /* Calling setWindow:NULL causes the context to remove itself from the context list. */           
    17562109            [context setWindow:NULL];
    17572110        }
     
    17602113        SDL_free(data);
    17612114    }
    17622115    window->driverdata = NULL;
     2116#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    17632117}}
     2118#else
     2119    [pool release];
     2120}
     2121#endif
    17642122
    17652123SDL_bool
    17662124Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
     
    17922150
    17932151SDL_bool
    17942152Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state)
     2153#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    17952154{ @autoreleasepool
    17962155{
     2156#else
     2157{
     2158    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     2159#endif
    17972160    SDL_bool succeeded = SDL_FALSE;
    17982161    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    17992162
     
    18242187        succeeded = SDL_TRUE;
    18252188    }
    18262189
     2190#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     2191    [pool release];
     2192#endif
    18272193    return succeeded;
     2194#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
    18282195}}
     2196#else
     2197}
     2198#endif
    18292199
    18302200int
    18312201Cocoa_SetWindowHitTest(SDL_Window * window, SDL_bool enabled)