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) |
---|
-
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 24339 24339 $as_echo "#define SDL_AUDIO_DRIVER_COREAUDIO 1" >>confdefs.h 24340 24340 24341 24341 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" 24343 24343 SUMMARY_audio="${SUMMARY_audio} coreaudio" 24344 24344 have_audio=yes 24345 24345 fi -
configure.in
diff -ru SDL2-2.0.6-orig/configure.in SDL2-2.0.6-tiger/configure.in
old new 3722 3722 if test x$enable_audio = xyes; then 3723 3723 AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO, 1, [ ]) 3724 3724 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" 3726 3726 SUMMARY_audio="${SUMMARY_audio} coreaudio" 3727 3727 have_audio=yes 3728 3728 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. */ 1 2 /* 2 3 Simple DirectMedia Layer 3 4 Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org> … … 22 23 #ifndef SDL_config_h_ 23 24 #define SDL_config_h_ 24 25 25 #include "SDL_platform.h"26 27 26 /** 28 * \file SDL_config.h 27 * \file SDL_config.h.in 28 * 29 * This is a set of defines to configure the SDL features 29 30 */ 30 31 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 44 48 #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 */ 48 53 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 51 91 #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 */ 52 392 53 393 #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 84 84 #undef __MACOSX__ 85 85 #define __MACOSX__ 1 86 86 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 87 #if 0 87 88 # error SDL for Mac OS X only supports deploying on 10.6 and above. 89 #endif 88 90 #endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1060 */ 89 91 #endif /* TARGET_OS_IPHONE */ 90 92 #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 229 229 #if defined(SDL_VIDEO_DRIVER_COCOA) 230 230 struct 231 231 { 232 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 232 233 #if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc) 233 234 NSWindow __unsafe_unretained *window; /**< The Cocoa window */ 234 235 #else 235 236 NSWindow *window; /**< The Cocoa window */ 236 237 #endif 238 #else 239 NSWindow *window; /**< The Cocoa window */ 240 #endif 237 241 } cocoa; 238 242 #endif 239 243 #if defined(SDL_VIDEO_DRIVER_UIKIT) 240 244 struct 241 245 { 246 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 242 247 #if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc) 243 248 UIWindow __unsafe_unretained *window; /**< The UIKit window */ 244 249 #else 245 250 UIWindow *window; /**< The UIKit window */ 246 251 #endif 252 #else 253 UIWindow *window; /**< The UIKit window */ 254 #endif 247 255 GLuint framebuffer; /**< The GL view's Framebuffer Object. It must be bound when rendering to the screen using GL. */ 248 256 GLuint colorbuffer; /**< The GL view's color Renderbuffer Object. It must be bound when SDL_GL_SwapWindow is called. */ 249 257 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 28 28 #include "SDL_mutex.h" 29 29 #include "SDL_timer.h" 30 30 31 #if defined(__MACOSX__) || defined(__IPHONEOS__) 32 #include <libkern/OSAtomic.h> 33 #endif 34 31 35 #if !defined(HAVE_GCC_ATOMICS) && defined(__SOLARIS__) 32 36 #include <atomic.h> 33 37 #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 29 29 #define MACOSX_COREAUDIO 1 30 30 #endif 31 31 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 32 39 #if MACOSX_COREAUDIO 33 40 #include <CoreAudio/CoreAudio.h> 34 41 #include <CoreServices/CoreServices.h> … … 46 53 struct SDL_PrivateAudioData 47 54 { 48 55 SDL_Thread *thread; 56 #if defined(MAC_OS_X_VERSION_10_5) 49 57 AudioQueueRef audioQueue; 50 58 AudioQueueBufferRef *audioBuffer; 59 #else 60 AudioUnit audioUnit; 61 int audioUnitOpened; 62 #endif 51 63 void *buffer; 52 64 UInt32 bufferOffset; 53 65 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 41 41 } 42 42 43 43 #if MACOSX_COREAUDIO 44 #if !defined(MAC_OS_X_VERSION_10_5) 45 #if 0 46 typedef void (*addDevFn)(const char *name, AudioDeviceID devId, void *data); 47 48 static void 49 addToDevList(const char *name, AudioDeviceID devId, void *data) 50 { 51 SDL_AddAudioDevice addfn = (SDL_AddAudioDevice) data; 52 addfn(name); 53 } 54 #endif 55 56 typedef struct 57 { 58 const char *findname; 59 AudioDeviceID devId; 60 int found; 61 } FindDevIdData; 62 63 static void 64 findDevId(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 44 76 static const AudioObjectPropertyAddress devlist_address = { 45 77 kAudioHardwarePropertyDevices, 46 78 kAudioObjectPropertyScopeGlobal, … … 213 245 build_device_list(SDL_FALSE, addToDevList, NULL); 214 246 } 215 247 248 249 #if !defined(MAC_OS_X_VERSION_10_5) 250 static int 251 find_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 216 314 static void 217 315 build_device_change_list(const char *name, const int iscapture, AudioDeviceID devId, void *data) 218 316 { … … 404 502 #endif 405 503 406 504 505 #if defined(MAC_OS_X_VERSION_10_5) 407 506 /* The AudioQueue callback */ 408 507 static void 409 508 outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer) … … 486 585 AudioQueueEnqueueBuffer(this->hidden->audioQueue, inBuffer, 0, NULL); 487 586 } 488 587 588 #else 589 /* OS X 10.4 stuff */ 590 /* The CoreAudio callback */ 591 static OSStatus 592 outputCallback(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 650 static OSStatus 651 inputCallback(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 489 663 490 664 #if MACOSX_COREAUDIO 491 665 static const AudioObjectPropertyAddress alive_address = … … 528 702 static void 529 703 COREAUDIO_CloseDevice(_THIS) 530 704 { 705 #if defined(MAC_OS_X_VERSION_10_5) 531 706 const SDL_bool iscapture = this->iscapture; 532 707 533 708 /* !!! FIXME: what does iOS do when a bluetooth audio device vanishes? Headphones unplugged? */ … … 565 740 } else { 566 741 open_playback_devices--; 567 742 } 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 568 780 } 569 781 570 782 #if MACOSX_COREAUDIO … … 620 832 this->hidden->deviceID = devid; 621 833 return 1; 622 834 } 835 836 #if !defined(MAC_OS_X_VERSION_10_5) 837 static int 838 prepare_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 623 939 #endif 624 940 941 #if defined(MAC_OS_X_VERSION_10_5) 625 942 static int 626 943 prepare_audioqueue(_THIS) 627 944 { … … 741 1058 742 1059 return 0; 743 1060 } 1061 #endif 744 1062 745 1063 static int 746 1064 COREAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) … … 820 1138 strdesc->mBytesPerFrame = strdesc->mBitsPerChannel * strdesc->mChannelsPerFrame / 8; 821 1139 strdesc->mBytesPerPacket = strdesc->mBytesPerFrame * strdesc->mFramesPerPacket; 822 1140 1141 #if defined(MAC_OS_X_VERSION_10_5) 823 1142 #if MACOSX_COREAUDIO 824 1143 if (!prepare_device(this, handle, iscapture)) { 825 1144 return -1; … … 848 1167 } 849 1168 850 1169 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 851 1178 } 852 1179 853 1180 static void … … 870 1197 871 1198 #if MACOSX_COREAUDIO 872 1199 impl->DetectDevices = COREAUDIO_DetectDevices; 1200 #if defined(MAC_OS_X_VERSION_10_5) 873 1201 AudioObjectAddPropertyListener(kAudioObjectSystemObject, &devlist_address, device_list_changed, NULL); 1202 #endif 874 1203 #else 875 1204 impl->OnlyHasDefaultOutputDevice = 1; 876 1205 impl->OnlyHasDefaultCaptureDevice = 1; 877 1206 #endif 878 1207 879 1208 impl->ProvidesOwnCallbackThread = 1; 1209 #if defined(MAC_OS_X_VERSION_10_5) 880 1210 impl->HasCaptureSupport = 1; 1211 #endif 881 1212 882 1213 return 1; /* this audio target is available. */ 883 1214 } -
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 21 21 #include "../../SDL_internal.h" 22 22 23 23 #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 24 32 #import <Foundation/Foundation.h> 25 33 26 34 #include "SDL_rwopsbundlesupport.h" … … 33 41 Also, note the bundle layouts are different for iPhone and Mac. 34 42 */ 35 43 FILE* SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode) 44 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 36 45 { @autoreleasepool 46 #endif 37 47 { 38 48 FILE* fp = NULL; 39 49 … … 42 52 return fopen(file, mode); 43 53 } 44 54 55 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 56 NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init]; 57 #endif 45 58 NSFileManager* file_manager = [NSFileManager defaultManager]; 46 59 NSString* resource_path = [[NSBundle mainBundle] resourcePath]; 47 60 … … 54 67 fp = fopen(file, mode); 55 68 } 56 69 70 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 71 [autorelease_pool drain]; 72 #endif 57 73 return fp; 74 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 75 } 76 #else 58 77 }} 78 #endif 59 79 60 80 #endif /* __APPLE__ */ 61 81 -
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 25 25 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 26 26 /* System dependent filesystem routines */ 27 27 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 28 35 #include <Foundation/Foundation.h> 29 36 #include <sys/stat.h> 30 37 #include <sys/types.h> … … 35 42 36 43 char * 37 44 SDL_GetBasePath(void) 45 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 38 46 { @autoreleasepool 39 47 { 48 #else 49 { 50 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 51 #endif 40 52 NSBundle *bundle = [NSBundle mainBundle]; 41 53 const char* baseType = [[[bundle infoDictionary] objectForKey:@"SDL_FILESYSTEM_BASE_DIR_TYPE"] UTF8String]; 42 54 const char *base = NULL; … … 64 76 } 65 77 } 66 78 79 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 67 80 return retval; 68 81 }} 82 #else 83 [pool release]; 84 return retval; 85 } 86 #endif 69 87 70 88 char * 71 89 SDL_GetPrefPath(const char *org, const char *app) 90 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 72 91 { @autoreleasepool 73 92 { 93 #else 94 { 95 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 96 #endif 74 97 if (!app) { 75 98 SDL_InvalidParamError("app"); 76 99 return NULL; … … 109 132 } 110 133 } 111 134 135 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 112 136 return retval; 113 137 }} 138 #else 139 [pool release]; 140 return retval; 141 } 142 #endif 114 143 115 144 #endif /* SDL_FILESYSTEM_COCOA */ 116 145 -
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 459 459 device->instance_id = ++s_joystick_instance_id; 460 460 461 461 /* We have to do some storage of the io_service_t for SDL_HapticOpenFromJoystick */ 462 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 462 463 ioservice = IOHIDDeviceGetService(ioHIDDeviceObject); 464 #else 465 ioservice = 0; 466 #endif 463 467 #if SDL_HAPTIC_IOKIT 464 468 if ((ioservice) && (FFIsForceFeedback(ioservice) == FF_OK)) { 465 469 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 25 25 #include "SDL_cocoavideo.h" 26 26 #include "../../events/SDL_clipboardevents_c.h" 27 27 28 static NSString * 29 GetTextFormat(_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 28 42 int 29 43 Cocoa_SetClipboardText(_THIS, const char *text) 44 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 30 45 { @autoreleasepool 31 46 { 47 #else 48 { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 49 #endif 32 50 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; 33 51 NSPasteboard *pasteboard; 52 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 34 53 NSString *format = NSPasteboardTypeString; 54 #else 55 NSString *format = GetTextFormat(_this); 56 #endif 35 57 36 58 pasteboard = [NSPasteboard generalPasteboard]; 37 59 data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil]; 38 60 [pasteboard setString:[NSString stringWithUTF8String:text] forType:format]; 39 61 62 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 63 [pool release]; 64 #endif 40 65 return 0; 66 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 41 67 }} 68 #else 69 } 70 #endif 42 71 43 72 char * 44 73 Cocoa_GetClipboardText(_THIS) 74 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 45 75 { @autoreleasepool 46 76 { 77 #else 78 { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 79 #endif 47 80 NSPasteboard *pasteboard; 81 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 48 82 NSString *format = NSPasteboardTypeString; 83 #else 84 NSString *format = GetTextFormat(_this); 85 #endif 49 86 NSString *available; 50 87 char *text; 51 88 … … 66 103 text = SDL_strdup(""); 67 104 } 68 105 106 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 107 [pool release]; 108 #endif 69 109 return text; 110 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 70 111 }} 112 #else 113 } 114 #endif 71 115 72 116 SDL_bool 73 117 Cocoa_HasClipboardText(_THIS) … … 83 127 84 128 void 85 129 Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data) 130 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 86 131 { @autoreleasepool 87 132 { 133 #else 134 { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 135 #endif 88 136 NSPasteboard *pasteboard; 89 137 NSInteger count; 90 138 … … 96 144 } 97 145 data->clipboard_count = count; 98 146 } 147 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 99 148 }} 149 #else 150 [pool release]; 151 } 152 #endif 100 153 101 154 #endif /* SDL_VIDEO_DRIVER_COCOA */ 102 155 -
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 55 55 SDL_VideoDevice *_this = SDL_GetVideoDevice(); 56 56 57 57 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 58 71 case NSEventTypeLeftMouseDown: 59 72 case NSEventTypeOtherMouseDown: 60 73 case NSEventTypeRightMouseDown: … … 66 79 case NSEventTypeOtherMouseDragged: /* usually middle mouse dragged */ 67 80 case NSEventTypeMouseMoved: 68 81 case NSEventTypeScrollWheel: 82 #endif 69 83 Cocoa_HandleMouseEvent(_this, theEvent); 70 84 break; 85 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 86 case NSKeyDown: 87 case NSKeyUp: 88 case NSFlagsChanged: 89 #else 71 90 case NSEventTypeKeyDown: 72 91 case NSEventTypeKeyUp: 73 92 case NSEventTypeFlagsChanged: 93 #endif 74 94 Cocoa_HandleKeyEvent(_this, theEvent); 75 95 break; 76 96 default: … … 97 117 - (void)setAppleMenu:(NSMenu *)menu; 98 118 @end 99 119 120 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 100 121 @interface SDLAppDelegate : NSObject <NSApplicationDelegate> { 122 #else 123 @interface SDLAppDelegate : NSObject { 124 #endif 101 125 @public 102 126 BOOL seenFirstActivate; 103 127 } … … 141 165 - (void)windowWillClose:(NSNotification *)notification; 142 166 { 143 167 NSWindow *win = (NSWindow*)[notification object]; 168 #if !defined(MAC_OS_X_VERSION_10_5) 169 int i; 170 #endif 144 171 145 172 if (![win isKeyWindow]) { 146 173 return; … … 155 182 * want to try its list first since the behavior in other apps is to only 156 183 * make the 'About' window key if no other windows are on-screen. 157 184 */ 185 #if defined(MAC_OS_X_VERSION_10_5) 158 186 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 159 192 if (window != win && [window canBecomeKeyWindow]) { 160 if (![window isOnActiveSpace]) { 161 continue; 193 if ([window respondsToSelector:@selector(isOnActiveSpace)]) { 194 if (![window isOnActiveSpace]) { 195 continue; 196 } 162 197 } 163 198 [window makeKeyAndOrderFront:self]; 164 199 return; … … 169 204 * the active Space in z-order (including the 'About' window, if it's shown) 170 205 * and make the first one key. 171 206 */ 207 if ([NSWindow respondsToSelector:@selector(windowNumbersWithOptions:)]) { 208 #if defined(MAC_OS_X_VERSION_10_5) 172 209 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)]) { 173 216 NSWindow *window = [NSApp windowWithWindowNumber:[num integerValue]]; 174 217 if (window && window != win && [window canBecomeKeyWindow]) { 175 218 [window makeKeyAndOrderFront:self]; 176 219 return; 177 220 } 221 } 222 } 178 223 } 179 224 } 180 225 181 226 - (void)focusSomeWindow:(NSNotification *)aNotification 182 227 { 228 SDL_VideoDevice *device; 229 183 230 /* HACK: Ignore the first call. The application gets a 184 231 * applicationDidBecomeActive: a little bit after the first window is 185 232 * created, and if we don't ignore it, a window that has been created with … … 190 237 return; 191 238 } 192 239 193 SDL_VideoDevice *device = SDL_GetVideoDevice();240 device = SDL_GetVideoDevice(); 194 241 if (device && device->windows) { 195 242 SDL_Window *window = device->windows; 196 243 int i; … … 328 375 [windowMenu release]; 329 376 330 377 378 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 331 379 /* Add the fullscreen view toggle menu option, if supported */ 332 380 if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) { 333 381 /* Create the view menu */ … … 345 393 346 394 [viewMenu release]; 347 395 } 396 #endif 348 397 } 349 398 350 399 void 351 400 Cocoa_RegisterApp(void) 401 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 352 402 { @autoreleasepool 353 403 { 404 #else 405 { 406 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 407 #endif 354 408 /* 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 355 417 356 418 if (NSApp == nil) { 419 NSDictionary *appDefaults; 357 420 [SDLApplication sharedApplication]; 358 421 SDL_assert(NSApp != nil); 359 422 360 423 s_bShouldHandleEventsInSDLApplication = SDL_TRUE; 361 424 362 425 if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, SDL_FALSE)) { 426 #if defined(MAC_OS_X_VERSION_10_6) 363 427 [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; 428 #endif 364 429 [NSApp activateIgnoringOtherApps:YES]; 365 430 } 366 431 … … 368 433 CreateApplicationMenus(); 369 434 } 370 435 [NSApp finishLaunching]; 371 NSDictionary *appDefaults = [[NSDictionary alloc] initWithObjectsAndKeys:436 appDefaults = [[NSDictionary alloc] initWithObjectsAndKeys: 372 437 [NSNumber numberWithBool:NO], @"AppleMomentumScrollSupported", 373 438 [NSNumber numberWithBool:NO], @"ApplePressAndHoldEnabled", 374 439 [NSNumber numberWithBool:YES], @"ApplePersistenceIgnoreState", … … 388 453 appDelegate->seenFirstActivate = YES; 389 454 } 390 455 } 456 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 391 457 }} 458 #else 459 [pool release]; 460 } 461 #endif 392 462 393 463 void 394 464 Cocoa_PumpEvents(_THIS) 465 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 395 466 { @autoreleasepool 396 467 { 468 #else 469 { 470 NSAutoreleasePool *pool; 471 #endif 397 472 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 398 473 /* Update activity every 30 seconds to prevent screensaver */ 399 474 SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; … … 407 482 } 408 483 #endif 409 484 485 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 486 pool = [[NSAutoreleasePool alloc] init]; 487 #endif 410 488 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 411 492 NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ]; 493 #endif 412 494 if ( event == nil ) { 413 495 break; 414 496 } … … 420 502 // Pass events down to SDLApplication to be handled in sendEvent: 421 503 [NSApp sendEvent:event]; 422 504 } 505 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 423 506 }} 507 #else 508 [pool release]; 509 } 510 #endif 424 511 425 512 void 426 513 Cocoa_SuspendScreenSaver(_THIS) 514 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 427 515 { @autoreleasepool 428 516 { 429 517 SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; … … 450 538 &data->screensaver_assertion); 451 539 } 452 540 }} 541 #else 542 { 543 } 544 #endif 453 545 454 546 #endif /* SDL_VIDEO_DRIVER_COCOA */ 455 547 -
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 34 34 /*#define DEBUG_IME NSLog */ 35 35 #define DEBUG_IME(...) 36 36 37 #if defined(MAC_OS_X_VERSION_10_5) 37 38 @interface SDLTranslatorResponder : NSView <NSTextInputClient> { 39 #else 40 @interface SDLTranslatorResponder : NSView { 41 #endif 38 42 NSString *_markedText; 39 43 NSRange _markedRange; 40 44 NSRange _selectedRange; … … 93 97 return _selectedRange; 94 98 } 95 99 100 - (void)unmarkText 101 { 102 [_markedText release]; 103 _markedText = nil; 104 105 SDL_SendEditingText("", 0, 0); 106 } 107 96 108 - (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange; 97 109 { 98 110 if ([aString isKindOfClass:[NSAttributedString class]]) { … … 119 131 selRange.location, selRange.length); 120 132 } 121 133 122 - (void)unmarkText123 {124 [_markedText release];125 _markedText = nil;126 127 SDL_SendEditingText("", 0, 0);128 }129 130 134 - (NSRect)firstRectForCharacterRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange; 131 135 { 132 136 NSWindow *window = [self window]; … … 144 148 NSStringFromRect(rect)); 145 149 146 150 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 151 #if defined(MAC_OS_X_VERSION_10_7) 147 152 if (![window respondsToSelector:@selector(convertRectToScreen:)]) { 153 #endif 148 154 rect.origin = [window convertBaseToScreen:rect.origin]; 155 #if defined(MAC_OS_X_VERSION_10_7) 149 156 } else 150 157 #endif 158 #endif 151 159 { 160 #if defined(MAC_OS_X_VERSION_10_7) 152 161 rect = [window convertRectToScreen:rect]; 162 #endif 153 163 } 154 164 155 165 return rect; … … 193 203 http://stackoverflow.com/questions/7190852/using-iohidmanager-to-get-modifier-key-events 194 204 */ 195 205 206 #if defined(MAC_OS_X_VERSION_10_5) 196 207 static IOHIDManagerRef s_hidManager = NULL; 197 208 198 209 static void … … 296 307 CFRelease(keyboard); 297 308 } 298 309 } 310 #endif 299 311 300 312 /* This is a helper function for HandleModifierSide. This 301 313 * function reverts back to behavior before the distinction between … … 504 516 static void 505 517 UpdateKeymap(SDL_VideoData *data, SDL_bool send_event) 506 518 { 519 #if defined(MAC_OS_X_VERSION_10_5) 507 520 TISInputSourceRef key_layout; 508 521 const void *chr_data; 509 522 int i; … … 566 579 567 580 cleanup: 568 581 CFRelease(key_layout); 582 #endif 569 583 } 570 584 571 585 void … … 583 597 SDL_SetScancodeName(SDL_SCANCODE_RALT, "Right Option"); 584 598 SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Command"); 585 599 600 if([NSEvent respondsToSelector:@selector(modifierFlags)]) { 586 601 data->modifierFlags = [NSEvent modifierFlags]; 602 } else { 603 data->modifierFlags = 0; 604 } 587 605 SDL_ToggleModState(KMOD_CAPS, (data->modifierFlags & NSEventModifierFlagCapsLock) != 0); 588 606 607 #if defined(MAC_OS_X_VERSION_10_5) 589 608 InitHIDCallback(); 609 #endif 590 610 } 591 611 592 612 void 593 613 Cocoa_StartTextInput(_THIS) 614 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 594 615 { @autoreleasepool 595 616 { 617 #else 618 { 619 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 620 #endif 596 621 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; 597 622 SDL_Window *window = SDL_GetKeyboardFocus(); 598 623 NSWindow *nswindow = nil; 624 NSView *parentView; 599 625 if (window) { 600 626 nswindow = ((SDL_WindowData*)window->driverdata)->nswindow; 601 627 } 602 628 603 NSView *parentView = [nswindow contentView];629 parentView = [nswindow contentView]; 604 630 605 631 /* We only keep one field editor per process, since only the front most 606 632 * window can receive text input events, so it make no sense to keep more … … 618 644 [parentView addSubview: data->fieldEdit]; 619 645 [nswindow makeFirstResponder: data->fieldEdit]; 620 646 } 647 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 621 648 }} 649 #else 650 [pool release]; 651 } 652 #endif 622 653 623 654 void 624 655 Cocoa_StopTextInput(_THIS) 656 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 625 657 { @autoreleasepool 658 #endif 626 659 { 627 660 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; 628 661 629 662 if (data && data->fieldEdit) { 663 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 664 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 665 #endif 630 666 [data->fieldEdit removeFromSuperview]; 631 667 [data->fieldEdit release]; 632 668 data->fieldEdit = nil; 669 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 670 [pool release]; 671 #endif 633 672 } 673 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 634 674 }} 675 #else 676 } 677 #endif 635 678 636 679 void 637 680 Cocoa_SetTextInputRect(_THIS, SDL_Rect *rect) … … 649 692 void 650 693 Cocoa_HandleKeyEvent(_THIS, NSEvent *event) 651 694 { 695 unsigned short scancode; 696 SDL_Scancode code; 697 #if 0 698 const char *text; 699 #endif 652 700 SDL_VideoData *data = _this ? ((SDL_VideoData *) _this->driverdata) : NULL; 653 701 if (!data) { 654 702 return; /* can happen when returning from fullscreen Space on shutdown */ 655 703 } 656 704 657 unsigned short scancode = [event keyCode]; 658 SDL_Scancode code; 659 #if 0 660 const char *text; 661 #endif 705 scancode = [event keyCode]; 662 706 663 707 if ((scancode == 10 || scancode == 50) && KBGetLayoutType(LMGetKbdType()) == kKeyboardISO) { 664 708 /* see comments in SDL_cocoakeys.h */ … … 673 717 } 674 718 675 719 switch ([event type]) { 720 #if !defined(MAC_OS_X_VERSION_10_12) 721 case NSKeyDown: 722 #else 676 723 case NSEventTypeKeyDown: 724 #endif 677 725 if (![event isARepeat]) { 678 726 /* See if we need to rebuild the keyboard layout */ 679 727 UpdateKeymap(data, SDL_TRUE); … … 697 745 #endif 698 746 } 699 747 break; 748 #if !defined(MAC_OS_X_VERSION_10_12) 749 case NSKeyUp: 750 #else 700 751 case NSEventTypeKeyUp: 752 #endif 701 753 SDL_SendKeyboardKey(SDL_RELEASED, code); 702 754 break; 755 #if !defined(MAC_OS_X_VERSION_10_12) 756 case NSFlagsChanged: 757 #else 703 758 case NSEventTypeFlagsChanged: 759 #endif 704 760 /* FIXME CW 2007-08-14: check if this whole mess that takes up half of this file is really necessary */ 705 761 HandleModifiers(_this, scancode, [event modifierFlags]); 706 762 break; … … 712 768 void 713 769 Cocoa_QuitKeyboard(_THIS) 714 770 { 771 #if defined(MAC_OS_X_VERSION_10_5) 715 772 QuitHIDCallback(); 773 #endif 716 774 } 717 775 718 776 #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 92 92 /* Display a Cocoa message box */ 93 93 int 94 94 Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) 95 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 95 96 { @autoreleasepool 97 #endif 96 98 { 97 99 Cocoa_RegisterApp(); 98 100 101 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 102 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 103 #endif 99 104 NSAlert* alert = [[[NSAlert alloc] init] autorelease]; 100 105 101 106 if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) { … … 137 142 returnValue = SDL_SetError("Did not get a valid `clicked button' id: %ld", (long)clicked); 138 143 } 139 144 145 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 146 [pool release]; 147 #endif 140 148 return returnValue; 149 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 141 150 }} 151 #else 152 } 153 #endif 142 154 143 155 #endif /* SDL_VIDEO_DRIVER_COCOA */ 144 156 -
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 29 29 #ifndef SDL_cocoametalview_h_ 30 30 #define SDL_cocoametalview_h_ 31 31 32 #i mport"../SDL_sysvideo.h"33 #i mport"SDL_cocoawindow.h"32 #include "../SDL_sysvideo.h" 33 #include "SDL_cocoawindow.h" 34 34 35 35 #if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_COCOA 36 36 -
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 26 26 * how to add a CAMetalLayer backed view. 27 27 */ 28 28 29 #i mport"SDL_cocoametalview.h"29 #include "SDL_cocoametalview.h" 30 30 31 31 #if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_COCOA 32 32 -
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 30 30 31 31 typedef struct 32 32 { 33 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 33 34 CGDisplayModeRef moderef; 35 #else 36 const void *moderef; 37 #endif 34 38 } SDL_DisplayModeData; 35 39 36 40 extern 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 100 100 } 101 101 102 102 static SDL_bool 103 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 103 104 GetDisplayMode(_THIS, CGDisplayModeRef vidmode, CFArrayRef modelist, CVDisplayLinkRef link, SDL_DisplayMode *mode) 105 #else 106 GetDisplayMode(_THIS, const void *moderef, CFArrayRef modelist, CVDisplayLinkRef link, SDL_DisplayMode *mode) 107 #endif 104 108 { 105 109 SDL_DisplayModeData *data; 110 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 106 111 int width = (int) CGDisplayModeGetWidth(vidmode); 107 112 int height = (int) CGDisplayModeGetHeight(vidmode); 108 113 int bpp = 0; 109 114 int refreshRate = 0; 110 115 CFStringRef fmt; 116 #else 117 long width = 0; 118 long height = 0; 119 long bpp = 0; 120 long refreshRate = 0; 121 #endif 111 122 112 123 /* Ignore this mode if it's low-dpi (@1x) and we have a high-dpi mode in the 113 124 * list with the same size in points. … … 145 156 if (!data) { 146 157 return SDL_FALSE; 147 158 } 159 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 148 160 data->moderef = vidmode; 161 #else 162 data->moderef = moderef; 163 #endif 149 164 165 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 150 166 fmt = CGDisplayModeCopyPixelEncoding(vidmode); 151 167 refreshRate = (int) (CGDisplayModeGetRefreshRate(vidmode) + 0.5); 152 168 … … 164 180 } 165 181 166 182 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 167 199 168 200 /* CGDisplayModeGetRefreshRate returns 0 for many non-CRT displays. */ 169 201 if (refreshRate == 0 && link != NULL) { … … 212 244 213 245 void 214 246 Cocoa_InitModes(_THIS) 247 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 215 248 { @autoreleasepool 216 249 { 250 #else 251 { 252 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 253 #endif 217 254 CGDisplayErr result; 218 255 CGDirectDisplayID *displays; 219 256 CGDisplayCount numDisplays; … … 222 259 result = CGGetOnlineDisplayList(0, NULL, &numDisplays); 223 260 if (result != kCGErrorSuccess) { 224 261 CG_SetError("CGGetOnlineDisplayList()", result); 262 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 263 [pool release]; 264 #endif 225 265 return; 226 266 } 227 267 displays = SDL_stack_alloc(CGDirectDisplayID, numDisplays); … … 229 269 if (result != kCGErrorSuccess) { 230 270 CG_SetError("CGGetOnlineDisplayList()", result); 231 271 SDL_stack_free(displays); 272 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 273 [pool release]; 274 #endif 232 275 return; 233 276 } 234 277 … … 238 281 SDL_VideoDisplay display; 239 282 SDL_DisplayData *displaydata; 240 283 SDL_DisplayMode mode; 284 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 241 285 CGDisplayModeRef moderef = NULL; 286 #else 287 const void *moderef = NULL; 288 #endif 242 289 CVDisplayLinkRef link = NULL; 243 290 244 291 if (pass == 0) { … … 255 302 continue; 256 303 } 257 304 305 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 258 306 moderef = CGDisplayCopyDisplayMode(displays[i]); 307 #else 308 moderef = CGDisplayCurrentMode(displays[i]); 309 #endif 259 310 260 311 if (!moderef) { 261 312 continue; … … 263 314 264 315 displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata)); 265 316 if (!displaydata) { 317 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 266 318 CGDisplayModeRelease(moderef); 319 #endif 267 320 continue; 268 321 } 269 322 displaydata->display = displays[i]; … … 275 328 display.name = (char *)Cocoa_GetDisplayName(displays[i]); 276 329 if (!GetDisplayMode(_this, moderef, NULL, link, &mode)) { 277 330 CVDisplayLinkRelease(link); 331 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 278 332 CGDisplayModeRelease(moderef); 333 #endif 279 334 SDL_free(display.name); 280 335 SDL_free(displaydata); 281 336 continue; … … 291 346 } 292 347 } 293 348 SDL_stack_free(displays); 349 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 350 [pool release]; 351 } 352 #else 294 353 }} 354 #endif 295 355 296 356 int 297 357 Cocoa_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect) … … 316 376 NSScreen *screen = nil; 317 377 318 378 /* !!! FIXME: maybe track the NSScreen in SDL_DisplayData? */ 379 #if defined(MAC_OS_X_VERSION_10_5) 319 380 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 320 387 const CGDirectDisplayID thisDisplay = (CGDirectDisplayID) [[[i deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue]; 321 388 if (thisDisplay == cgdisplay) { 322 389 screen = i; … … 329 396 return -1; 330 397 } 331 398 399 { 332 400 const CGRect cgrect = CGDisplayBounds(cgdisplay); 333 401 const NSRect frame = [screen visibleFrame]; 334 402 … … 338 406 rect->y = (int)(cgrect.origin.y + frame.origin.y); 339 407 rect->w = (int)frame.size.width; 340 408 rect->h = (int)frame.size.height; 409 } 341 410 342 411 return 0; 343 412 } … … 391 460 } 392 461 #endif 393 462 463 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 394 464 modes = CGDisplayCopyAllDisplayModes(data->display, dict); 465 #else 466 modes = CGDisplayAvailableModes(data->display); 467 #endif 395 468 396 469 if (dict != NULL) { 397 470 CFRelease(dict); … … 405 478 CVDisplayLinkCreateWithCGDisplay(data->display, &link); 406 479 407 480 for (i = 0; i < count; i++) { 481 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 408 482 CGDisplayModeRef moderef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i); 483 #else 484 const void *moderef = CFArrayGetValueAtIndex(modes, i); 485 #endif 409 486 SDL_DisplayMode mode; 410 487 if (GetDisplayMode(_this, moderef, modes, link, &mode)) { 488 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 411 489 CGDisplayModeRetain(moderef); 490 #endif 412 491 SDL_AddDisplayMode(display, &mode); 413 492 } 414 493 } … … 433 512 434 513 if (data == display->desktop_mode.driverdata) { 435 514 /* Restoring desktop mode */ 515 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 436 516 CGDisplaySetDisplayMode(displaydata->display, data->moderef, NULL); 517 #else 518 CGDisplaySwitchToMode(displaydata->display, data->moderef); 519 #endif 437 520 438 521 if (CGDisplayIsMain(displaydata->display)) { 439 522 CGReleaseAllDisplays(); … … 458 541 } 459 542 460 543 /* Do the physical switch */ 544 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 461 545 result = CGDisplaySetDisplayMode(displaydata->display, data->moderef, NULL); 546 #else 547 result = CGDisplaySwitchToMode(displaydata->display, data->moderef); 548 #endif 462 549 if (result != kCGErrorSuccess) { 463 550 CG_SetError("CGDisplaySwitchToMode()", result); 464 551 goto ERR_NO_SWITCH; … … 503 590 } 504 591 505 592 mode = (SDL_DisplayModeData *) display->desktop_mode.driverdata; 593 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 506 594 CGDisplayModeRelease(mode->moderef); 595 #endif 507 596 508 597 for (j = 0; j < display->num_display_modes; j++) { 509 598 mode = (SDL_DisplayModeData*) display->display_modes[j].driverdata; 599 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 510 600 CGDisplayModeRelease(mode->moderef); 601 #endif 511 602 } 512 603 513 604 } -
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 25 25 26 26 #include "SDL_cocoavideo.h" 27 27 28 #if !defined(MAC_OS_X_VERSION_10_5) 29 typedef float CGFloat; 30 #endif 31 28 32 extern void Cocoa_InitMouse(_THIS); 29 33 extern void Cocoa_HandleMouseEvent(_THIS, NSEvent * event); 30 34 extern 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 67 67 68 68 static SDL_Cursor * 69 69 Cocoa_CreateDefaultCursor() 70 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 70 71 { @autoreleasepool 71 72 { 73 #else 74 { 75 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 76 #endif 72 77 NSCursor *nscursor; 73 78 SDL_Cursor *cursor = NULL; 74 79 … … 82 87 } 83 88 } 84 89 90 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 91 [pool release]; 92 #endif 85 93 return cursor; 94 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 86 95 }} 96 #else 97 } 98 #endif 87 99 88 100 static SDL_Cursor * 89 101 Cocoa_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) 102 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 90 103 { @autoreleasepool 91 104 { 105 #else 106 { 107 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 108 #endif 92 109 NSImage *nsimage; 93 110 NSCursor *nscursor = NULL; 94 111 SDL_Cursor *cursor = NULL; … … 107 124 } 108 125 } 109 126 127 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 128 [pool release]; 129 #endif 110 130 return cursor; 131 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 111 132 }} 133 #else 134 } 135 #endif 112 136 113 137 static SDL_Cursor * 114 138 Cocoa_CreateSystemCursor(SDL_SystemCursor id) 139 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 115 140 { @autoreleasepool 116 141 { 142 #else 143 { 144 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 145 #endif 117 146 NSCursor *nscursor = NULL; 118 147 SDL_Cursor *cursor = NULL; 119 148 … … 147 176 nscursor = [NSCursor closedHandCursor]; 148 177 break; 149 178 case SDL_SYSTEM_CURSOR_NO: 179 if ([NSCursor respondsToSelector:@selector(operationNotAllowedCursor)]) { 150 180 nscursor = [NSCursor operationNotAllowedCursor]; 181 } 151 182 break; 152 183 case SDL_SYSTEM_CURSOR_HAND: 153 184 nscursor = [NSCursor pointingHandCursor]; … … 166 197 } 167 198 } 168 199 200 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 201 [pool release]; 202 #endif 169 203 return cursor; 204 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 170 205 }} 206 #else 207 } 208 #endif 171 209 172 210 static void 173 211 Cocoa_FreeCursor(SDL_Cursor * cursor) 212 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 174 213 { @autoreleasepool 175 214 { 215 #else 216 { 217 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 218 #endif 176 219 NSCursor *nscursor = (NSCursor *)cursor->driverdata; 177 220 178 221 [nscursor release]; 179 222 SDL_free(cursor); 223 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 180 224 }} 225 #else 226 [pool release]; 227 } 228 #endif 181 229 182 230 static int 183 231 Cocoa_ShowCursor(SDL_Cursor * cursor) 232 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 184 233 { @autoreleasepool 185 234 { 235 #else 236 { 237 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 238 #endif 186 239 SDL_VideoDevice *device = SDL_GetVideoDevice(); 187 240 SDL_Window *window = (device ? device->windows : NULL); 188 241 for (; window != NULL; window = window->next) { … … 193 246 waitUntilDone:NO]; 194 247 } 195 248 } 249 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 250 [pool release]; 251 #endif 196 252 return 0; 253 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 197 254 }} 255 #else 256 } 257 #endif 198 258 199 259 static SDL_Window * 200 260 SDL_FindWindowAtPoint(const int x, const int y) … … 214 274 static int 215 275 Cocoa_WarpMouseGlobal(int x, int y) 216 276 { 277 const CGPoint point = CGPointMake((float)x, (float)y); 217 278 SDL_Mouse *mouse = SDL_GetMouse(); 218 279 if (mouse->focus) { 219 280 SDL_WindowData *data = (SDL_WindowData *) mouse->focus->driverdata; … … 223 284 return 0; 224 285 } 225 286 } 226 const CGPoint point = CGPointMake((float)x, (float)y);227 287 228 288 Cocoa_HandleMouseWarp(point.x, point.y); 229 289 … … 261 321 static int 262 322 Cocoa_SetRelativeMouseMode(SDL_bool enabled) 263 323 { 324 CGError result; 325 SDL_WindowData *data; 264 326 /* We will re-apply the relative mode when the window gets focus, if it 265 327 * doesn't have focus right now. 266 328 */ … … 272 334 /* We will re-apply the relative mode when the window finishes being moved, 273 335 * if it is being moved right now. 274 336 */ 275 SDL_WindowData *data = (SDL_WindowData *) window->driverdata;337 data = (SDL_WindowData *) window->driverdata; 276 338 if ([data->listener isMoving]) { 277 339 return 0; 278 340 } 279 341 280 CGError result;281 342 if (enabled) { 282 343 DLog("Turning on."); 283 344 result = CGAssociateMouseAndMouseCursorPosition(NO); … … 311 372 static Uint32 312 373 Cocoa_GetGlobalMouseState(int *x, int *y) 313 374 { 314 const NSUInteger cocoaButtons = [NSEvent pressedMouseButtons];375 NSUInteger cocoaButtons = 0; 315 376 const NSPoint cocoaLocation = [NSEvent mouseLocation]; 316 377 Uint32 retval = 0; 378 #if !defined(MAC_OS_X_VERSION_10_5) 379 int i; 380 #endif 317 381 382 if ([NSEvent respondsToSelector:@selector(pressedMouseButtons)]) { 383 cocoaButtons = [NSEvent pressedMouseButtons]; 384 } 385 386 #if defined(MAC_OS_X_VERSION_10_5) 318 387 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 319 393 NSRect frame = [screen frame]; 320 394 if (NSMouseInRect(cocoaLocation, frame, NO)) { 321 395 *x = (int) cocoaLocation.x; … … 336 410 void 337 411 Cocoa_InitMouse(_THIS) 338 412 { 413 SDL_MouseData *driverdata; 414 NSPoint location; 339 415 SDL_Mouse *mouse = SDL_GetMouse(); 340 416 341 417 mouse->driverdata = SDL_calloc(1, sizeof(SDL_MouseData)); … … 354 430 355 431 Cocoa_InitMouseEventTap(mouse->driverdata); 356 432 357 SDL_MouseData *driverdata = (SDL_MouseData*)mouse->driverdata;358 const NSPointlocation = [NSEvent mouseLocation];433 driverdata = (SDL_MouseData*)mouse->driverdata; 434 location = [NSEvent mouseLocation]; 359 435 driverdata->lastMoveX = location.x; 360 436 driverdata->lastMoveY = location.y; 361 437 } … … 363 439 void 364 440 Cocoa_HandleMouseEvent(_THIS, NSEvent *event) 365 441 { 442 SDL_Mouse *mouse; 443 SDL_MouseData *driverdata; 444 SDL_bool seenWarp; 366 445 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 367 452 case NSEventTypeMouseMoved: 368 453 case NSEventTypeLeftMouseDragged: 369 454 case NSEventTypeRightMouseDragged: 370 455 case NSEventTypeOtherMouseDragged: 456 #endif 371 457 break; 372 458 373 459 default: … … 375 461 return; 376 462 } 377 463 378 SDL_Mouse *mouse = SDL_GetMouse();379 SDL_MouseData *driverdata = (SDL_MouseData*)mouse->driverdata;464 mouse = SDL_GetMouse(); 465 driverdata = (SDL_MouseData*)mouse->driverdata; 380 466 if (!driverdata) { 381 467 return; /* can happen when returning from fullscreen Space on shutdown */ 382 468 } 383 469 384 const SDL_boolseenWarp = driverdata->seenWarp;470 seenWarp = driverdata->seenWarp; 385 471 driverdata->seenWarp = NO; 386 472 473 { 474 float deltaX; 475 float deltaY; 387 476 const NSPoint location = [NSEvent mouseLocation]; 388 477 const CGFloat lastMoveX = driverdata->lastMoveX; 389 478 const CGFloat lastMoveY = driverdata->lastMoveY; … … 404 493 } 405 494 } 406 495 407 floatdeltaX = [event deltaX];408 floatdeltaY = [event deltaY];496 deltaX = [event deltaX]; 497 deltaY = [event deltaY]; 409 498 410 499 if (seenWarp) { 411 500 deltaX += (lastMoveX - driverdata->lastWarpX); … … 415 504 } 416 505 417 506 SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 1, (int)deltaX, (int)deltaY); 507 } 418 508 } 419 509 420 510 void -
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 150 150 151 151 SDL_GLContext 152 152 Cocoa_GL_CreateContext(_THIS, SDL_Window * window) 153 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 153 154 { @autoreleasepool 154 155 { 156 #else 157 { 158 NSAutoreleasePool *pool; 159 #endif 155 160 SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); 156 161 SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata; 162 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1670 157 163 SDL_bool lion_or_later = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6; 164 #else 165 SDL_bool lion_or_later = SDL_FALSE; 166 #endif 158 167 NSOpenGLPixelFormatAttribute attr[32]; 159 168 NSOpenGLPixelFormat *fmt; 160 169 SDLOpenGLContext *context; … … 173 182 return NULL; 174 183 } 175 184 185 #if defined(MAC_OS_X_VERSION_10_5) 176 186 attr[i++] = NSOpenGLPFAAllowOfflineRenderers; 187 #endif 177 188 189 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 190 pool = [[NSAutoreleasePool alloc] init]; 191 #endif 178 192 /* specify a profile if we're on Lion (10.7) or later. */ 193 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 179 194 if (lion_or_later) { 180 195 NSOpenGLPixelFormatAttribute profile = NSOpenGLProfileVersionLegacy; 181 196 if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) { … … 184 199 attr[i++] = NSOpenGLPFAOpenGLProfile; 185 200 attr[i++] = profile; 186 201 } 202 #endif 187 203 188 204 attr[i++] = NSOpenGLPFAColorSize; 189 205 attr[i++] = SDL_BYTESPERPIXEL(display->current_mode.format)*8; … … 239 255 fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr]; 240 256 if (fmt == nil) { 241 257 SDL_SetError("Failed creating OpenGL pixel format"); 258 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 259 [pool release]; 260 #endif 242 261 return NULL; 243 262 } 244 263 … … 252 271 253 272 if (context == nil) { 254 273 SDL_SetError("Failed creating OpenGL context"); 274 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 275 [pool release]; 276 #endif 255 277 return NULL; 256 278 } 257 279 258 280 if ( Cocoa_GL_MakeCurrent(_this, window, context) < 0 ) { 259 281 Cocoa_GL_DeleteContext(_this, context); 260 282 SDL_SetError("Failed making OpenGL context current"); 283 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 284 [pool release]; 285 #endif 261 286 return NULL; 262 287 } 263 288 … … 272 297 if (!glGetStringFunc) { 273 298 Cocoa_GL_DeleteContext(_this, context); 274 299 SDL_SetError ("Failed getting OpenGL glGetString entry point"); 300 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 301 [pool release]; 302 #endif 275 303 return NULL; 276 304 } 277 305 … … 279 307 if (glversion == NULL) { 280 308 Cocoa_GL_DeleteContext(_this, context); 281 309 SDL_SetError ("Failed getting OpenGL context version"); 310 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 311 [pool release]; 312 #endif 282 313 return NULL; 283 314 } 284 315 285 316 if (SDL_sscanf(glversion, "%d.%d", &glversion_major, &glversion_minor) != 2) { 286 317 Cocoa_GL_DeleteContext(_this, context); 287 318 SDL_SetError ("Failed parsing OpenGL context version"); 319 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 320 [pool release]; 321 #endif 288 322 return NULL; 289 323 } 290 324 … … 292 326 ((glversion_major == _this->gl_config.major_version) && (glversion_minor < _this->gl_config.minor_version))) { 293 327 Cocoa_GL_DeleteContext(_this, context); 294 328 SDL_SetError ("Failed creating OpenGL context at version requested"); 329 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 330 [pool release]; 331 #endif 295 332 return NULL; 296 333 } 297 334 … … 301 338 /*_this->gl_config.major_version = glversion_major;*/ 302 339 /*_this->gl_config.minor_version = glversion_minor;*/ 303 340 } 341 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 342 [pool release]; 343 #endif 304 344 return context; 345 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 346 } 347 #else 305 348 }} 349 #endif 306 350 307 351 int 308 352 Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) 353 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 309 354 { @autoreleasepool 310 355 { 356 #else 357 { 358 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 359 #endif 311 360 if (context) { 312 361 SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context; 313 362 [nscontext setWindow:window]; … … 317 366 [NSOpenGLContext clearCurrentContext]; 318 367 } 319 368 369 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 370 [pool release]; 371 #endif 320 372 return 0; 373 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 321 374 }} 375 #else 376 } 377 #endif 322 378 323 379 void 324 380 Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h) … … 329 385 330 386 /* This gives us the correct viewport for a Retina-enabled view, only 331 387 * supported on 10.7+. */ 388 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 332 389 if ([contentView respondsToSelector:@selector(convertRectToBacking:)]) { 333 390 viewport = [contentView convertRectToBacking:viewport]; 334 391 } 392 #endif 335 393 336 394 if (w) { 337 395 *w = viewport.size.width; … … 344 402 345 403 int 346 404 Cocoa_GL_SetSwapInterval(_THIS, int interval) 405 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 347 406 { @autoreleasepool 407 #endif 348 408 { 349 409 NSOpenGLContext *nscontext; 350 410 GLint value; … … 353 413 if (interval < 0) { /* no extension for this on Mac OS X at the moment. */ 354 414 return SDL_SetError("Late swap tearing currently unsupported"); 355 415 } 416 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 417 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 418 #endif 356 419 357 420 nscontext = (NSOpenGLContext*)SDL_GL_GetCurrentContext(); 358 421 if (nscontext != nil) { … … 363 426 status = SDL_SetError("No current OpenGL context"); 364 427 } 365 428 429 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 430 [pool release]; 431 #endif 366 432 return status; 433 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 367 434 }} 435 #else 436 } 437 #endif 368 438 369 439 int 370 440 Cocoa_GL_GetSwapInterval(_THIS) 441 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 371 442 { @autoreleasepool 372 443 { 444 #else 445 { 446 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 447 #endif 373 448 NSOpenGLContext *nscontext; 374 449 GLint value; 375 450 int status = 0; … … 380 455 status = (int)value; 381 456 } 382 457 458 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 459 [pool release]; 460 #endif 383 461 return status; 462 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 384 463 }} 464 #else 465 } 466 #endif 385 467 386 468 int 387 469 Cocoa_GL_SwapWindow(_THIS, SDL_Window * window) 470 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 388 471 { @autoreleasepool 389 472 { 473 #else 474 { 475 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 476 #endif 390 477 SDLOpenGLContext* nscontext = (SDLOpenGLContext*)SDL_GL_GetCurrentContext(); 391 478 [nscontext flushBuffer]; 392 479 [nscontext updateIfNeeded]; 480 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 481 [pool release]; 482 #endif 393 483 return 0; 484 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 394 485 }} 486 #else 487 } 488 #endif 395 489 396 490 void 397 491 Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context) 492 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 398 493 { @autoreleasepool 399 494 { 495 #else 496 { 497 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 498 #endif 400 499 SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context; 401 500 402 501 [nscontext setWindow:NULL]; 403 502 [nscontext release]; 503 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 404 504 }} 505 #else 506 [pool release]; 507 } 508 #endif 405 509 406 510 #endif /* SDL_VIDEO_OPENGL_CGL */ 407 511 -
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 35 35 SDL_WindowData* windata = (SDL_WindowData*)window->driverdata; 36 36 [windata->nswindow setOpaque:NO]; 37 37 38 if ([windata->nswindow respondsToSelector:@selector(setStyleMask:)]) { 38 39 [windata->nswindow setStyleMask:NSWindowStyleMaskBorderless]; 40 } 39 41 40 42 SDL_WindowShaper* result = result = malloc(sizeof(SDL_WindowShaper)); 41 43 result->window = window; … … 73 75 74 76 int 75 77 Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode) 78 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 76 79 { @autoreleasepool 77 80 { 81 #else 82 { 83 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 84 #endif 78 85 SDL_ShapeData* data = (SDL_ShapeData*)shaper->driverdata; 79 86 SDL_WindowData* windata = (SDL_WindowData*)shaper->window->driverdata; 80 87 SDL_CocoaClosure closure; … … 97 104 SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure); 98 105 [closure.path addClip]; 99 106 107 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 108 [pool release]; 109 #endif 100 110 return 0; 111 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 101 112 }} 113 #else 114 } 115 #endif 102 116 103 117 int 104 118 Cocoa_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 25 25 26 26 #include "SDL_opengl.h" 27 27 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 28 34 #include <ApplicationServices/ApplicationServices.h> 29 35 #include <IOKit/pwr_mgt/IOPMLib.h> 30 36 #include <Cocoa/Cocoa.h> … … 40 46 #include "SDL_cocoaopengl.h" 41 47 #include "SDL_cocoawindow.h" 42 48 49 #if !defined(MAC_OS_X_VERSION_10_5) 50 typedef long int NSInteger; 51 typedef unsigned int NSUInteger; 52 #endif 53 43 54 #ifndef MAC_OS_X_VERSION_10_12 44 55 #define DECLARE_EVENT(name) static const NSEventType NSEventType##name = NS##name 45 56 DECLARE_EVENT(LeftMouseDown); … … 58 69 DECLARE_EVENT(FlagsChanged); 59 70 #undef DECLARE_EVENT 60 71 72 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 61 73 static const NSEventMask NSEventMaskAny = NSAnyEventMask; 74 #endif 62 75 63 76 #define DECLARE_MODIFIER_FLAG(name) static const NSUInteger NSEventModifierFlag##name = NS##name##KeyMask 64 77 DECLARE_MODIFIER_FLAG(Shift); … … 79 92 DECLARE_WINDOW_MASK(Resizable); 80 93 DECLARE_WINDOW_MASK(TexturedBackground); 81 94 DECLARE_WINDOW_MASK(UnifiedTitleAndToolbar); 95 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 82 96 DECLARE_WINDOW_MASK(FullScreen); 97 #endif 83 98 /*DECLARE_WINDOW_MASK(FullSizeContentView);*/ /* Not used, fails compile on older SDKs */ 84 99 static const unsigned int NSWindowStyleMaskUtilityWindow = NSUtilityWindowMask; 85 100 static const unsigned int NSWindowStyleMaskDocModalWindow = NSDocModalWindowMask; 101 #if defined(MAC_OS_X_VERSION_10_5) 86 102 static const unsigned int NSWindowStyleMaskHUDWindow = NSHUDWindowMask; 103 #endif 87 104 #undef DECLARE_WINDOW_MASK 88 105 89 106 #define DECLARE_ALERT_STYLE(name) static const NSUInteger NSAlertStyle##name = NS##name##AlertStyle … … 106 123 NSInteger clipboard_count; 107 124 Uint32 screensaver_activity; 108 125 BOOL screensaver_use_iopm; 126 #if defined(MAC_OS_X_VERSION_10_5) 109 127 IOPMAssertionID screensaver_assertion; 128 #endif 110 129 111 130 } SDL_VideoData; 112 131 -
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 22 22 23 23 #if SDL_VIDEO_DRIVER_COCOA 24 24 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 25 32 #include "SDL.h" 26 33 #include "SDL_endian.h" 27 34 #include "SDL_cocoavideo.h" … … 159 166 Cocoa_InitKeyboard(_this); 160 167 Cocoa_InitMouse(_this); 161 168 169 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 162 170 data->allow_spaces = ((floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) && SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_TRUE)); 163 171 164 172 /* The IOPM assertion API can disable the screensaver as of 10.7. */ 165 173 data->screensaver_use_iopm = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6; 174 #else 175 data->allow_spaces = 0; 176 data->screensaver_use_iopm = 0; 177 #endif 166 178 167 179 return 0; 168 180 } -
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 23 23 #ifndef SDL_cocoawindow_h_ 24 24 #define SDL_cocoawindow_h_ 25 25 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 26 33 #import <Cocoa/Cocoa.h> 27 34 28 35 typedef struct SDL_WindowData SDL_WindowData; … … 35 42 PENDING_OPERATION_MINIMIZE 36 43 } PendingWindowOperation; 37 44 45 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 38 46 @interface Cocoa_WindowListener : NSResponder <NSWindowDelegate> { 47 #else 48 @interface Cocoa_WindowListener : NSResponder { 49 #endif 39 50 SDL_WindowData *_data; 40 51 BOOL observingVisible; 41 52 BOOL wasCtrlLeft; … … 75 86 -(void) windowDidEnterFullScreen:(NSNotification *) aNotification; 76 87 -(void) windowWillExitFullScreen:(NSNotification *) aNotification; 77 88 -(void) windowDidExitFullScreen:(NSNotification *) aNotification; 89 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 78 90 -(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions; 91 #endif 79 92 80 93 /* See if event is in a drag area, toggle on window dragging. */ 81 94 -(BOOL) processHitTest:(NSEvent *)theEvent; … … 98 111 -(void) touchesCancelledWithEvent:(NSEvent *) theEvent; 99 112 100 113 /* Touch event handling */ 114 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 101 115 -(void) handleTouches:(NSTouchPhase) phase withEvent:(NSEvent*) theEvent; 116 #else 117 typedef 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 102 125 103 126 @end 104 127 /* *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 23 23 #if SDL_VIDEO_DRIVER_COCOA 24 24 25 25 #if MAC_OS_X_VERSION_MAX_ALLOWED < 1070 26 #if 0 26 27 # error SDL for Mac OS X must be built with a 10.7 SDK or above. 28 #endif 27 29 #endif /* MAC_OS_X_VERSION_MAX_ALLOWED < 1070 */ 28 30 29 31 #include "SDL_syswm.h" … … 54 56 #define FULLSCREEN_MASK (SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN) 55 57 56 58 59 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 60 @interface SDLWindow : NSWindow 61 #else 57 62 @interface SDLWindow : NSWindow <NSDraggingDestination> 63 #endif 58 64 /* These are needed for borderless/fullscreen windows */ 59 65 - (BOOL)canBecomeKeyWindow; 60 66 - (BOOL)canBecomeMainWindow; … … 136 142 } 137 143 138 144 - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender 145 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 139 146 { @autoreleasepool 140 147 { 148 #else 149 { 150 NSAutoreleasePool *pool; 151 #endif 141 152 NSPasteboard *pasteboard = [sender draggingPasteboard]; 142 153 NSArray *types = [NSArray arrayWithObject:NSFilenamesPboardType]; 143 154 NSString *desiredType = [pasteboard availableTypeFromArray:types]; 144 155 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 145 161 146 162 if (desiredType == nil) { 147 163 return NO; /* can't accept anything that's being dropped here. */ 148 164 } 149 165 150 NSData *data = [pasteboard dataForType:desiredType];166 data = [pasteboard dataForType:desiredType]; 151 167 if (data == nil) { 152 168 return NO; 153 169 } 154 170 171 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 172 pool = [[NSAutoreleasePool alloc] init]; 173 #endif 174 155 175 SDL_assert([desiredType isEqualToString:NSFilenamesPboardType]); 176 #if defined(MAC_OS_X_VERSION_10_5) 156 177 NSArray *array = [pasteboard propertyListForType:@"NSFilenamesPboardType"]; 157 178 158 179 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 159 186 NSURL *fileURL = [NSURL fileURLWithPath:path]; 187 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 160 188 NSNumber *isAlias = nil; 161 189 162 190 [fileURL getResourceValue:&isAlias forKey:NSURLIsAliasFileKey error:nil]; … … 177 205 } 178 206 } 179 207 } 208 #endif 180 209 181 210 if (!SDL_SendDropFile(sdlwindow, [[fileURL path] UTF8String])) { 211 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 212 [pool release]; 213 #endif 182 214 return NO; 183 215 } 184 216 } 185 217 218 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 219 [pool release]; 220 #endif 186 221 SDL_SendDropComplete(sdlwindow); 187 222 return YES; 223 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 224 } 225 #else 188 226 }} 227 #endif 189 228 190 229 - (BOOL)wantsPeriodicDraggingUpdates 191 230 { … … 226 265 NSOpenGLContext *currentContext = [NSOpenGLContext currentContext]; 227 266 NSMutableArray *contexts = data->nscontexts; 228 267 @synchronized (contexts) { 268 #if defined(MAC_OS_X_VERSION_10_5) 229 269 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 230 276 if (context == currentContext) { 231 277 [context update]; 232 278 } else { … … 274 320 [[nswindow contentView] setNextResponder:nil]; 275 321 } 276 322 323 if ([nswindow respondsToSelector:@selector(setStyleMask:)]) { 277 324 [nswindow setStyleMask:style]; 325 } 278 326 279 327 /* The view responder chain gets messed with during setStyleMask */ 280 328 if ([[nswindow contentView] nextResponder] != data->listener) { … … 313 361 [center addObserver:self selector:@selector(windowDidDeminiaturize:) name:NSWindowDidDeminiaturizeNotification object:window]; 314 362 [center addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:window]; 315 363 [center addObserver:self selector:@selector(windowDidResignKey:) name:NSWindowDidResignKeyNotification object:window]; 364 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 316 365 [center addObserver:self selector:@selector(windowDidChangeBackingProperties:) name:NSWindowDidChangeBackingPropertiesNotification object:window]; 317 366 [center addObserver:self selector:@selector(windowWillEnterFullScreen:) name:NSWindowWillEnterFullScreenNotification object:window]; 318 367 [center addObserver:self selector:@selector(windowDidEnterFullScreen:) name:NSWindowDidEnterFullScreenNotification object:window]; 319 368 [center addObserver:self selector:@selector(windowWillExitFullScreen:) name:NSWindowWillExitFullScreenNotification object:window]; 320 369 [center addObserver:self selector:@selector(windowDidExitFullScreen:) name:NSWindowDidExitFullScreenNotification object:window]; 370 #endif 321 371 [center addObserver:self selector:@selector(windowDidFailToEnterFullScreen:) name:@"NSWindowDidFailToEnterFullScreenNotification" object:window]; 322 372 [center addObserver:self selector:@selector(windowDidFailToExitFullScreen:) name:@"NSWindowDidFailToExitFullScreenNotification" object:window]; 323 373 } else { … … 338 388 339 389 [view setNextResponder:self]; 340 390 391 if ([view respondsToSelector:@selector(setAcceptsTouchEvents:)]) { 341 392 [view setAcceptsTouchEvents:YES]; 393 } 342 394 } 343 395 344 396 - (void)observeValueForKeyPath:(NSString *)keyPath … … 408 460 inFullscreenTransition = YES; 409 461 410 462 /* you need to be FullScreenPrimary, or toggleFullScreen doesn't work. Unset it again in windowDidExitFullScreen. */ 463 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 411 464 [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; 465 #endif 412 466 [nswindow performSelectorOnMainThread: @selector(toggleFullScreen:) withObject:nswindow waitUntilDone:NO]; 413 467 return YES; 414 468 } … … 444 498 [center removeObserver:self name:NSWindowDidDeminiaturizeNotification object:window]; 445 499 [center removeObserver:self name:NSWindowDidBecomeKeyNotification object:window]; 446 500 [center removeObserver:self name:NSWindowDidResignKeyNotification object:window]; 501 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 447 502 [center removeObserver:self name:NSWindowDidChangeBackingPropertiesNotification object:window]; 448 503 [center removeObserver:self name:NSWindowWillEnterFullScreenNotification object:window]; 449 504 [center removeObserver:self name:NSWindowDidEnterFullScreenNotification object:window]; 450 505 [center removeObserver:self name:NSWindowWillExitFullScreenNotification object:window]; 451 506 [center removeObserver:self name:NSWindowDidExitFullScreenNotification object:window]; 507 #endif 452 508 [center removeObserver:self name:@"NSWindowDidFailToEnterFullScreenNotification" object:window]; 453 509 [center removeObserver:self name:@"NSWindowDidFailToExitFullScreenNotification" object:window]; 454 510 } else { … … 628 684 [NSMenu setMenuBarVisible:NO]; 629 685 } 630 686 687 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 631 688 const unsigned int newflags = [NSEvent modifierFlags] & NSEventModifierFlagCapsLock; 632 689 _data->videodata->modifierFlags = (_data->videodata->modifierFlags & ~NSEventModifierFlagCapsLock) | newflags; 633 690 SDL_ToggleModState(KMOD_CAPS, newflags != 0); 691 #endif 634 692 } 635 693 636 694 - (void)windowDidResignKey:(NSNotification *)aNotification … … 657 715 658 716 - (void)windowDidChangeBackingProperties:(NSNotification *)aNotification 659 717 { 718 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 660 719 NSNumber *oldscale = [[aNotification userInfo] objectForKey:NSBackingPropertyOldScaleFactorKey]; 661 720 662 721 if (inFullscreenTransition) { … … 669 728 _data->window->h = 0; 670 729 [self windowDidResize:aNotification]; 671 730 } 731 #endif 672 732 } 673 733 674 734 - (void)windowWillEnterFullScreen:(NSNotification *)aNotification … … 777 837 [nswindow miniaturize:nil]; 778 838 } else { 779 839 /* Adjust the fullscreen toggle button and readd menu now that we're here. */ 840 #if MAC_OS_X_VERSION_MIN_REQUIRED > 1070 780 841 if (window->flags & SDL_WINDOW_RESIZABLE) { 781 842 /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */ 782 843 [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; 783 844 } else { 784 845 [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged]; 785 846 } 847 #endif 786 848 [NSMenu setMenuBarVisible:YES]; 787 849 788 850 pendingWindowOperation = PENDING_OPERATION_NONE; … … 825 887 } 826 888 } 827 889 890 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 828 891 -(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions 829 892 { 830 893 if ((_data->window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) { … … 833 896 return proposedOptions; 834 897 } 835 898 } 899 #endif 836 900 837 901 838 902 /* We'll respond to key events by doing nothing so we don't beep. … … 1059 1123 1060 1124 - (void)touchesBeganWithEvent:(NSEvent *) theEvent 1061 1125 { 1126 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1062 1127 NSSet *touches = [theEvent touchesMatchingPhase:NSTouchPhaseAny inView:nil]; 1063 1128 int existingTouchCount = 0; 1064 1129 … … 1079 1144 1080 1145 DLog("Began Fingers: %lu .. existing: %d", (unsigned long)[touches count], existingTouchCount); 1081 1146 [self handleTouches:NSTouchPhaseBegan withEvent:theEvent]; 1147 #endif 1082 1148 } 1083 1149 1084 1150 - (void)touchesMovedWithEvent:(NSEvent *) theEvent 1085 1151 { 1152 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1086 1153 [self handleTouches:NSTouchPhaseMoved withEvent:theEvent]; 1154 #endif 1087 1155 } 1088 1156 1089 1157 - (void)touchesEndedWithEvent:(NSEvent *) theEvent 1090 1158 { 1159 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1091 1160 [self handleTouches:NSTouchPhaseEnded withEvent:theEvent]; 1161 #endif 1092 1162 } 1093 1163 1094 1164 - (void)touchesCancelledWithEvent:(NSEvent *) theEvent 1095 1165 { 1166 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1096 1167 [self handleTouches:NSTouchPhaseCancelled withEvent:theEvent]; 1168 #endif 1097 1169 } 1098 1170 1171 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 1172 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 1099 1173 - (void)handleTouches:(NSTouchPhase) phase withEvent:(NSEvent *) theEvent 1174 #else 1175 - (void)handleTouches:(cocoaTouchType)type withEvent:(NSEvent *)event 1176 #endif 1100 1177 { 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 1101 1230 NSSet *touches = [theEvent touchesMatchingPhase:phase inView:nil]; 1102 1231 1103 1232 for (NSTouch *touch in touches) { … … 1127 1256 break; 1128 1257 } 1129 1258 } 1259 #endif 1130 1260 } 1261 #endif 1131 1262 1132 1263 @end 1133 1264 … … 1194 1325 1195 1326 static int 1196 1327 SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created) 1328 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1197 1329 { @autoreleasepool 1198 1330 { 1331 #else 1332 { 1333 NSAutoreleasePool *pool; 1334 #endif 1199 1335 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; 1200 1336 SDL_WindowData *data; 1201 1337 … … 1210 1346 data->videodata = videodata; 1211 1347 data->nscontexts = [[NSMutableArray alloc] init]; 1212 1348 1349 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 1350 pool = [[NSAutoreleasePool alloc] init]; 1351 #endif 1213 1352 /* Create an event listener for the window */ 1214 1353 data->listener = [[Cocoa_WindowListener alloc] init]; 1215 1354 … … 1270 1409 */ 1271 1410 [nswindow setOneShot:NO]; 1272 1411 1412 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 1413 [pool release]; 1414 #endif 1273 1415 /* All done! */ 1274 1416 window->driverdata = data; 1275 1417 return 0; 1418 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 1419 } 1420 #else 1276 1421 }} 1422 #endif 1277 1423 1278 1424 int 1279 1425 Cocoa_CreateWindow(_THIS, SDL_Window * window) 1426 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1280 1427 { @autoreleasepool 1281 1428 { 1429 #else 1430 { 1431 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 1432 #endif 1282 1433 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; 1283 1434 NSWindow *nswindow; 1284 1435 SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); … … 1286 1437 SDL_Rect bounds; 1287 1438 NSUInteger style; 1288 1439 NSArray *screens = [NSScreen screens]; 1440 #if !defined(MAC_OS_X_VERSION_10_5) 1441 NSScreen *screen = nil; 1442 int i; 1443 #endif 1289 1444 1290 1445 Cocoa_GetDisplayBounds(_this, display, &bounds); 1291 1446 rect.origin.x = window->x; … … 1297 1452 style = GetWindowStyle(window); 1298 1453 1299 1454 /* Figure out which screen to place this window */ 1455 #if defined(MAC_OS_X_VERSION_10_5) 1300 1456 NSScreen *screen = nil; 1301 1457 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 1302 1463 NSRect screenRect = [candidate frame]; 1303 1464 if (rect.origin.x >= screenRect.origin.x && 1304 1465 rect.origin.x < screenRect.origin.x + screenRect.size.width && … … 1319 1480 [nswindow setBackgroundColor:[NSColor blackColor]]; 1320 1481 1321 1482 if (videodata->allow_spaces) { 1483 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 1322 1484 SDL_assert(floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6); 1323 1485 SDL_assert([nswindow respondsToSelector:@selector(toggleFullScreen:)]); 1324 1486 /* we put FULLSCREEN_DESKTOP windows in their own Space, without a toggle button or menubar, later */ … … 1326 1488 /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */ 1327 1489 [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; 1328 1490 } 1491 #endif 1329 1492 } 1330 1493 1331 1494 /* Create a default view for this window */ … … 1344 1507 1345 1508 /* Allow files and folders to be dragged onto the window by users */ 1346 1509 [nswindow registerForDraggedTypes:[NSArray arrayWithObject:(NSString *)kUTTypeFileURL]]; 1510 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 1511 [pool release]; 1512 #endif 1347 1513 1348 1514 if (SetupWindowData(_this, window, nswindow, SDL_TRUE) < 0) { 1349 1515 [nswindow release]; 1350 1516 return -1; 1351 1517 } 1352 1518 return 0; 1519 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1353 1520 }} 1521 #else 1522 } 1523 #endif 1354 1524 1355 1525 int 1356 1526 Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) 1527 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1357 1528 { @autoreleasepool 1358 1529 { 1530 #else 1531 { 1532 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 1533 #endif 1359 1534 NSWindow *nswindow = (NSWindow *) data; 1360 1535 NSString *title; 1361 1536 … … 1366 1541 } 1367 1542 1368 1543 return SetupWindowData(_this, window, nswindow, SDL_FALSE); 1544 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1369 1545 }} 1546 #else 1547 [pool release]; 1548 } 1549 #endif 1370 1550 1371 1551 void 1372 1552 Cocoa_SetWindowTitle(_THIS, SDL_Window * window) 1553 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1373 1554 { @autoreleasepool 1374 1555 { 1556 #else 1557 { 1558 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 1559 #endif 1375 1560 const char *title = window->title ? window->title : ""; 1376 1561 NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow; 1377 1562 NSString *string = [[NSString alloc] initWithUTF8String:title]; 1378 1563 [nswindow setTitle:string]; 1379 1564 [string release]; 1565 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1380 1566 }} 1567 #else 1568 [pool release]; 1569 } 1570 #endif 1381 1571 1382 1572 void 1383 1573 Cocoa_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) 1574 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1384 1575 { @autoreleasepool 1385 1576 { 1577 #else 1578 { 1579 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 1580 #endif 1386 1581 NSImage *nsimage = Cocoa_CreateImage(icon); 1387 1582 1388 1583 if (nsimage) { 1389 1584 [NSApp setApplicationIconImage:nsimage]; 1390 1585 } 1586 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1391 1587 }} 1588 #else 1589 [pool release]; 1590 } 1591 #endif 1392 1592 1393 1593 void 1394 1594 Cocoa_SetWindowPosition(_THIS, SDL_Window * window) 1595 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1395 1596 { @autoreleasepool 1396 1597 { 1598 #else 1599 { 1600 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 1601 #endif 1397 1602 SDL_WindowData *windata = (SDL_WindowData *) window->driverdata; 1398 1603 NSWindow *nswindow = windata->nswindow; 1399 1604 NSRect rect; … … 1411 1616 s_moveHack = moveHack; 1412 1617 1413 1618 ScheduleContextUpdates(windata); 1619 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1414 1620 }} 1621 #else 1622 [pool release]; 1623 } 1624 #endif 1415 1625 1416 1626 void 1417 1627 Cocoa_SetWindowSize(_THIS, SDL_Window * window) 1628 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1418 1629 { @autoreleasepool 1419 1630 { 1631 #else 1632 { 1633 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 1634 #endif 1420 1635 SDL_WindowData *windata = (SDL_WindowData *) window->driverdata; 1421 1636 NSWindow *nswindow = windata->nswindow; 1422 1637 NSRect rect; … … 1438 1653 s_moveHack = moveHack; 1439 1654 1440 1655 ScheduleContextUpdates(windata); 1656 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1441 1657 }} 1658 #else 1659 [pool release]; 1660 } 1661 #endif 1442 1662 1443 1663 void 1444 1664 Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window) 1665 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1445 1666 { @autoreleasepool 1446 1667 { 1668 #else 1669 { 1670 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 1671 #endif 1447 1672 SDL_WindowData *windata = (SDL_WindowData *) window->driverdata; 1448 1673 1449 1674 NSSize minSize; … … 1451 1676 minSize.height = window->min_h; 1452 1677 1453 1678 [windata->nswindow setContentMinSize:minSize]; 1679 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1454 1680 }} 1681 #else 1682 [pool release]; 1683 } 1684 #endif 1455 1685 1456 1686 void 1457 1687 Cocoa_SetWindowMaximumSize(_THIS, SDL_Window * window) 1688 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1458 1689 { @autoreleasepool 1459 1690 { 1691 #else 1692 { 1693 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 1694 #endif 1460 1695 SDL_WindowData *windata = (SDL_WindowData *) window->driverdata; 1461 1696 1462 1697 NSSize maxSize; … … 1464 1699 maxSize.height = window->max_h; 1465 1700 1466 1701 [windata->nswindow setContentMaxSize:maxSize]; 1702 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1467 1703 }} 1704 #else 1705 [pool release]; 1706 } 1707 #endif 1468 1708 1469 1709 void 1470 1710 Cocoa_ShowWindow(_THIS, SDL_Window * window) 1711 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1471 1712 { @autoreleasepool 1472 1713 { 1714 #else 1715 { 1716 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 1717 #endif 1473 1718 SDL_WindowData *windowData = ((SDL_WindowData *) window->driverdata); 1474 1719 NSWindow *nswindow = windowData->nswindow; 1475 1720 … … 1478 1723 [nswindow makeKeyAndOrderFront:nil]; 1479 1724 [windowData->listener resumeVisibleObservation]; 1480 1725 } 1726 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1481 1727 }} 1728 #else 1729 [pool release]; 1730 } 1731 #endif 1482 1732 1483 1733 void 1484 1734 Cocoa_HideWindow(_THIS, SDL_Window * window) 1735 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1485 1736 { @autoreleasepool 1486 1737 { 1738 #else 1739 { 1740 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 1741 #endif 1487 1742 NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow; 1488 1743 1489 1744 [nswindow orderOut:nil]; 1745 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1490 1746 }} 1747 #else 1748 [pool release]; 1749 } 1750 #endif 1491 1751 1492 1752 void 1493 1753 Cocoa_RaiseWindow(_THIS, SDL_Window * window) 1754 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1494 1755 { @autoreleasepool 1495 1756 { 1757 #else 1758 { 1759 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 1760 #endif 1496 1761 SDL_WindowData *windowData = ((SDL_WindowData *) window->driverdata); 1497 1762 NSWindow *nswindow = windowData->nswindow; 1498 1763 … … 1505 1770 [nswindow makeKeyAndOrderFront:nil]; 1506 1771 } 1507 1772 [windowData->listener resumeVisibleObservation]; 1773 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1508 1774 }} 1775 #else 1776 [pool release]; 1777 } 1778 #endif 1509 1779 1510 1780 void 1511 1781 Cocoa_MaximizeWindow(_THIS, SDL_Window * window) 1782 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1512 1783 { @autoreleasepool 1513 1784 { 1785 #else 1786 { 1787 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 1788 #endif 1514 1789 SDL_WindowData *windata = (SDL_WindowData *) window->driverdata; 1515 1790 NSWindow *nswindow = windata->nswindow; 1516 1791 1517 1792 [nswindow zoom:nil]; 1518 1793 1519 1794 ScheduleContextUpdates(windata); 1795 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1520 1796 }} 1797 #else 1798 [pool release]; 1799 } 1800 #endif 1521 1801 1522 1802 void 1523 1803 Cocoa_MinimizeWindow(_THIS, SDL_Window * window) 1804 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1524 1805 { @autoreleasepool 1525 1806 { 1807 #else 1808 { 1809 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 1810 #endif 1526 1811 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; 1527 1812 NSWindow *nswindow = data->nswindow; 1528 1813 … … 1531 1816 } else { 1532 1817 [nswindow miniaturize:nil]; 1533 1818 } 1819 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1534 1820 }} 1821 #else 1822 [pool release]; 1823 } 1824 #endif 1535 1825 1536 1826 void 1537 1827 Cocoa_RestoreWindow(_THIS, SDL_Window * window) 1828 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1538 1829 { @autoreleasepool 1539 1830 { 1831 #else 1832 { 1833 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 1834 #endif 1540 1835 NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow; 1541 1836 1542 1837 if ([nswindow isMiniaturized]) { … … 1544 1839 } else if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) { 1545 1840 [nswindow zoom:nil]; 1546 1841 } 1842 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1547 1843 }} 1844 #else 1845 [pool release]; 1846 } 1847 #endif 1548 1848 1549 1849 void 1550 1850 Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered) 1851 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1551 1852 { @autoreleasepool 1552 1853 { 1854 #else 1855 { 1856 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 1857 #endif 1553 1858 if (SetWindowStyle(window, GetWindowStyle(window))) { 1554 1859 if (bordered) { 1555 1860 Cocoa_SetWindowTitle(_this, window); /* this got blanked out. */ 1556 1861 } 1557 1862 } 1863 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1558 1864 }} 1865 #else 1866 [pool release]; 1867 } 1868 #endif 1869 1559 1870 1560 1871 void 1561 1872 Cocoa_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable) 1873 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1562 1874 { @autoreleasepool 1563 1875 { 1876 #else 1877 { 1878 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 1879 #endif 1564 1880 /* Don't set this if we're in a space! 1565 1881 * The window will get permanently stuck if resizable is false. 1566 1882 * -flibit … … 1570 1886 if (![listener isInFullscreenSpace]) { 1571 1887 SetWindowStyle(window, GetWindowStyle(window)); 1572 1888 } 1889 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1573 1890 }} 1891 #else 1892 [pool release]; 1893 } 1894 #endif 1895 1574 1896 1575 1897 void 1576 1898 Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen) 1899 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1577 1900 { @autoreleasepool 1578 1901 { 1902 #else 1903 { 1904 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 1905 #endif 1579 1906 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; 1580 1907 NSWindow *nswindow = data->nswindow; 1581 1908 NSRect rect; … … 1587 1914 1588 1915 if (fullscreen) { 1589 1916 SDL_Rect bounds; 1917 NSRect screenRect; 1590 1918 1591 1919 Cocoa_GetDisplayBounds(_this, display, &bounds); 1592 1920 rect.origin.x = bounds.x; … … 1596 1924 ConvertNSRect([nswindow screen], fullscreen, &rect); 1597 1925 1598 1926 /* Hack to fix origin on Mac OS X 10.4 */ 1599 NSRectscreenRect = [[nswindow screen] frame];1927 screenRect = [[nswindow screen] frame]; 1600 1928 if (screenRect.size.height >= 1.0f) { 1601 1929 rect.origin.y += (screenRect.size.height - rect.size.height); 1602 1930 } 1603 1931 1932 if ([nswindow respondsToSelector:@selector(setStyleMask:)]) { 1604 1933 [nswindow setStyleMask:NSWindowStyleMaskBorderless]; 1934 } 1605 1935 } else { 1606 1936 rect.origin.x = window->windowed.x; 1607 1937 rect.origin.y = window->windowed.y; … … 1609 1939 rect.size.height = window->windowed.h; 1610 1940 ConvertNSRect([nswindow screen], fullscreen, &rect); 1611 1941 1942 if ([nswindow respondsToSelector:@selector(setStyleMask:)]) { 1612 1943 [nswindow setStyleMask:GetWindowStyle(window)]; 1944 } 1613 1945 1614 1946 /* Hack to restore window decorations on Mac OS X 10.10 */ 1615 1947 NSRect frameRect = [nswindow frame]; … … 1646 1978 } 1647 1979 1648 1980 ScheduleContextUpdates(data); 1981 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1649 1982 }} 1983 #else 1984 [pool release]; 1985 } 1986 #endif 1650 1987 1651 1988 int 1652 1989 Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) … … 1736 2073 1737 2074 void 1738 2075 Cocoa_DestroyWindow(_THIS, SDL_Window * window) 2076 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1739 2077 { @autoreleasepool 1740 2078 { 2079 #else 2080 { 2081 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 2082 #endif 1741 2083 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; 1742 2084 1743 2085 if (data) { 2086 #if !defined(MAC_OS_X_VERSION_10_5) 2087 int i; 2088 NSArray *contexts; 2089 #endif 1744 2090 if ([data->listener isInFullscreenSpace]) { 1745 2091 [NSMenu setMenuBarVisible:YES]; 1746 2092 } … … 1750 2096 [data->nswindow close]; 1751 2097 } 1752 2098 2099 #if defined(MAC_OS_X_VERSION_10_5) 1753 2100 NSArray *contexts = [[data->nscontexts copy] autorelease]; 1754 2101 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 1755 2108 /* Calling setWindow:NULL causes the context to remove itself from the context list. */ 1756 2109 [context setWindow:NULL]; 1757 2110 } … … 1760 2113 SDL_free(data); 1761 2114 } 1762 2115 window->driverdata = NULL; 2116 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1763 2117 }} 2118 #else 2119 [pool release]; 2120 } 2121 #endif 1764 2122 1765 2123 SDL_bool 1766 2124 Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) … … 1792 2150 1793 2151 SDL_bool 1794 2152 Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state) 2153 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1795 2154 { @autoreleasepool 1796 2155 { 2156 #else 2157 { 2158 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 2159 #endif 1797 2160 SDL_bool succeeded = SDL_FALSE; 1798 2161 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; 1799 2162 … … 1824 2187 succeeded = SDL_TRUE; 1825 2188 } 1826 2189 2190 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 2191 [pool release]; 2192 #endif 1827 2193 return succeeded; 2194 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 1828 2195 }} 2196 #else 2197 } 2198 #endif 1829 2199 1830 2200 int 1831 2201 Cocoa_SetWindowHitTest(SDL_Window * window, SDL_bool enabled)