Skip to content

Commit

Permalink
Removed Mac OS 10.5 support (bug #3137). Also fixed a warning about d…
Browse files Browse the repository at this point in the history
…eprecated Carbon code when using SDL_audio (bug #3127, thanks Dominik!)
  • Loading branch information
slime73 committed May 21, 2016
1 parent 6255c85 commit 4a46873
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 282 deletions.
4 changes: 2 additions & 2 deletions Xcode/SDL/SDL.xcodeproj/project.pbxproj
Expand Up @@ -2774,7 +2774,7 @@
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_OPTIMIZATION_LEVEL = 3;
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
MACOSX_DEPLOYMENT_TARGET = 10.5;
MACOSX_DEPLOYMENT_TARGET = 10.6;
SDKROOT = macosx;
STRIP_STYLE = "non-global";
};
Expand Down Expand Up @@ -2832,7 +2832,7 @@
GCC_ENABLE_SSE3_EXTENSIONS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
MACOSX_DEPLOYMENT_TARGET = 10.5;
MACOSX_DEPLOYMENT_TARGET = 10.6;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
STRIP_INSTALLED_PRODUCT = NO;
Expand Down
4 changes: 2 additions & 2 deletions Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj
Expand Up @@ -3934,7 +3934,7 @@
);
GCC_OPTIMIZATION_LEVEL = 0;
HEADER_SEARCH_PATHS = ../../include;
MACOSX_DEPLOYMENT_TARGET = 10.5;
MACOSX_DEPLOYMENT_TARGET = 10.6;
};
name = Debug;
};
Expand Down Expand Up @@ -4060,7 +4060,7 @@
);
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
HEADER_SEARCH_PATHS = ../../include;
MACOSX_DEPLOYMENT_TARGET = 10.5;
MACOSX_DEPLOYMENT_TARGET = 10.6;
};
name = Release;
};
Expand Down
6 changes: 3 additions & 3 deletions build-scripts/g++-fat.sh
Expand Up @@ -6,11 +6,11 @@

DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer"

# Intel 32-bit compiler flags (10.5 runtime compatibility)
GCC_COMPILE_X86="g++ -arch i386 -mmacosx-version-min=10.5 \
# Intel 32-bit compiler flags (10.6 runtime compatibility)
GCC_COMPILE_X86="g++ -arch i386 -mmacosx-version-min=10.6 \
-I/usr/local/include"

GCC_LINK_X86="-mmacosx-version-min=10.5"
GCC_LINK_X86="-mmacosx-version-min=10.6"

# Intel 64-bit compiler flags (10.6 runtime compatibility)
GCC_COMPILE_X64="g++ -arch x86_64 -mmacosx-version-min=10.6 \
Expand Down
6 changes: 3 additions & 3 deletions build-scripts/gcc-fat.sh
Expand Up @@ -6,11 +6,11 @@

DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer"

# Intel 32-bit compiler flags (10.5 runtime compatibility)
GCC_COMPILE_X86="gcc -arch i386 -mmacosx-version-min=10.5 \
# Intel 32-bit compiler flags (10.6 runtime compatibility)
GCC_COMPILE_X86="gcc -arch i386 -mmacosx-version-min=10.6 \
-I/usr/local/include"

GCC_LINK_X86="-mmacosx-version-min=10.5"
GCC_LINK_X86="-mmacosx-version-min=10.6"

# Intel 64-bit compiler flags (10.6 runtime compatibility)
GCC_COMPILE_X64="gcc -arch x86_64 -mmacosx-version-min=10.6 \
Expand Down
6 changes: 3 additions & 3 deletions include/SDL_platform.h
Expand Up @@ -79,9 +79,9 @@
/* if not compiling for iPhone */
#undef __MACOSX__
#define __MACOSX__ 1
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050
# error SDL for Mac OS X only supports deploying on 10.5 and above.
#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1050 */
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
# error SDL for Mac OS X only supports deploying on 10.6 and above.
#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1060 */
#endif /* TARGET_OS_IPHONE */
#endif /* defined(__APPLE__) */

Expand Down
23 changes: 1 addition & 22 deletions src/audio/coreaudio/SDL_coreaudio.c
Expand Up @@ -406,13 +406,7 @@ COREAUDIO_CloseDevice(_THIS)
AudioUnitSetProperty(this->hidden->audioUnit,
kAudioUnitProperty_SetRenderCallback,
scope, bus, &callback, sizeof(callback));

