Removed Mac OS 10.5 support (bug #3137). Also fixed a warning about deprecated Carbon code when using SDL_audio (bug #3127, thanks Dominik!)
1.1 --- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj Fri May 20 22:18:15 2016 +0200
1.2 +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj Sat May 21 00:20:52 2016 -0300
1.3 @@ -2774,7 +2774,7 @@
1.4 GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
1.5 GCC_OPTIMIZATION_LEVEL = 3;
1.6 GCC_SYMBOLS_PRIVATE_EXTERN = YES;
1.7 - MACOSX_DEPLOYMENT_TARGET = 10.5;
1.8 + MACOSX_DEPLOYMENT_TARGET = 10.6;
1.9 SDKROOT = macosx;
1.10 STRIP_STYLE = "non-global";
1.11 };
1.12 @@ -2832,7 +2832,7 @@
1.13 GCC_ENABLE_SSE3_EXTENSIONS = YES;
1.14 GCC_OPTIMIZATION_LEVEL = 0;
1.15 GCC_SYMBOLS_PRIVATE_EXTERN = YES;
1.16 - MACOSX_DEPLOYMENT_TARGET = 10.5;
1.17 + MACOSX_DEPLOYMENT_TARGET = 10.6;
1.18 ONLY_ACTIVE_ARCH = YES;
1.19 SDKROOT = macosx;
1.20 STRIP_INSTALLED_PRODUCT = NO;
2.1 --- a/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj Fri May 20 22:18:15 2016 +0200
2.2 +++ b/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj Sat May 21 00:20:52 2016 -0300
2.3 @@ -3934,7 +3934,7 @@
2.4 );
2.5 GCC_OPTIMIZATION_LEVEL = 0;
2.6 HEADER_SEARCH_PATHS = ../../include;
2.7 - MACOSX_DEPLOYMENT_TARGET = 10.5;
2.8 + MACOSX_DEPLOYMENT_TARGET = 10.6;
2.9 };
2.10 name = Debug;
2.11 };
2.12 @@ -4060,7 +4060,7 @@
2.13 );
2.14 GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
2.15 HEADER_SEARCH_PATHS = ../../include;
2.16 - MACOSX_DEPLOYMENT_TARGET = 10.5;
2.17 + MACOSX_DEPLOYMENT_TARGET = 10.6;
2.18 };
2.19 name = Release;
2.20 };
3.1 --- a/build-scripts/g++-fat.sh Fri May 20 22:18:15 2016 +0200
3.2 +++ b/build-scripts/g++-fat.sh Sat May 21 00:20:52 2016 -0300
3.3 @@ -6,11 +6,11 @@
3.4
3.5 DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer"
3.6
3.7 -# Intel 32-bit compiler flags (10.5 runtime compatibility)
3.8 -GCC_COMPILE_X86="g++ -arch i386 -mmacosx-version-min=10.5 \
3.9 +# Intel 32-bit compiler flags (10.6 runtime compatibility)
3.10 +GCC_COMPILE_X86="g++ -arch i386 -mmacosx-version-min=10.6 \
3.11 -I/usr/local/include"
3.12
3.13 -GCC_LINK_X86="-mmacosx-version-min=10.5"
3.14 +GCC_LINK_X86="-mmacosx-version-min=10.6"
3.15
3.16 # Intel 64-bit compiler flags (10.6 runtime compatibility)
3.17 GCC_COMPILE_X64="g++ -arch x86_64 -mmacosx-version-min=10.6 \
4.1 --- a/build-scripts/gcc-fat.sh Fri May 20 22:18:15 2016 +0200
4.2 +++ b/build-scripts/gcc-fat.sh Sat May 21 00:20:52 2016 -0300
4.3 @@ -6,11 +6,11 @@
4.4
4.5 DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer"
4.6
4.7 -# Intel 32-bit compiler flags (10.5 runtime compatibility)
4.8 -GCC_COMPILE_X86="gcc -arch i386 -mmacosx-version-min=10.5 \
4.9 +# Intel 32-bit compiler flags (10.6 runtime compatibility)
4.10 +GCC_COMPILE_X86="gcc -arch i386 -mmacosx-version-min=10.6 \
4.11 -I/usr/local/include"
4.12
4.13 -GCC_LINK_X86="-mmacosx-version-min=10.5"
4.14 +GCC_LINK_X86="-mmacosx-version-min=10.6"
4.15
4.16 # Intel 64-bit compiler flags (10.6 runtime compatibility)
4.17 GCC_COMPILE_X64="gcc -arch x86_64 -mmacosx-version-min=10.6 \
5.1 --- a/include/SDL_platform.h Fri May 20 22:18:15 2016 +0200
5.2 +++ b/include/SDL_platform.h Sat May 21 00:20:52 2016 -0300
5.3 @@ -79,9 +79,9 @@
5.4 /* if not compiling for iPhone */
5.5 #undef __MACOSX__
5.6 #define __MACOSX__ 1
5.7 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050
5.8 -# error SDL for Mac OS X only supports deploying on 10.5 and above.
5.9 -#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1050 */
5.10 +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
5.11 +# error SDL for Mac OS X only supports deploying on 10.6 and above.
5.12 +#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1060 */
5.13 #endif /* TARGET_OS_IPHONE */
5.14 #endif /* defined(__APPLE__) */
5.15
6.1 --- a/src/audio/coreaudio/SDL_coreaudio.c Fri May 20 22:18:15 2016 +0200
6.2 +++ b/src/audio/coreaudio/SDL_coreaudio.c Sat May 21 00:20:52 2016 -0300
6.3 @@ -406,13 +406,7 @@
6.4 AudioUnitSetProperty(this->hidden->audioUnit,
6.5 kAudioUnitProperty_SetRenderCallback,
6.6 scope, bus, &callback, sizeof(callback));
6.7 -
6.8 - #if MACOSX_COREAUDIO
6.9 - CloseComponent(this->hidden->audioUnit);
6.10 - #else
6.11 AudioComponentInstanceDispose(this->hidden->audioUnit);
6.12 - #endif
6.13 -
6.14 this->hidden->audioUnitOpened = 0;
6.15 }
6.16 SDL_free(this->hidden->buffer);
6.17 @@ -482,13 +476,8 @@
6.18 {
6.19 OSStatus result = noErr;
6.20 AURenderCallbackStruct callback;
6.21 -#if MACOSX_COREAUDIO
6.22 - ComponentDescription desc;
6.23 - Component comp = NULL;
6.24 -#else
6.25 AudioComponentDescription desc;
6.26 AudioComponent comp = NULL;
6.27 -#endif
6.28 const AudioUnitElement output_bus = 0;
6.29 const AudioUnitElement input_bus = 1;
6.30 const AudioUnitElement bus = ((iscapture) ? input_bus : output_bus);
6.31 @@ -507,11 +496,10 @@
6.32
6.33 #if MACOSX_COREAUDIO
6.34 desc.componentSubType = kAudioUnitSubType_DefaultOutput;
6.35 - comp = FindNextComponent(NULL, &desc);
6.36 #else
6.37 desc.componentSubType = kAudioUnitSubType_RemoteIO;
6.38 +#endif
6.39 comp = AudioComponentFindNext(NULL, &desc);
6.40 -#endif
6.41
6.42 if (comp == NULL) {
6.43 SDL_SetError("Couldn't find requested CoreAudio component");
6.44 @@ -519,17 +507,8 @@
6.45 }
6.46
6.47 /* Open & initialize the audio unit */
6.48 -#if MACOSX_COREAUDIO
6.49 - result = OpenAComponent(comp, &this->hidden->audioUnit);
6.50 - CHECK_RESULT("OpenAComponent");
6.51 -#else
6.52 - /*
6.53 - AudioComponentInstanceNew only available on iPhone OS 2.0 and Mac OS X 10.6
6.54 - We can't use OpenAComponent on iPhone because it is not present
6.55 - */
6.56 result = AudioComponentInstanceNew(comp, &this->hidden->audioUnit);
6.57 CHECK_RESULT("AudioComponentInstanceNew");
6.58 -#endif
6.59
6.60 this->hidden->audioUnitOpened = 1;
6.61
7.1 --- a/src/joystick/darwin/SDL_sysjoystick.c Fri May 20 22:18:15 2016 +0200
7.2 +++ b/src/joystick/darwin/SDL_sysjoystick.c Sat May 21 00:20:52 2016 -0300
7.3 @@ -422,6 +422,7 @@
7.4 {
7.5 recDevice *device;
7.6 int device_index = 0;
7.7 + io_service_t ioservice;
7.8
7.9 if (res != kIOReturnSuccess) {
7.10 return;
7.11 @@ -451,20 +452,11 @@
7.12 device->instance_id = ++s_joystick_instance_id;
7.13
7.14 /* We have to do some storage of the io_service_t for SDL_HapticOpenFromJoystick */
7.15 -
7.16 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
7.17 - if (IOHIDDeviceGetService != NULL) { /* weak reference: available in 10.6 and later. */
7.18 -#endif
7.19 -
7.20 - const io_service_t ioservice = IOHIDDeviceGetService(ioHIDDeviceObject);
7.21 + ioservice = IOHIDDeviceGetService(ioHIDDeviceObject);
7.22 #if SDL_HAPTIC_IOKIT
7.23 - if ((ioservice) && (FFIsForceFeedback(ioservice) == FF_OK)) {
7.24 - device->ffservice = ioservice;
7.25 - MacHaptic_MaybeAddDevice(ioservice);
7.26 - }
7.27 -#endif
7.28 -
7.29 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
7.30 + if ((ioservice) && (FFIsForceFeedback(ioservice) == FF_OK)) {
7.31 + device->ffservice = ioservice;
7.32 + MacHaptic_MaybeAddDevice(ioservice);
7.33 }
7.34 #endif
7.35
8.1 --- a/src/video/cocoa/SDL_cocoaclipboard.m Fri May 20 22:18:15 2016 +0200
8.2 +++ b/src/video/cocoa/SDL_cocoaclipboard.m Sat May 21 00:20:52 2016 -0300
8.3 @@ -25,23 +25,13 @@
8.4 #include "SDL_cocoavideo.h"
8.5 #include "../../events/SDL_clipboardevents_c.h"
8.6
8.7 -static NSString *
8.8 -GetTextFormat(_THIS)
8.9 -{
8.10 - if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) {
8.11 - return NSPasteboardTypeString;
8.12 - } else {
8.13 - return NSStringPboardType;
8.14 - }
8.15 -}
8.16 -
8.17 int
8.18 Cocoa_SetClipboardText(_THIS, const char *text)
8.19 { @autoreleasepool
8.20 {
8.21 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
8.22 NSPasteboard *pasteboard;
8.23 - NSString *format = GetTextFormat(_this);
8.24 + NSString *format = NSPasteboardTypeString;
8.25
8.26 pasteboard = [NSPasteboard generalPasteboard];
8.27 data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
8.28 @@ -55,7 +45,7 @@
8.29 { @autoreleasepool
8.30 {
8.31 NSPasteboard *pasteboard;
8.32 - NSString *format = GetTextFormat(_this);
8.33 + NSString *format = NSPasteboardTypeString;
8.34 NSString *available;
8.35 char *text;
8.36
9.1 --- a/src/video/cocoa/SDL_cocoaevents.m Fri May 20 22:18:15 2016 +0200
9.2 +++ b/src/video/cocoa/SDL_cocoaevents.m Sat May 21 00:20:52 2016 -0300
9.3 @@ -114,28 +114,23 @@
9.4 */
9.5 for (NSWindow *window in [NSApp orderedWindows]) {
9.6 if (window != win && [window canBecomeKeyWindow]) {
9.7 - if ([window respondsToSelector:@selector(isOnActiveSpace)]) {
9.8 - if (![window isOnActiveSpace]) {
9.9 - continue;
9.10 - }
9.11 + if (![window isOnActiveSpace]) {
9.12 + continue;
9.13 }
9.14 [window makeKeyAndOrderFront:self];
9.15 return;
9.16 }
9.17 }
9.18
9.19 - /* If a window wasn't found above, iterate through all visible windows
9.20 - * (including the 'About' window, if it's shown) and make the first one key.
9.21 - * Note that +[NSWindow windowNumbersWithOptions:] was added in 10.6.
9.22 + /* If a window wasn't found above, iterate through all visible windows in
9.23 + * the active Space in z-order (including the 'About' window, if it's shown)
9.24 + * and make the first one key.
9.25 */
9.26 - if ([NSWindow respondsToSelector:@selector(windowNumbersWithOptions:)]) {
9.27 - /* Get all visible windows in the active Space, in z-order. */
9.28 - for (NSNumber *num in [NSWindow windowNumbersWithOptions:0]) {
9.29 - NSWindow *window = [NSApp windowWithWindowNumber:[num integerValue]];
9.30 - if (window && window != win && [window canBecomeKeyWindow]) {
9.31 - [window makeKeyAndOrderFront:self];
9.32 - return;
9.33 - }
9.34 + for (NSNumber *num in [NSWindow windowNumbersWithOptions:0]) {
9.35 + NSWindow *window = [NSApp windowWithWindowNumber:[num integerValue]];
9.36 + if (window && window != win && [window canBecomeKeyWindow]) {
9.37 + [window makeKeyAndOrderFront:self];
9.38 + return;
9.39 }
9.40 }
9.41 }
9.42 @@ -291,7 +286,7 @@
9.43
9.44
9.45 /* Add the fullscreen view toggle menu option, if supported */
9.46 - if ([NSApp respondsToSelector:@selector(setPresentationOptions:)]) {
9.47 + if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
9.48 /* Create the view menu */
9.49 viewMenu = [[NSMenu alloc] initWithTitle:@"View"];
9.50
9.51 @@ -321,16 +316,7 @@
9.52
9.53 const char *hint = SDL_GetHint(SDL_HINT_MAC_BACKGROUND_APP);
9.54 if (!hint || *hint == '0') {
9.55 -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
9.56 - if ([NSApp respondsToSelector:@selector(setActivationPolicy:)]) {
9.57 -#endif
9.58 - [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
9.59 -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
9.60 - } else {
9.61 - ProcessSerialNumber psn = {0, kCurrentProcess};
9.62 - TransformProcessType(&psn, kProcessTransformToForegroundApplication);
9.63 - }
9.64 -#endif
9.65 + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
9.66 [NSApp activateIgnoringOtherApps:YES];
9.67 }
9.68
10.1 --- a/src/video/cocoa/SDL_cocoakeyboard.m Fri May 20 22:18:15 2016 +0200
10.2 +++ b/src/video/cocoa/SDL_cocoakeyboard.m Sat May 21 00:20:52 2016 -0300
10.3 @@ -69,14 +69,6 @@
10.4 SDL_SendKeyboardText(str);
10.5 }
10.6
10.7 -- (void)insertText:(id)insertString
10.8 -{
10.9 - /* This method is part of NSTextInput and not NSTextInputClient, but
10.10 - * apparently it still might be called in OS X 10.5 and can cause beeps if
10.11 - * the implementation is missing: http://crbug.com/47890 */
10.12 - [self insertText:insertString replacementRange:NSMakeRange(0, 0)];
10.13 -}
10.14 -
10.15 - (void)doCommandBySelector:(SEL)myselector
10.16 {
10.17 /* No need to do anything since we are not using Cocoa
10.18 @@ -498,11 +490,8 @@
10.19 SDL_SetScancodeName(SDL_SCANCODE_RALT, "Right Option");
10.20 SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Command");
10.21
10.22 - /* On pre-10.6, you might have the initial capslock key state wrong. */
10.23 - if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_6) {
10.24 - data->modifierFlags = [NSEvent modifierFlags];
10.25 - SDL_ToggleModState(KMOD_CAPS, (data->modifierFlags & NSAlphaShiftKeyMask) != 0);
10.26 - }
10.27 + data->modifierFlags = [NSEvent modifierFlags];
10.28 + SDL_ToggleModState(KMOD_CAPS, (data->modifierFlags & NSAlphaShiftKeyMask) != 0);
10.29 }
10.30
10.31 void
11.1 --- a/src/video/cocoa/SDL_cocoamodes.h Fri May 20 22:18:15 2016 +0200
11.2 +++ b/src/video/cocoa/SDL_cocoamodes.h Sat May 21 00:20:52 2016 -0300
11.3 @@ -30,7 +30,7 @@
11.4
11.5 typedef struct
11.6 {
11.7 - const void *moderef;
11.8 + CGDisplayModeRef moderef;
11.9 } SDL_DisplayModeData;
11.10
11.11 extern void Cocoa_InitModes(_THIS);
12.1 --- a/src/video/cocoa/SDL_cocoamodes.m Fri May 20 22:18:15 2016 +0200
12.2 +++ b/src/video/cocoa/SDL_cocoamodes.m Sat May 21 00:20:52 2016 -0300
12.3 @@ -56,25 +56,6 @@
12.4 #endif
12.5 }
12.6
12.7 -
12.8 -/* !!! FIXME: clean out the pre-10.6 code when it makes sense to do so. */
12.9 -#define FORCE_OLD_API 0
12.10 -
12.11 -#if FORCE_OLD_API
12.12 -#undef MAC_OS_X_VERSION_MIN_REQUIRED
12.13 -#define MAC_OS_X_VERSION_MIN_REQUIRED 1050
12.14 -#endif
12.15 -
12.16 -static BOOL
12.17 -IS_SNOW_LEOPARD_OR_LATER()
12.18 -{
12.19 -#if FORCE_OLD_API
12.20 - return NO;
12.21 -#else
12.22 - return floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5;
12.23 -#endif
12.24 -}
12.25 -
12.26 static int
12.27 CG_SetError(const char *prefix, CGDisplayErr result)
12.28 {
12.29 @@ -119,59 +100,40 @@
12.30 }
12.31
12.32 static SDL_bool
12.33 -GetDisplayMode(_THIS, const void *moderef, CVDisplayLinkRef link, SDL_DisplayMode *mode)
12.34 +GetDisplayMode(_THIS, CGDisplayModeRef vidmode, CVDisplayLinkRef link, SDL_DisplayMode *mode)
12.35 {
12.36 SDL_DisplayModeData *data;
12.37 long width = 0;
12.38 long height = 0;
12.39 long bpp = 0;
12.40 long refreshRate = 0;
12.41 + CFStringRef fmt;
12.42
12.43 data = (SDL_DisplayModeData *) SDL_malloc(sizeof(*data));
12.44 if (!data) {
12.45 return SDL_FALSE;
12.46 }
12.47 - data->moderef = moderef;
12.48 + data->moderef = vidmode;
12.49
12.50 - if (IS_SNOW_LEOPARD_OR_LATER()) {
12.51 - CGDisplayModeRef vidmode = (CGDisplayModeRef) moderef;
12.52 - CFStringRef fmt = CGDisplayModeCopyPixelEncoding(vidmode);
12.53 - width = (long) CGDisplayModeGetWidth(vidmode);
12.54 - height = (long) CGDisplayModeGetHeight(vidmode);
12.55 - refreshRate = (long) (CGDisplayModeGetRefreshRate(vidmode) + 0.5);
12.56 + fmt = CGDisplayModeCopyPixelEncoding(vidmode);
12.57 + width = (long) CGDisplayModeGetWidth(vidmode);
12.58 + height = (long) CGDisplayModeGetHeight(vidmode);
12.59 + refreshRate = (long) (CGDisplayModeGetRefreshRate(vidmode) + 0.5);
12.60
12.61 - if (CFStringCompare(fmt, CFSTR(IO32BitDirectPixels),
12.62 - kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
12.63 - bpp = 32;
12.64 - } else if (CFStringCompare(fmt, CFSTR(IO16BitDirectPixels),
12.65 - kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
12.66 - bpp = 16;
12.67 - } else if (CFStringCompare(fmt, CFSTR(kIO30BitDirectPixels),
12.68 - kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
12.69 - bpp = 30;
12.70 - } else {
12.71 - bpp = 0; /* ignore 8-bit and such for now. */
12.72 - }
12.73 -
12.74 - CFRelease(fmt);
12.75 + if (CFStringCompare(fmt, CFSTR(IO32BitDirectPixels),
12.76 + kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
12.77 + bpp = 32;
12.78 + } else if (CFStringCompare(fmt, CFSTR(IO16BitDirectPixels),
12.79 + kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
12.80 + bpp = 16;
12.81 + } else if (CFStringCompare(fmt, CFSTR(kIO30BitDirectPixels),
12.82 + kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
12.83 + bpp = 30;
12.84 + } else {
12.85 + bpp = 0; /* ignore 8-bit and such for now. */
12.86 }
12.87
12.88 - #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
12.89 - if (!IS_SNOW_LEOPARD_OR_LATER()) {
12.90 - CFNumberRef number;
12.91 - double refresh;
12.92 - CFDictionaryRef vidmode = (CFDictionaryRef) moderef;
12.93 - number = CFDictionaryGetValue(vidmode, kCGDisplayWidth);
12.94 - CFNumberGetValue(number, kCFNumberLongType, &width);
12.95 - number = CFDictionaryGetValue(vidmode, kCGDisplayHeight);
12.96 - CFNumberGetValue(number, kCFNumberLongType, &height);
12.97 - number = CFDictionaryGetValue(vidmode, kCGDisplayBitsPerPixel);
12.98 - CFNumberGetValue(number, kCFNumberLongType, &bpp);
12.99 - number = CFDictionaryGetValue(vidmode, kCGDisplayRefreshRate);
12.100 - CFNumberGetValue(number, kCFNumberDoubleType, &refresh);
12.101 - refreshRate = (long) (refresh + 0.5);
12.102 - }
12.103 - #endif
12.104 + CFRelease(fmt);
12.105
12.106 /* CGDisplayModeGetRefreshRate returns 0 for many non-CRT displays. */
12.107 if (refreshRate == 0 && link != NULL) {
12.108 @@ -204,22 +166,6 @@
12.109 return SDL_TRUE;
12.110 }
12.111
12.112 -static void
12.113 -Cocoa_ReleaseDisplayMode(_THIS, const void *moderef)
12.114 -{
12.115 - if (IS_SNOW_LEOPARD_OR_LATER()) {
12.116 - CGDisplayModeRelease((CGDisplayModeRef) moderef); /* NULL is ok */
12.117 - }
12.118 -}
12.119 -
12.120 -static void
12.121 -Cocoa_ReleaseDisplayModeList(_THIS, CFArrayRef modelist)
12.122 -{
12.123 - if (IS_SNOW_LEOPARD_OR_LATER()) {
12.124 - CFRelease(modelist); /* NULL is ok */
12.125 - }
12.126 -}
12.127 -
12.128 static const char *
12.129 Cocoa_GetDisplayName(CGDirectDisplayID displayID)
12.130 {
12.131 @@ -262,7 +208,7 @@
12.132 SDL_VideoDisplay display;
12.133 SDL_DisplayData *displaydata;
12.134 SDL_DisplayMode mode;
12.135 - const void *moderef = NULL;
12.136 + CGDisplayModeRef moderef = NULL;
12.137 CVDisplayLinkRef link = NULL;
12.138
12.139 if (pass == 0) {
12.140 @@ -279,15 +225,7 @@
12.141 continue;
12.142 }
12.143
12.144 - if (IS_SNOW_LEOPARD_OR_LATER()) {
12.145 - moderef = CGDisplayCopyDisplayMode(displays[i]);
12.146 - }
12.147 -
12.148 - #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
12.149 - if (!IS_SNOW_LEOPARD_OR_LATER()) {
12.150 - moderef = CGDisplayCurrentMode(displays[i]);
12.151 - }
12.152 - #endif
12.153 + moderef = CGDisplayCopyDisplayMode(displays[i]);
12.154
12.155 if (!moderef) {
12.156 continue;
12.157 @@ -295,7 +233,7 @@
12.158
12.159 displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
12.160 if (!displaydata) {
12.161 - Cocoa_ReleaseDisplayMode(_this, moderef);
12.162 + CGDisplayModeRelease(moderef);
12.163 continue;
12.164 }
12.165 displaydata->display = displays[i];
12.166 @@ -307,7 +245,7 @@
12.167 display.name = (char *)Cocoa_GetDisplayName(displays[i]);
12.168 if (!GetDisplayMode(_this, moderef, link, &mode)) {
12.169 CVDisplayLinkRelease(link);
12.170 - Cocoa_ReleaseDisplayMode(_this, moderef);
12.171 + CGDisplayModeRelease(moderef);
12.172 SDL_free(display.name);
12.173 SDL_free(displaydata);
12.174 continue;
12.175 @@ -396,17 +334,7 @@
12.176 Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
12.177 {
12.178 SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
12.179 - CFArrayRef modes = NULL;
12.180 -
12.181 - if (IS_SNOW_LEOPARD_OR_LATER()) {
12.182 - modes = CGDisplayCopyAllDisplayModes(data->display, NULL);
12.183 - }
12.184 -
12.185 - #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
12.186 - if (!IS_SNOW_LEOPARD_OR_LATER()) {
12.187 - modes = CGDisplayAvailableModes(data->display);
12.188 - }
12.189 - #endif
12.190 + CFArrayRef modes = CGDisplayCopyAllDisplayModes(data->display, NULL);
12.191
12.192 if (modes) {
12.193 CVDisplayLinkRef link = NULL;
12.194 @@ -416,37 +344,19 @@
12.195 CVDisplayLinkCreateWithCGDisplay(data->display, &link);
12.196
12.197 for (i = 0; i < count; i++) {
12.198 - const void *moderef = CFArrayGetValueAtIndex(modes, i);
12.199 + CGDisplayModeRef moderef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
12.200 SDL_DisplayMode mode;
12.201 if (GetDisplayMode(_this, moderef, link, &mode)) {
12.202 - if (IS_SNOW_LEOPARD_OR_LATER()) {
12.203 - CGDisplayModeRetain((CGDisplayModeRef) moderef);
12.204 - }
12.205 + CGDisplayModeRetain(moderef);
12.206 SDL_AddDisplayMode(display, &mode);
12.207 }
12.208 }
12.209
12.210 CVDisplayLinkRelease(link);
12.211 - Cocoa_ReleaseDisplayModeList(_this, modes);
12.212 + CFRelease(modes);
12.213 }
12.214 }
12.215
12.216 -static CGError
12.217 -Cocoa_SwitchMode(_THIS, CGDirectDisplayID display, const void *mode)
12.218 -{
12.219 - if (IS_SNOW_LEOPARD_OR_LATER()) {
12.220 - return CGDisplaySetDisplayMode(display, (CGDisplayModeRef) mode, NULL);
12.221 - }
12.222 -
12.223 - #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
12.224 - if (!IS_SNOW_LEOPARD_OR_LATER()) {
12.225 - return CGDisplaySwitchToMode(display, (CFDictionaryRef) mode);
12.226 - }
12.227 - #endif
12.228 -
12.229 - return kCGErrorFailure;
12.230 -}
12.231 -
12.232 int
12.233 Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
12.234 {
12.235 @@ -462,7 +372,7 @@
12.236
12.237 if (data == display->desktop_mode.driverdata) {
12.238 /* Restoring desktop mode */
12.239 - Cocoa_SwitchMode(_this, displaydata->display, data->moderef);
12.240 + CGDisplaySetDisplayMode(displaydata->display, data->moderef, NULL);
12.241
12.242 if (CGDisplayIsMain(displaydata->display)) {
12.243 CGReleaseAllDisplays();
12.244 @@ -487,7 +397,7 @@
12.245 }
12.246
12.247 /* Do the physical switch */
12.248 - result = Cocoa_SwitchMode(_this, displaydata->display, data->moderef);
12.249 + result = CGDisplaySetDisplayMode(displaydata->display, data->moderef, NULL);
12.250 if (result != kCGErrorSuccess) {
12.251 CG_SetError("CGDisplaySwitchToMode()", result);
12.252 goto ERR_NO_SWITCH;
12.253 @@ -532,11 +442,11 @@
12.254 }
12.255
12.256 mode = (SDL_DisplayModeData *) display->desktop_mode.driverdata;
12.257 - Cocoa_ReleaseDisplayMode(_this, mode->moderef);
12.258 + CGDisplayModeRelease(mode->moderef);
12.259
12.260 for (j = 0; j < display->num_display_modes; j++) {
12.261 mode = (SDL_DisplayModeData*) display->display_modes[j].driverdata;
12.262 - Cocoa_ReleaseDisplayMode(_this, mode->moderef);
12.263 + CGDisplayModeRelease(mode->moderef);
12.264 }
12.265
12.266 }
13.1 --- a/src/video/cocoa/SDL_cocoashape.m Fri May 20 22:18:15 2016 +0200
13.2 +++ b/src/video/cocoa/SDL_cocoashape.m Sat May 21 00:20:52 2016 -0300
13.3 @@ -35,9 +35,7 @@
13.4 SDL_WindowData* windata = (SDL_WindowData*)window->driverdata;
13.5 [windata->nswindow setOpaque:NO];
13.6
13.7 - if ([windata->nswindow respondsToSelector:@selector(setStyleMask:)]) {
13.8 - [windata->nswindow setStyleMask:NSBorderlessWindowMask];
13.9 - }
13.10 + [windata->nswindow setStyleMask:NSBorderlessWindowMask];
13.11
13.12 SDL_WindowShaper* result = result = malloc(sizeof(SDL_WindowShaper));
13.13 result->window = window;
14.1 --- a/src/video/cocoa/SDL_cocoawindow.m Fri May 20 22:18:15 2016 +0200
14.2 +++ b/src/video/cocoa/SDL_cocoawindow.m Sat May 21 00:20:52 2016 -0300
14.3 @@ -138,10 +138,7 @@
14.4 NSURL *fileURL = [[NSURL fileURLWithPath:path] autorelease];
14.5 NSNumber *isAlias = nil;
14.6
14.7 - /* Functionality for resolving URL aliases was added with OS X 10.6. */
14.8 - if ([fileURL respondsToSelector:@selector(getResourceValue:forKey:error:)]) {
14.9 - [fileURL getResourceValue:&isAlias forKey:NSURLIsAliasFileKey error:nil];
14.10 - }
14.11 + [fileURL getResourceValue:&isAlias forKey:NSURLIsAliasFileKey error:nil];
14.12
14.13 /* If the URL is an alias, resolve it. */
14.14 if ([isAlias boolValue]) {
14.15 @@ -218,10 +215,10 @@
14.16 return hint != NULL && *hint != '0';
14.17 }
14.18
14.19 -static unsigned int
14.20 +static NSUInteger
14.21 GetWindowStyle(SDL_Window * window)
14.22 {
14.23 - unsigned int style;
14.24 + NSUInteger style = 0;
14.25
14.26 if (window->flags & SDL_WINDOW_FULLSCREEN) {
14.27 style = NSBorderlessWindowMask;
14.28 @@ -239,21 +236,17 @@
14.29 }
14.30
14.31 static SDL_bool
14.32 -SetWindowStyle(SDL_Window * window, unsigned int style)
14.33 +SetWindowStyle(SDL_Window * window, NSUInteger style)
14.34 {
14.35 SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
14.36 NSWindow *nswindow = data->nswindow;
14.37
14.38 - if (![nswindow respondsToSelector: @selector(setStyleMask:)]) {
14.39 - return SDL_FALSE;
14.40 - }
14.41 -
14.42 /* The view responder chain gets messed with during setStyleMask */
14.43 if ([[nswindow contentView] nextResponder] == data->listener) {
14.44 [[nswindow contentView] setNextResponder:nil];
14.45 }
14.46
14.47 - [nswindow performSelector: @selector(setStyleMask:) withObject: (id)(uintptr_t)style];
14.48 + [nswindow setStyleMask:style];
14.49
14.50 /* The view responder chain gets messed with during setStyleMask */
14.51 if ([[nswindow contentView] nextResponder] != data->listener) {
14.52 @@ -317,9 +310,7 @@
14.53
14.54 [view setNextResponder:self];
14.55
14.56 - if ([view respondsToSelector:@selector(setAcceptsTouchEvents:)]) {
14.57 - [view setAcceptsTouchEvents:YES];
14.58 - }
14.59 + [view setAcceptsTouchEvents:YES];
14.60 }
14.61
14.62 - (void)observeValueForKeyPath:(NSString *)keyPath
14.63 @@ -604,12 +595,9 @@
14.64 [NSMenu setMenuBarVisible:NO];
14.65 }
14.66
14.67 - /* On pre-10.6, you might have the capslock key state wrong now because we can't check here. */
14.68 - if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_6) {
14.69 - const unsigned int newflags = [NSEvent modifierFlags] & NSAlphaShiftKeyMask;
14.70 - _data->videodata->modifierFlags = (_data->videodata->modifierFlags & ~NSAlphaShiftKeyMask) | newflags;
14.71 - SDL_ToggleModState(KMOD_CAPS, newflags != 0);
14.72 - }
14.73 + const unsigned int newflags = [NSEvent modifierFlags] & NSAlphaShiftKeyMask;
14.74 + _data->videodata->modifierFlags = (_data->videodata->modifierFlags & ~NSAlphaShiftKeyMask) | newflags;
14.75 + SDL_ToggleModState(KMOD_CAPS, newflags != 0);
14.76 }
14.77
14.78 - (void)windowDidResignKey:(NSNotification *)aNotification
14.79 @@ -1483,27 +1471,6 @@
14.80 }
14.81 }}
14.82
14.83 -static NSWindow *
14.84 -Cocoa_RebuildWindow(SDL_WindowData * data, NSWindow * nswindow, unsigned style)
14.85 -{
14.86 - if (!data->created) {
14.87 - /* Don't mess with other people's windows... */
14.88 - return nswindow;
14.89 - }
14.90 -
14.91 - [data->listener close];
14.92 - data->nswindow = [[SDLWindow alloc] initWithContentRect:[[nswindow contentView] frame] styleMask:style backing:NSBackingStoreBuffered defer:NO screen:[nswindow screen]];
14.93 - [data->nswindow setContentView:[nswindow contentView]];
14.94 - [data->nswindow registerForDraggedTypes:[NSArray arrayWithObject:(NSString *)kUTTypeFileURL]];
14.95 - /* See comment in SetupWindowData. */
14.96 - [data->nswindow setOneShot:NO];
14.97 - [data->listener listen:data];
14.98 -
14.99 - [nswindow close];
14.100 -
14.101 - return data->nswindow;
14.102 -}
14.103 -
14.104 void
14.105 Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
14.106 { @autoreleasepool
14.107 @@ -1545,11 +1512,7 @@
14.108 rect.origin.y += (screenRect.size.height - rect.size.height);
14.109 }
14.110
14.111 - if ([nswindow respondsToSelector: @selector(setStyleMask:)]) {
14.112 - [nswindow performSelector: @selector(setStyleMask:) withObject: (id)NSBorderlessWindowMask];
14.113 - } else {
14.114 - nswindow = Cocoa_RebuildWindow(data, nswindow, NSBorderlessWindowMask);
14.115 - }
14.116 + [nswindow setStyleMask:NSBorderlessWindowMask];
14.117 } else {
14.118 rect.origin.x = window->windowed.x;
14.119 rect.origin.y = window->windowed.y;
14.120 @@ -1557,16 +1520,12 @@
14.121 rect.size.height = window->windowed.h;
14.122 ConvertNSRect([nswindow screen], fullscreen, &rect);
14.123
14.124 - if ([nswindow respondsToSelector: @selector(setStyleMask:)]) {
14.125 - [nswindow performSelector: @selector(setStyleMask:) withObject: (id)(uintptr_t)GetWindowStyle(window)];
14.126 + [nswindow setStyleMask:GetWindowStyle(window)];
14.127
14.128 - /* Hack to restore window decorations on Mac OS X 10.10 */
14.129 - NSRect frameRect = [nswindow frame];
14.130 - [nswindow setFrame:NSMakeRect(frameRect.origin.x, frameRect.origin.y, frameRect.size.width + 1, frameRect.size.height) display:NO];
14.131 - [nswindow setFrame:frameRect display:NO];
14.132 - } else {
14.133 - nswindow = Cocoa_RebuildWindow(data, nswindow, GetWindowStyle(window));
14.134 - }
14.135 + /* Hack to restore window decorations on Mac OS X 10.10 */
14.136 + NSRect frameRect = [nswindow frame];
14.137 + [nswindow setFrame:NSMakeRect(frameRect.origin.x, frameRect.origin.y, frameRect.size.width + 1, frameRect.size.height) display:NO];
14.138 + [nswindow setFrame:frameRect display:NO];
14.139 }
14.140
14.141 /* The view responder chain gets messed with during setStyleMask */