mirror of https://github.com/libsdl-org/SDL
Removed Mac OS 10.5 support (bug #3137). Also fixed a warning about deprecated Carbon code when using SDL_audio (bug #3127, thanks Dominik!)
This commit is contained in:
parent
6255c8584a
commit
4a468739f8
|
@ -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";
|
||||
};
|
||||
|
@ -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;
|
||||
|
|
|
@ -3934,7 +3934,7 @@
|
|||
);
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
HEADER_SEARCH_PATHS = ../../include;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.5;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.6;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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__) */
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -507,11 +496,10 @@ 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");
|
||||
|
@ -519,17 +507,8 @@ prepare_audiounit(_THIS, void *handle, int iscapture,
|
|||
}
|
||||
|
||||
/* 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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
@ -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
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
@ -55,7 +45,7 @@ Cocoa_GetClipboardText(_THIS)
|
|||
{ @autoreleasepool
|
||||
{
|
||||
NSPasteboard *pasteboard;
|
||||
NSString *format = GetTextFormat(_this);
|
||||
NSString *format = NSPasteboardTypeString;
|
||||
NSString *available;
|
||||
char *text;
|
||||
|
||||
|
|
|
@ -114,28 +114,23 @@
|
|||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -291,7 +286,7 @@ CreateApplicationMenus(void)
|
|||
|
||||
|
||||
/* 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"];
|
||||
|
||||
|
@ -321,16 +316,7 @@ Cocoa_RegisterApp(void)
|
|||
|
||||
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];
|
||||
}
|
||||
|
||||
|
|
|
@ -69,14 +69,6 @@
|
|||
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
|
||||
|
@ -498,11 +490,8 @@ Cocoa_InitKeyboard(_THIS)
|
|||
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
|
||||
|
|
|
@ -30,7 +30,7 @@ typedef struct
|
|||
|
||||
typedef struct
|
||||
{
|
||||
const void *moderef;
|
||||
CGDisplayModeRef moderef;
|
||||
} SDL_DisplayModeData;
|
||||
|
||||
extern void Cocoa_InitModes(_THIS);
|
||||
|
|
|
@ -56,25 +56,6 @@ Cocoa_ToggleMenuBar(const BOOL show)
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* !!! FIXME: clean out the pre-10.6 code when it makes sense to do so. */
|
||||
#define FORCE_OLD_API 0
|
||||
|
||||
#if FORCE_OLD_API
|
||||
#undef MAC_OS_X_VERSION_MIN_REQUIRED
|
||||
#define MAC_OS_X_VERSION_MIN_REQUIRED 1050
|
||||
#endif
|
||||
|
||||
static BOOL
|
||||
IS_SNOW_LEOPARD_OR_LATER()
|
||||
{
|
||||
#if FORCE_OLD_API
|
||||
return NO;
|
||||
#else
|
||||
return floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
CG_SetError(const char *prefix, CGDisplayErr result)
|
||||
{
|
||||
|
@ -119,59 +100,40 @@ CG_SetError(const char *prefix, CGDisplayErr result)
|
|||
}
|
||||
|
||||
static SDL_bool
|
||||
GetDisplayMode(_THIS, const void *moderef, CVDisplayLinkRef link, SDL_DisplayMode *mode)
|
||||
GetDisplayMode(_THIS, CGDisplayModeRef vidmode, CVDisplayLinkRef link, SDL_DisplayMode *mode)
|
||||
{
|
||||
SDL_DisplayModeData *data;
|
||||
long width = 0;
|
||||
long height = 0;
|
||||
long bpp = 0;
|
||||
long refreshRate = 0;
|
||||
CFStringRef fmt;
|
||||
|
||||
data = (SDL_DisplayModeData *) SDL_malloc(sizeof(*data));
|
||||
if (!data) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
data->moderef = moderef;
|
||||
data->moderef = vidmode;
|
||||
|
||||
if (IS_SNOW_LEOPARD_OR_LATER()) {
|
||||
CGDisplayModeRef vidmode = (CGDisplayModeRef) moderef;
|
||||
CFStringRef fmt = CGDisplayModeCopyPixelEncoding(vidmode);
|
||||
width = (long) CGDisplayModeGetWidth(vidmode);
|
||||
height = (long) CGDisplayModeGetHeight(vidmode);
|
||||
refreshRate = (long) (CGDisplayModeGetRefreshRate(vidmode) + 0.5);
|
||||
fmt = CGDisplayModeCopyPixelEncoding(vidmode);
|
||||
width = (long) CGDisplayModeGetWidth(vidmode);
|
||||
height = (long) CGDisplayModeGetHeight(vidmode);
|
||||
refreshRate = (long) (CGDisplayModeGetRefreshRate(vidmode) + 0.5);
|
||||
|
||||
if (CFStringCompare(fmt, CFSTR(IO32BitDirectPixels),
|
||||
kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
|
||||
bpp = 32;
|
||||
} else if (CFStringCompare(fmt, CFSTR(IO16BitDirectPixels),
|
||||
kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
|
||||
bpp = 16;
|
||||
} else if (CFStringCompare(fmt, CFSTR(kIO30BitDirectPixels),
|
||||
kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
|
||||
bpp = 30;
|
||||
} else {
|
||||
bpp = 0; /* ignore 8-bit and such for now. */
|
||||
}
|
||||
|
||||
CFRelease(fmt);
|
||||
if (CFStringCompare(fmt, CFSTR(IO32BitDirectPixels),
|
||||
kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
|
||||
bpp = 32;
|
||||
} else if (CFStringCompare(fmt, CFSTR(IO16BitDirectPixels),
|
||||
kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
|
||||
bpp = 16;
|
||||
} else if (CFStringCompare(fmt, CFSTR(kIO30BitDirectPixels),
|
||||
kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
|
||||
bpp = 30;
|
||||
} else {
|
||||
bpp = 0; /* ignore 8-bit and such for now. */
|
||||
}
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
|
||||
if (!IS_SNOW_LEOPARD_OR_LATER()) {
|
||||
CFNumberRef number;
|
||||
double refresh;
|
||||
CFDictionaryRef vidmode = (CFDictionaryRef) moderef;
|
||||
number = CFDictionaryGetValue(vidmode, kCGDisplayWidth);
|
||||
CFNumberGetValue(number, kCFNumberLongType, &width);
|
||||
number = CFDictionaryGetValue(vidmode, kCGDisplayHeight);
|
||||
CFNumberGetValue(number, kCFNumberLongType, &height);
|
||||
number = CFDictionaryGetValue(vidmode, kCGDisplayBitsPerPixel);
|
||||
CFNumberGetValue(number, kCFNumberLongType, &bpp);
|
||||
number = CFDictionaryGetValue(vidmode, kCGDisplayRefreshRate);
|
||||
CFNumberGetValue(number, kCFNumberDoubleType, &refresh);
|
||||
refreshRate = (long) (refresh + 0.5);
|
||||
}
|
||||
#endif
|
||||
CFRelease(fmt);
|
||||
|
||||
/* CGDisplayModeGetRefreshRate returns 0 for many non-CRT displays. */
|
||||
if (refreshRate == 0 && link != NULL) {
|
||||
|
@ -204,22 +166,6 @@ GetDisplayMode(_THIS, const void *moderef, CVDisplayLinkRef link, SDL_DisplayMod
|
|||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
Cocoa_ReleaseDisplayMode(_THIS, const void *moderef)
|
||||
{
|
||||
if (IS_SNOW_LEOPARD_OR_LATER()) {
|
||||
CGDisplayModeRelease((CGDisplayModeRef) moderef); /* NULL is ok */
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Cocoa_ReleaseDisplayModeList(_THIS, CFArrayRef modelist)
|
||||
{
|
||||
if (IS_SNOW_LEOPARD_OR_LATER()) {
|
||||
CFRelease(modelist); /* NULL is ok */
|
||||
}
|
||||
}
|
||||
|
||||
static const char *
|
||||
Cocoa_GetDisplayName(CGDirectDisplayID displayID)
|
||||
{
|
||||
|
@ -262,7 +208,7 @@ Cocoa_InitModes(_THIS)
|
|||
SDL_VideoDisplay display;
|
||||
SDL_DisplayData *displaydata;
|
||||
SDL_DisplayMode mode;
|
||||
const void *moderef = NULL;
|
||||
CGDisplayModeRef moderef = NULL;
|
||||
CVDisplayLinkRef link = NULL;
|
||||
|
||||
if (pass == 0) {
|
||||
|
@ -279,15 +225,7 @@ Cocoa_InitModes(_THIS)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (IS_SNOW_LEOPARD_OR_LATER()) {
|
||||
moderef = CGDisplayCopyDisplayMode(displays[i]);
|
||||
}
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
|
||||
if (!IS_SNOW_LEOPARD_OR_LATER()) {
|
||||
moderef = CGDisplayCurrentMode(displays[i]);
|
||||
}
|
||||
#endif
|
||||
moderef = CGDisplayCopyDisplayMode(displays[i]);
|
||||
|
||||
if (!moderef) {
|
||||
continue;
|
||||
|
@ -295,7 +233,7 @@ Cocoa_InitModes(_THIS)
|
|||
|
||||
displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
|
||||
if (!displaydata) {
|
||||
Cocoa_ReleaseDisplayMode(_this, moderef);
|
||||
CGDisplayModeRelease(moderef);
|
||||
continue;
|
||||
}
|
||||
displaydata->display = displays[i];
|
||||
|
@ -307,7 +245,7 @@ Cocoa_InitModes(_THIS)
|
|||
display.name = (char *)Cocoa_GetDisplayName(displays[i]);
|
||||
if (!GetDisplayMode(_this, moderef, link, &mode)) {
|
||||
CVDisplayLinkRelease(link);
|
||||
Cocoa_ReleaseDisplayMode(_this, moderef);
|
||||
CGDisplayModeRelease(moderef);
|
||||
SDL_free(display.name);
|
||||
SDL_free(displaydata);
|
||||
continue;
|
||||
|
@ -396,17 +334,7 @@ void
|
|||
Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
|
||||
{
|
||||
SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
|
||||
CFArrayRef modes = NULL;
|
||||
|
||||
if (IS_SNOW_LEOPARD_OR_LATER()) {
|
||||
modes = CGDisplayCopyAllDisplayModes(data->display, NULL);
|
||||
}
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
|
||||
if (!IS_SNOW_LEOPARD_OR_LATER()) {
|
||||
modes = CGDisplayAvailableModes(data->display);
|
||||
}
|
||||
#endif
|
||||
CFArrayRef modes = CGDisplayCopyAllDisplayModes(data->display, NULL);
|
||||
|
||||
if (modes) {
|
||||
CVDisplayLinkRef link = NULL;
|
||||
|
@ -416,37 +344,19 @@ Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
|
|||
CVDisplayLinkCreateWithCGDisplay(data->display, &link);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
const void *moderef = CFArrayGetValueAtIndex(modes, i);
|
||||
CGDisplayModeRef moderef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
|
||||
SDL_DisplayMode mode;
|
||||
if (GetDisplayMode(_this, moderef, link, &mode)) {
|
||||
if (IS_SNOW_LEOPARD_OR_LATER()) {
|
||||
CGDisplayModeRetain((CGDisplayModeRef) moderef);
|
||||
}
|
||||
CGDisplayModeRetain(moderef);
|
||||
SDL_AddDisplayMode(display, &mode);
|
||||
}
|
||||
}
|
||||
|
||||
CVDisplayLinkRelease(link);
|
||||
Cocoa_ReleaseDisplayModeList(_this, modes);
|
||||
CFRelease(modes);
|
||||
}
|
||||
}
|
||||
|
||||
static CGError
|
||||
Cocoa_SwitchMode(_THIS, CGDirectDisplayID display, const void *mode)
|
||||
{
|
||||
if (IS_SNOW_LEOPARD_OR_LATER()) {
|
||||
return CGDisplaySetDisplayMode(display, (CGDisplayModeRef) mode, NULL);
|
||||
}
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
|
||||
if (!IS_SNOW_LEOPARD_OR_LATER()) {
|
||||
return CGDisplaySwitchToMode(display, (CFDictionaryRef) mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
return kCGErrorFailure;
|
||||
}
|
||||
|
||||
int
|
||||
Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
||||
{
|
||||
|
@ -462,7 +372,7 @@ Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
|||
|
||||
if (data == display->desktop_mode.driverdata) {
|
||||
/* Restoring desktop mode */
|
||||
Cocoa_SwitchMode(_this, displaydata->display, data->moderef);
|
||||
CGDisplaySetDisplayMode(displaydata->display, data->moderef, NULL);
|
||||
|
||||
if (CGDisplayIsMain(displaydata->display)) {
|
||||
CGReleaseAllDisplays();
|
||||
|
@ -487,7 +397,7 @@ Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
|||
}
|
||||
|
||||
/* Do the physical switch */
|
||||
result = Cocoa_SwitchMode(_this, displaydata->display, data->moderef);
|
||||
result = CGDisplaySetDisplayMode(displaydata->display, data->moderef, NULL);
|
||||
if (result != kCGErrorSuccess) {
|
||||
CG_SetError("CGDisplaySwitchToMode()", result);
|
||||
goto ERR_NO_SWITCH;
|
||||
|
@ -532,11 +442,11 @@ Cocoa_QuitModes(_THIS)
|
|||
}
|
||||
|
||||
mode = (SDL_DisplayModeData *) display->desktop_mode.driverdata;
|
||||
Cocoa_ReleaseDisplayMode(_this, mode->moderef);
|
||||
CGDisplayModeRelease(mode->moderef);
|
||||
|
||||
for (j = 0; j < display->num_display_modes; j++) {
|
||||
mode = (SDL_DisplayModeData*) display->display_modes[j].driverdata;
|
||||
Cocoa_ReleaseDisplayMode(_this, mode->moderef);
|
||||
CGDisplayModeRelease(mode->moderef);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,9 +35,7 @@ Cocoa_CreateShaper(SDL_Window* window)
|
|||
SDL_WindowData* windata = (SDL_WindowData*)window->driverdata;
|
||||
[windata->nswindow setOpaque:NO];
|
||||
|
||||
if ([windata->nswindow respondsToSelector:@selector(setStyleMask:)]) {
|
||||
[windata->nswindow setStyleMask:NSBorderlessWindowMask];
|
||||
}
|
||||
[windata->nswindow setStyleMask:NSBorderlessWindowMask];
|
||||
|
||||
SDL_WindowShaper* result = result = malloc(sizeof(SDL_WindowShaper));
|
||||
result->window = window;
|
||||
|
|
|
@ -138,10 +138,7 @@
|
|||
NSURL *fileURL = [[NSURL fileURLWithPath:path] autorelease];
|
||||
NSNumber *isAlias = nil;
|
||||
|
||||
/* Functionality for resolving URL aliases was added with OS X 10.6. */
|
||||
if ([fileURL respondsToSelector:@selector(getResourceValue:forKey:error:)]) {
|
||||
[fileURL getResourceValue:&isAlias forKey:NSURLIsAliasFileKey error:nil];
|
||||
}
|
||||
[fileURL getResourceValue:&isAlias forKey:NSURLIsAliasFileKey error:nil];
|
||||
|
||||
/* If the URL is an alias, resolve it. */
|
||||
if ([isAlias boolValue]) {
|
||||
|
@ -218,10 +215,10 @@ GetHintCtrlClickEmulateRightClick()
|
|||
return hint != NULL && *hint != '0';
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
static NSUInteger
|
||||
GetWindowStyle(SDL_Window * window)
|
||||
{
|
||||
unsigned int style;
|
||||
NSUInteger style = 0;
|
||||
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
style = NSBorderlessWindowMask;
|
||||
|
@ -239,21 +236,17 @@ GetWindowStyle(SDL_Window * window)
|
|||
}
|
||||
|
||||
static SDL_bool
|
||||
SetWindowStyle(SDL_Window * window, unsigned int style)
|
||||
SetWindowStyle(SDL_Window * window, NSUInteger style)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
NSWindow *nswindow = data->nswindow;
|
||||
|
||||
if (![nswindow respondsToSelector: @selector(setStyleMask:)]) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* The view responder chain gets messed with during setStyleMask */
|
||||
if ([[nswindow contentView] nextResponder] == data->listener) {
|
||||
[[nswindow contentView] setNextResponder:nil];
|
||||
}
|
||||
|
||||
[nswindow performSelector: @selector(setStyleMask:) withObject: (id)(uintptr_t)style];
|
||||
[nswindow setStyleMask:style];
|
||||
|
||||
/* The view responder chain gets messed with during setStyleMask */
|
||||
if ([[nswindow contentView] nextResponder] != data->listener) {
|
||||
|
@ -317,9 +310,7 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
|
|||
|
||||
[view setNextResponder:self];
|
||||
|
||||
if ([view respondsToSelector:@selector(setAcceptsTouchEvents:)]) {
|
||||
[view setAcceptsTouchEvents:YES];
|
||||
}
|
||||
[view setAcceptsTouchEvents:YES];
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath
|
||||
|
@ -604,12 +595,9 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
|
|||
[NSMenu setMenuBarVisible:NO];
|
||||
}
|
||||
|
||||
/* On pre-10.6, you might have the capslock key state wrong now because we can't check here. */
|
||||
if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_6) {
|
||||
const unsigned int newflags = [NSEvent modifierFlags] & NSAlphaShiftKeyMask;
|
||||
_data->videodata->modifierFlags = (_data->videodata->modifierFlags & ~NSAlphaShiftKeyMask) | newflags;
|
||||
SDL_ToggleModState(KMOD_CAPS, newflags != 0);
|
||||
}
|
||||
const unsigned int newflags = [NSEvent modifierFlags] & NSAlphaShiftKeyMask;
|
||||
_data->videodata->modifierFlags = (_data->videodata->modifierFlags & ~NSAlphaShiftKeyMask) | newflags;
|
||||
SDL_ToggleModState(KMOD_CAPS, newflags != 0);
|
||||
}
|
||||
|
||||
- (void)windowDidResignKey:(NSNotification *)aNotification
|
||||
|
@ -1483,27 +1471,6 @@ Cocoa_RestoreWindow(_THIS, SDL_Window * window)
|
|||
}
|
||||
}}
|
||||
|
||||
static NSWindow *
|
||||
Cocoa_RebuildWindow(SDL_WindowData * data, NSWindow * nswindow, unsigned style)
|
||||
{
|
||||
if (!data->created) {
|
||||
/* Don't mess with other people's windows... */
|
||||
return nswindow;
|
||||
}
|
||||
|
||||
[data->listener close];
|
||||
data->nswindow = [[SDLWindow alloc] initWithContentRect:[[nswindow contentView] frame] styleMask:style backing:NSBackingStoreBuffered defer:NO screen:[nswindow screen]];
|
||||
[data->nswindow setContentView:[nswindow contentView]];
|
||||
[data->nswindow registerForDraggedTypes:[NSArray arrayWithObject:(NSString *)kUTTypeFileURL]];
|
||||
/* See comment in SetupWindowData. */
|
||||
[data->nswindow setOneShot:NO];
|
||||
[data->listener listen:data];
|
||||
|
||||
[nswindow close];
|
||||
|
||||
return data->nswindow;
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
|
||||
{ @autoreleasepool
|
||||
|
@ -1545,11 +1512,7 @@ Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
|
|||
rect.origin.y += (screenRect.size.height - rect.size.height);
|
||||
}
|
||||
|
||||
if ([nswindow respondsToSelector: @selector(setStyleMask:)]) {
|
||||
[nswindow performSelector: @selector(setStyleMask:) withObject: (id)NSBorderlessWindowMask];
|
||||
} else {
|
||||
nswindow = Cocoa_RebuildWindow(data, nswindow, NSBorderlessWindowMask);
|
||||
}
|
||||
[nswindow setStyleMask:NSBorderlessWindowMask];
|
||||
} else {
|
||||
rect.origin.x = window->windowed.x;
|
||||
rect.origin.y = window->windowed.y;
|
||||
|
@ -1557,16 +1520,12 @@ Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
|
|||
rect.size.height = window->windowed.h;
|
||||
ConvertNSRect([nswindow screen], fullscreen, &rect);
|
||||
|
||||
if ([nswindow respondsToSelector: @selector(setStyleMask:)]) {
|
||||
[nswindow performSelector: @selector(setStyleMask:) withObject: (id)(uintptr_t)GetWindowStyle(window)];
|
||||
[nswindow setStyleMask:GetWindowStyle(window)];
|
||||
|
||||
/* Hack to restore window decorations on Mac OS X 10.10 */
|
||||
NSRect frameRect = [nswindow frame];
|
||||
[nswindow setFrame:NSMakeRect(frameRect.origin.x, frameRect.origin.y, frameRect.size.width + 1, frameRect.size.height) display:NO];
|
||||
[nswindow setFrame:frameRect display:NO];
|
||||
} else {
|
||||
nswindow = Cocoa_RebuildWindow(data, nswindow, GetWindowStyle(window));
|
||||
}
|
||||
/* Hack to restore window decorations on Mac OS X 10.10 */
|
||||
NSRect frameRect = [nswindow frame];
|
||||
[nswindow setFrame:NSMakeRect(frameRect.origin.x, frameRect.origin.y, frameRect.size.width + 1, frameRect.size.height) display:NO];
|
||||
[nswindow setFrame:frameRect display:NO];
|
||||
}
|
||||
|
||||
/* The view responder chain gets messed with during setStyleMask */
|
||||
|
|
Loading…
Reference in New Issue