#if MACOSX_COREAUDIO
CloseComponent(this->hidden->audioUnit);
#else
AudioComponentInstanceDispose(this->hidden->audioUnit);
#endif

this->hidden->audioUnitOpened = 0;
}
SDL_free(this->hidden->buffer);
Expand Down Expand Up @@ -482,13 +476,8 @@ prepare_audiounit(_THIS, void *handle, int iscapture,
{
OSStatus result = noErr;
AURenderCallbackStruct callback;
#if MACOSX_COREAUDIO
ComponentDescription desc;
Component comp = NULL;
#else
AudioComponentDescription desc;
AudioComponent comp = NULL;
#endif
const AudioUnitElement output_bus = 0;
const AudioUnitElement input_bus = 1;
const AudioUnitElement bus = ((iscapture) ? input_bus : output_bus);
Expand All @@ -507,29 +496,19 @@ prepare_audiounit(_THIS, void *handle, int iscapture,

#if MACOSX_COREAUDIO
desc.componentSubType = kAudioUnitSubType_DefaultOutput;
comp = FindNextComponent(NULL, &desc);
#else
desc.componentSubType = kAudioUnitSubType_RemoteIO;
comp = AudioComponentFindNext(NULL, &desc);
#endif
comp = AudioComponentFindNext(NULL, &desc);

if (comp == NULL) {
SDL_SetError("Couldn't find requested CoreAudio component");
return 0;
}

/* Open & initialize the audio unit */
#if MACOSX_COREAUDIO
result = OpenAComponent(comp, &this->hidden->audioUnit);
CHECK_RESULT("OpenAComponent");
#else
/*
AudioComponentInstanceNew only available on iPhone OS 2.0 and Mac OS X 10.6
We can't use OpenAComponent on iPhone because it is not present
*/
result = AudioComponentInstanceNew(comp, &this->hidden->audioUnit);
CHECK_RESULT("AudioComponentInstanceNew");
#endif

this->hidden->audioUnitOpened = 1;

Expand Down
18 changes: 5 additions & 13 deletions src/joystick/darwin/SDL_sysjoystick.c
Expand Up @@ -422,6 +422,7 @@ JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender, IOHIDDevic
{
recDevice *device;
int device_index = 0;
io_service_t ioservice;

if (res != kIOReturnSuccess) {
return;
Expand Down Expand Up @@ -451,20 +452,11 @@ JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender, IOHIDDevic
device->instance_id = ++s_joystick_instance_id;

/* We have to do some storage of the io_service_t for SDL_HapticOpenFromJoystick */

#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
if (IOHIDDeviceGetService != NULL) { /* weak reference: available in 10.6 and later. */
#endif

const io_service_t ioservice = IOHIDDeviceGetService(ioHIDDeviceObject);
ioservice = IOHIDDeviceGetService(ioHIDDeviceObject);
#if SDL_HAPTIC_IOKIT
if ((ioservice) && (FFIsForceFeedback(ioservice) == FF_OK)) {
device->ffservice = ioservice;
MacHaptic_MaybeAddDevice(ioservice);
}
#endif

#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
if ((ioservice) && (FFIsForceFeedback(ioservice) == FF_OK)) {
device->ffservice = ioservice;
MacHaptic_MaybeAddDevice(ioservice);
}
#endif

Expand Down
14 changes: 2 additions & 12 deletions src/video/cocoa/SDL_cocoaclipboard.m
Expand Up @@ -25,23 +25,13 @@
#include "SDL_cocoavideo.h"
#include "../../events/SDL_clipboardevents_c.h"

static NSString *
GetTextFormat(_THIS)
{
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) {
return NSPasteboardTypeString;
} else {
return NSStringPboardType;
}
}

int
Cocoa_SetClipboardText(_THIS, const char *text)
{ @autoreleasepool
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
NSPasteboard *pasteboard;
NSString *format = GetTextFormat(_this);
NSString *format = NSPasteboardTypeString;

pasteboard = [NSPasteboard generalPasteboard];
data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
Expand All @@ -55,7 +45,7 @@
{ @autoreleasepool
{
NSPasteboard *pasteboard;
NSString *format = GetTextFormat(_this);
NSString *format = NSPasteboardTypeString;
NSString *available;
char *text;

Expand Down
38 changes: 12 additions & 26 deletions src/video/cocoa/SDL_cocoaevents.m
Expand Up @@ -114,28 +114,23 @@ - (void)windowWillClose:(NSNotification *)notification;
*/
for (NSWindow *window in [NSApp orderedWindows]) {
if (window != win && [window canBecomeKeyWindow]) {
if ([window respondsToSelector:@selector(isOnActiveSpace)]) {
if (![window isOnActiveSpace]) {
continue;
}
if (![window isOnActiveSpace]) {
continue;
}
[window makeKeyAndOrderFront:self];
return;
}
}

/* If a window wasn't found above, iterate through all visible windows
* (including the 'About' window, if it's shown) and make the first one key.
* Note that +[NSWindow windowNumbersWithOptions:] was added in 10.6.
/* If a window wasn't found above, iterate through all visible windows in
* the active Space in z-order (including the 'About' window, if it's shown)
* and make the first one key.
*/
if ([NSWindow respondsToSelector:@selector(windowNumbersWithOptions:)]) {
/* Get all visible windows in the active Space, in z-order. */
for (NSNumber *num in [NSWindow windowNumbersWithOptions:0]) {
NSWindow *window = [NSApp windowWithWindowNumber:[num integerValue]];
if (window && window != win && [window canBecomeKeyWindow]) {
[window makeKeyAndOrderFront:self];
return;
}
for (NSNumber *num in [NSWindow windowNumbersWithOptions:0]) {
NSWindow *window = [NSApp windowWithWindowNumber:[num integerValue]];
if (window && window != win && [window canBecomeKeyWindow]) {
[window makeKeyAndOrderFront:self];
return;
}
}
}
Expand Down Expand Up @@ -291,7 +286,7 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenam


/* Add the fullscreen view toggle menu option, if supported */
if ([NSApp respondsToSelector:@selector(setPresentationOptions:)]) {
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
/* Create the view menu */
viewMenu = [[NSMenu alloc] initWithTitle:@"View"];

Expand Down Expand Up @@ -321,16 +316,7 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenam

const char *hint = SDL_GetHint(SDL_HINT_MAC_BACKGROUND_APP);
if (!hint || *hint == '0') {
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
if ([NSApp respondsToSelector:@selector(setActivationPolicy:)]) {
#endif
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
} else {
ProcessSerialNumber psn = {0, kCurrentProcess};
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
}
#endif
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
[NSApp activateIgnoringOtherApps:YES];
}

Expand Down
15 changes: 2 additions & 13 deletions src/video/cocoa/SDL_cocoakeyboard.m
Expand Up @@ -69,14 +69,6 @@ - (void)insertText:(id)aString replacementRange:(NSRange)replacementRange
SDL_SendKeyboardText(str);
}

- (void)insertText:(id)insertString
{
/* This method is part of NSTextInput and not NSTextInputClient, but
* apparently it still might be called in OS X 10.5 and can cause beeps if
* the implementation is missing: http://crbug.com/47890 */
[self insertText:insertString replacementRange:NSMakeRange(0, 0)];
}

- (void)doCommandBySelector:(SEL)myselector
{
/* No need to do anything since we are not using Cocoa
Expand Down Expand Up @@ -498,11 +490,8 @@ - (NSArray *)validAttributesForMarkedText
SDL_SetScancodeName(SDL_SCANCODE_RALT, "Right Option");
SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Command");

/* On pre-10.6, you might have the initial capslock key state wrong. */
if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_6) {
data->modifierFlags = [NSEvent modifierFlags];
SDL_ToggleModState(KMOD_CAPS, (data->modifierFlags & NSAlphaShiftKeyMask) != 0);
}
data->modifierFlags = [NSEvent modifierFlags];
SDL_ToggleModState(KMOD_CAPS, (data->modifierFlags & NSAlphaShiftKeyMask) != 0);
}

void
Expand Down
2 changes: 1 addition & 1 deletion src/video/cocoa/SDL_cocoamodes.h
Expand Up @@ -30,7 +30,7 @@ typedef struct

typedef struct
{
const void *moderef;
CGDisplayModeRef moderef;
} SDL_DisplayModeData;

extern void Cocoa_InitModes(_THIS);
Expand Down

0 comments on commit 4a46873

Please sign in to comment.