Created
September 10, 2018 19:23
-
-
Save dougmencken/3d82830cf3b0c3806557282f85ca5123 to your computer and use it in GitHub Desktop.
SDL2 2.0.8 patch for OS X 10.5 (unfinished)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From: Douglas Mencken <dougmencken@gmail.com> | |
Date: Mon, 10 Sep 2018 15:20:37 -0400 | |
Subject: [PATCH] SDL2 2.0.8 patch for OS X 10.5 (unfinished) | |
--- | |
include/SDL_platform.h | 3 -- | |
include/SDL_syswm.h | 4 -- | |
src/video/cocoa/SDL_cocoaclipboard.m | 53 ++++++++++++++++++++++++++ | |
src/video/cocoa/SDL_cocoaevents.m | 70 ++++++++++++++++++++++++++++++++++- | |
src/video/cocoa/SDL_cocoakeyboard.m | 42 +++++++++++++++++++-- | |
src/video/cocoa/SDL_cocoamessagebox.m | 14 +++++++ | |
src/video/cocoa/SDL_cocoamodes.h | 4 ++ | |
src/video/cocoa/SDL_cocoavideo.h | 22 ++++++++++- | |
src/video/cocoa/SDL_cocoavideo.m | 12 ++++++ | |
src/video/cocoa/SDL_cocoawindow.h | 16 ++++++++ | |
10 files changed, 226 insertions(+), 14 deletions(-) | |
diff --git a/include/SDL_platform.h b/include/SDL_platform.h | |
index 7dea4ce..113056c 100644 | |
--- a/include/SDL_platform.h | |
+++ b/include/SDL_platform.h | |
@@ -83,9 +83,6 @@ | |
/* if not compiling for iOS */ | |
#undef __MACOSX__ | |
#define __MACOSX__ 1 | |
-#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__) */ | |
diff --git a/include/SDL_syswm.h b/include/SDL_syswm.h | |
index 8aa4a39..189a804 100644 | |
--- a/include/SDL_syswm.h | |
+++ b/include/SDL_syswm.h | |
@@ -229,11 +229,7 @@ struct SDL_SysWMinfo | |
#if defined(SDL_VIDEO_DRIVER_COCOA) | |
struct | |
{ | |
-#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc) | |
- NSWindow __unsafe_unretained *window; /**< The Cocoa window */ | |
-#else | |
NSWindow *window; /**< The Cocoa window */ | |
-#endif | |
} cocoa; | |
#endif | |
#if defined(SDL_VIDEO_DRIVER_UIKIT) | |
diff --git a/src/video/cocoa/SDL_cocoaclipboard.m b/src/video/cocoa/SDL_cocoaclipboard.m | |
index 9c96634..ebe2e5f 100644 | |
--- a/src/video/cocoa/SDL_cocoaclipboard.m | |
+++ b/src/video/cocoa/SDL_cocoaclipboard.m | |
@@ -25,27 +25,64 @@ | |
#include "SDL_cocoavideo.h" | |
#include "../../events/SDL_clipboardevents_c.h" | |
+static NSString * | |
+GetTextFormat(_THIS) | |
+{ | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 | |
+ if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) { | |
+ return NSPasteboardTypeString; | |
+ } else { | |
+#endif | |
+ return NSStringPboardType; | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 | |
+ } | |
+#endif | |
+} | |
+ | |
int | |
Cocoa_SetClipboardText(_THIS, const char *text) | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 | |
{ @autoreleasepool | |
{ | |
+#else | |
+{ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; | |
+#endif | |
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; | |
NSPasteboard *pasteboard; | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 | |
NSString *format = NSPasteboardTypeString; | |
+#else | |
+ NSString *format = GetTextFormat(_this); | |
+#endif | |
pasteboard = [NSPasteboard generalPasteboard]; | |
data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil]; | |
[pasteboard setString:[NSString stringWithUTF8String:text] forType:format]; | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | |
+ [pool release]; | |
+#endif | |
return 0; | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 | |
}} | |
+#else | |
+} | |
+#endif | |
char * | |
Cocoa_GetClipboardText(_THIS) | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 | |
{ @autoreleasepool | |
{ | |
+#else | |
+{ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; | |
+#endif | |
NSPasteboard *pasteboard; | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 | |
NSString *format = NSPasteboardTypeString; | |
+#else | |
+ NSString *format = GetTextFormat(_this); | |
+#endif | |
NSString *available; | |
char *text; | |
@@ -66,8 +103,15 @@ Cocoa_GetClipboardText(_THIS) | |
text = SDL_strdup(""); | |
} | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | |
+ [pool release]; | |
+#endif | |
return text; | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 | |
}} | |
+#else | |
+} | |
+#endif | |
SDL_bool | |
Cocoa_HasClipboardText(_THIS) | |
@@ -83,8 +127,12 @@ Cocoa_HasClipboardText(_THIS) | |
void | |
Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data) | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 | |
{ @autoreleasepool | |
{ | |
+#else | |
+{ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; | |
+#endif | |
NSPasteboard *pasteboard; | |
NSInteger count; | |
@@ -96,7 +144,12 @@ Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data) | |
} | |
data->clipboard_count = count; | |
} | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 | |
}} | |
+#else | |
+ [pool release]; | |
+} | |
+#endif | |
#endif /* SDL_VIDEO_DRIVER_COCOA */ | |
diff --git a/src/video/cocoa/SDL_cocoaevents.m b/src/video/cocoa/SDL_cocoaevents.m | |
index 38f4ba6..e4d666c 100644 | |
--- a/src/video/cocoa/SDL_cocoaevents.m | |
+++ b/src/video/cocoa/SDL_cocoaevents.m | |
@@ -57,6 +57,19 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) | |
SDL_VideoDevice *_this = SDL_GetVideoDevice(); | |
switch ([theEvent type]) { | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | |
+ case NSLeftMouseDown: | |
+ case NSOtherMouseDown: | |
+ case NSRightMouseDown: | |
+ case NSLeftMouseUp: | |
+ case NSOtherMouseUp: | |
+ case NSRightMouseUp: | |
+ case NSLeftMouseDragged: | |
+ case NSRightMouseDragged: | |
+ case NSOtherMouseDragged: /* usually middle mouse dragged */ | |
+ case NSMouseMoved: | |
+ case NSScrollWheel: | |
+#else | |
case NSEventTypeLeftMouseDown: | |
case NSEventTypeOtherMouseDown: | |
case NSEventTypeRightMouseDown: | |
@@ -68,11 +81,18 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) | |
case NSEventTypeOtherMouseDragged: /* usually middle mouse dragged */ | |
case NSEventTypeMouseMoved: | |
case NSEventTypeScrollWheel: | |
+#endif | |
Cocoa_HandleMouseEvent(_this, theEvent); | |
break; | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | |
+ case NSKeyDown: | |
+ case NSKeyUp: | |
+ case NSFlagsChanged: | |
+#else | |
case NSEventTypeKeyDown: | |
case NSEventTypeKeyUp: | |
case NSEventTypeFlagsChanged: | |
+#endif | |
Cocoa_HandleKeyEvent(_this, theEvent); | |
break; | |
default: | |
@@ -110,7 +130,11 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) | |
- (void)setAppleMenu:(NSMenu *)menu; | |
@end | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 | |
@interface SDLAppDelegate : NSObject <NSApplicationDelegate> { | |
+#else | |
+@interface SDLAppDelegate : NSObject { | |
+#endif | |
@public | |
BOOL seenFirstActivate; | |
} | |
@@ -170,14 +194,17 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) | |
*/ | |
for (NSWindow *window in [NSApp orderedWindows]) { | |
if (window != win && [window canBecomeKeyWindow]) { | |
- if (![window isOnActiveSpace]) { | |
- continue; | |
+ if ([window respondsToSelector:@selector(isOnActiveSpace)]) { | |
+ if (![window isOnActiveSpace]) { | |
+ continue; | |
+ } | |
} | |
[window makeKeyAndOrderFront:self]; | |
return; | |
} | |
} | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 | |
/* 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. | |
@@ -189,6 +216,7 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) | |
return; | |
} | |
} | |
+#endif | |
} | |
- (void)focusSomeWindow:(NSNotification *)aNotification | |
@@ -357,6 +385,7 @@ CreateApplicationMenus(void) | |
[windowMenu release]; | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 | |
/* Add the fullscreen view toggle menu option, if supported */ | |
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) { | |
/* Create the view menu */ | |
@@ -374,12 +403,18 @@ CreateApplicationMenus(void) | |
[viewMenu release]; | |
} | |
+#endif | |
} | |
void | |
Cocoa_RegisterApp(void) | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 | |
{ @autoreleasepool | |
{ | |
+#else | |
+{ | |
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |
+#endif | |
/* This can get called more than once! Be careful what you initialize! */ | |
if (NSApp == nil) { | |
@@ -389,7 +424,11 @@ Cocoa_RegisterApp(void) | |
s_bShouldHandleEventsInSDLApplication = SDL_TRUE; | |
if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, SDL_FALSE)) { | |
+#if defined(MAC_OS_X_VERSION_10_6) | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6 | |
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; | |
+#endif | |
+#endif | |
} | |
if ([NSApp mainMenu] == nil) { | |
@@ -415,12 +454,22 @@ Cocoa_RegisterApp(void) | |
appDelegate->seenFirstActivate = YES; | |
} | |
} | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 | |
}} | |
+#else | |
+ [pool release]; | |
+} | |
+#endif | |
void | |
Cocoa_PumpEvents(_THIS) | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 | |
{ @autoreleasepool | |
{ | |
+#else | |
+{ | |
+ NSAutoreleasePool *pool; | |
+#endif | |
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | |
/* Update activity every 30 seconds to prevent screensaver */ | |
SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; | |
@@ -434,8 +483,15 @@ Cocoa_PumpEvents(_THIS) | |
} | |
#endif | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | |
+ pool = [[NSAutoreleasePool alloc] init]; | |
+#endif | |
for ( ; ; ) { | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | |
+ NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ]; | |
+#else | |
NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ]; | |
+#endif | |
if ( event == nil ) { | |
break; | |
} | |
@@ -447,10 +503,16 @@ Cocoa_PumpEvents(_THIS) | |
// Pass events down to SDLApplication to be handled in sendEvent: | |
[NSApp sendEvent:event]; | |
} | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 | |
}} | |
+#else | |
+ [pool release]; | |
+} | |
+#endif | |
void | |
Cocoa_SuspendScreenSaver(_THIS) | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 | |
{ @autoreleasepool | |
{ | |
SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; | |
@@ -477,6 +539,10 @@ Cocoa_SuspendScreenSaver(_THIS) | |
&data->screensaver_assertion); | |
} | |
}} | |
+#else | |
+{ | |
+} | |
+#endif | |
#endif /* SDL_VIDEO_DRIVER_COCOA */ | |
diff --git a/src/video/cocoa/SDL_cocoakeyboard.m b/src/video/cocoa/SDL_cocoakeyboard.m | |
index 8436047..74e9ca4 100644 | |
--- a/src/video/cocoa/SDL_cocoakeyboard.m | |
+++ b/src/video/cocoa/SDL_cocoakeyboard.m | |
@@ -143,13 +143,13 @@ | |
aRange.location, aRange.length, windowHeight, | |
NSStringFromRect(rect)); | |
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | |
- if (![window respondsToSelector:@selector(convertRectToScreen:)]) { | |
- rect.origin = [window convertBaseToScreen:rect.origin]; | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 | |
+ if ([window respondsToSelector:@selector(convertRectToScreen:)]) { | |
+ rect = [window convertRectToScreen:rect]; | |
} else | |
#endif | |
{ | |
- rect = [window convertRectToScreen:rect]; | |
+ rect.origin = [window convertBaseToScreen:rect.origin]; | |
} | |
return rect; | |
@@ -591,9 +591,14 @@ Cocoa_InitKeyboard(_THIS) | |
void | |
Cocoa_StartTextInput(_THIS) | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 | |
{ @autoreleasepool | |
+#endif | |
{ | |
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | |
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |
+#endif | |
SDL_Window *window = SDL_GetKeyboardFocus(); | |
NSWindow *nswindow = nil; | |
if (window) { | |
@@ -618,20 +623,37 @@ Cocoa_StartTextInput(_THIS) | |
[parentView addSubview: data->fieldEdit]; | |
[nswindow makeFirstResponder: data->fieldEdit]; | |
} | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 | |
}} | |
+#else | |
+ [pool release]; | |
+} | |
+#endif | |
void | |
Cocoa_StopTextInput(_THIS) | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 | |
{ @autoreleasepool | |
+#endif | |
{ | |
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; | |
if (data && data->fieldEdit) { | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | |
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |
+#endif | |
[data->fieldEdit removeFromSuperview]; | |
[data->fieldEdit release]; | |
data->fieldEdit = nil; | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | |
+ [pool release]; | |
+#endif | |
} | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 | |
}} | |
+#else | |
+} | |
+#endif | |
void | |
Cocoa_SetTextInputRect(_THIS, SDL_Rect *rect) | |
@@ -673,7 +695,11 @@ Cocoa_HandleKeyEvent(_THIS, NSEvent *event) | |
} | |
switch ([event type]) { | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | |
+ case NSKeyDown: | |
+#else | |
case NSEventTypeKeyDown: | |
+#endif | |
if (![event isARepeat]) { | |
/* See if we need to rebuild the keyboard layout */ | |
UpdateKeymap(data, SDL_TRUE); | |
@@ -697,10 +723,18 @@ Cocoa_HandleKeyEvent(_THIS, NSEvent *event) | |
#endif | |
} | |
break; | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | |
+ case NSKeyUp: | |
+#else | |
case NSEventTypeKeyUp: | |
+#endif | |
SDL_SendKeyboardKey(SDL_RELEASED, code); | |
break; | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | |
+ case NSFlagsChanged: | |
+#else | |
case NSEventTypeFlagsChanged: | |
+#endif | |
/* FIXME CW 2007-08-14: check if this whole mess that takes up half of this file is really necessary */ | |
HandleModifiers(_this, scancode, [event modifierFlags]); | |
break; | |
diff --git a/src/video/cocoa/SDL_cocoamessagebox.m b/src/video/cocoa/SDL_cocoamessagebox.m | |
index a98237f..3dec102 100644 | |
--- a/src/video/cocoa/SDL_cocoamessagebox.m | |
+++ b/src/video/cocoa/SDL_cocoamessagebox.m | |
@@ -92,10 +92,16 @@ | |
/* Display a Cocoa message box */ | |
int | |
Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 | |
{ @autoreleasepool | |
+#endif | |
{ | |
Cocoa_RegisterApp(); | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | |
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |
+#endif | |
+ | |
NSAlert* alert = [[[NSAlert alloc] init] autorelease]; | |
if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) { | |
@@ -137,8 +143,16 @@ Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) | |
returnValue = SDL_SetError("Did not get a valid `clicked button' id: %ld", (long)clicked); | |
} | |
+ | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 | |
+ [pool release]; | |
+#endif | |
return returnValue; | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 | |
}} | |
+#else | |
+} | |
+#endif | |
#endif /* SDL_VIDEO_DRIVER_COCOA */ | |
diff --git a/src/video/cocoa/SDL_cocoamodes.h b/src/video/cocoa/SDL_cocoamodes.h | |
index 05482e8..a4a8a9f 100644 | |
--- a/src/video/cocoa/SDL_cocoamodes.h | |
+++ b/src/video/cocoa/SDL_cocoamodes.h | |
@@ -30,7 +30,11 @@ typedef struct | |
typedef struct | |
{ | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 | |
CGDisplayModeRef moderef; | |
+#else | |
+ const void *moderef; | |
+#endif | |
} SDL_DisplayModeData; | |
extern void Cocoa_InitModes(_THIS); | |
diff --git a/src/video/cocoa/SDL_cocoavideo.h b/src/video/cocoa/SDL_cocoavideo.h | |
index 05bbd34..8eb3b13 100644 | |
--- a/src/video/cocoa/SDL_cocoavideo.h | |
+++ b/src/video/cocoa/SDL_cocoavideo.h | |
@@ -25,6 +25,13 @@ | |
#include "SDL_opengl.h" | |
+#if defined(__ALTIVEC__) && !defined(MAC_OS_X_VERSION_10_5) | |
+/* to cricumvent a bug in Mac OS X 10.4 SDK */ | |
+#define vector __vector | |
+#include <CoreServices/CoreServices.h> | |
+#undef vector | |
+#endif | |
+ | |
#include <ApplicationServices/ApplicationServices.h> | |
#include <IOKit/pwr_mgt/IOPMLib.h> | |
#include <Cocoa/Cocoa.h> | |
@@ -40,6 +47,11 @@ | |
#include "SDL_cocoaopengl.h" | |
#include "SDL_cocoawindow.h" | |
+#if !defined(MAC_OS_X_VERSION_10_5) | |
+typedef long int NSInteger; | |
+typedef unsigned int NSUInteger; | |
+#endif | |
+ | |
#ifndef MAC_OS_X_VERSION_10_12 | |
#define DECLARE_EVENT(name) static const NSEventType NSEventType##name = NS##name | |
DECLARE_EVENT(LeftMouseDown); | |
@@ -58,7 +70,9 @@ DECLARE_EVENT(KeyUp); | |
DECLARE_EVENT(FlagsChanged); | |
#undef DECLARE_EVENT | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 | |
static const NSEventMask NSEventMaskAny = NSAnyEventMask; | |
+#endif | |
#define DECLARE_MODIFIER_FLAG(name) static const NSUInteger NSEventModifierFlag##name = NS##name##KeyMask | |
DECLARE_MODIFIER_FLAG(Shift); | |
@@ -79,13 +93,17 @@ DECLARE_WINDOW_MASK(Miniaturizable); | |
DECLARE_WINDOW_MASK(Resizable); | |
DECLARE_WINDOW_MASK(TexturedBackground); | |
DECLARE_WINDOW_MASK(UnifiedTitleAndToolbar); | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 | |
DECLARE_WINDOW_MASK(FullScreen); | |
+#endif | |
/*DECLARE_WINDOW_MASK(FullSizeContentView);*/ /* Not used, fails compile on older SDKs */ | |
static const unsigned int NSWindowStyleMaskUtilityWindow = NSUtilityWindowMask; | |
static const unsigned int NSWindowStyleMaskDocModalWindow = NSDocModalWindowMask; | |
+ | |
static const unsigned int NSWindowStyleMaskHUDWindow = NSHUDWindowMask; | |
+#if defined(MAC_OS_X_VERSION_10_5) | |
#undef DECLARE_WINDOW_MASK | |
- | |
+#endif | |
#define DECLARE_ALERT_STYLE(name) static const NSUInteger NSAlertStyle##name = NS##name##AlertStyle | |
DECLARE_ALERT_STYLE(Warning); | |
DECLARE_ALERT_STYLE(Informational); | |
@@ -106,7 +124,9 @@ typedef struct SDL_VideoData | |
NSInteger clipboard_count; | |
Uint32 screensaver_activity; | |
BOOL screensaver_use_iopm; | |
+#if defined(MAC_OS_X_VERSION_10_5) | |
IOPMAssertionID screensaver_assertion; | |
+#endif | |
} SDL_VideoData; | |
diff --git a/src/video/cocoa/SDL_cocoavideo.m b/src/video/cocoa/SDL_cocoavideo.m | |
index 545dc1e..df6d94a 100644 | |
--- a/src/video/cocoa/SDL_cocoavideo.m | |
+++ b/src/video/cocoa/SDL_cocoavideo.m | |
@@ -22,6 +22,13 @@ | |
#if SDL_VIDEO_DRIVER_COCOA | |
+#if defined(__APPLE__) && defined(__POWERPC__) && !defined(__APPLE_ALTIVEC__) | |
+#include <altivec.h> | |
+#undef bool | |
+#undef vector | |
+#undef pixel | |
+#endif | |
+ | |
#include "SDL.h" | |
#include "SDL_endian.h" | |
#include "SDL_cocoavideo.h" | |
@@ -169,10 +176,15 @@ Cocoa_VideoInit(_THIS) | |
Cocoa_InitKeyboard(_this); | |
Cocoa_InitMouse(_this); | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 | |
data->allow_spaces = ((floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) && SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_TRUE)); | |
/* The IOPM assertion API can disable the screensaver as of 10.7. */ | |
data->screensaver_use_iopm = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6; | |
+#else | |
+ data->allow_spaces = 0; | |
+ data->screensaver_use_iopm = 0; | |
+#endif | |
return 0; | |
} | |
diff --git a/src/video/cocoa/SDL_cocoawindow.h b/src/video/cocoa/SDL_cocoawindow.h | |
index df6f173..b1dcc0f 100644 | |
--- a/src/video/cocoa/SDL_cocoawindow.h | |
+++ b/src/video/cocoa/SDL_cocoawindow.h | |
@@ -39,7 +39,11 @@ typedef enum | |
PENDING_OPERATION_MINIMIZE | |
} PendingWindowOperation; | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 | |
@interface Cocoa_WindowListener : NSResponder <NSWindowDelegate> { | |
+#else | |
+@interface Cocoa_WindowListener : NSResponder { | |
+#endif | |
SDL_WindowData *_data; | |
BOOL observingVisible; | |
BOOL wasCtrlLeft; | |
@@ -79,7 +83,9 @@ typedef enum | |
-(void) windowDidEnterFullScreen:(NSNotification *) aNotification; | |
-(void) windowWillExitFullScreen:(NSNotification *) aNotification; | |
-(void) windowDidExitFullScreen:(NSNotification *) aNotification; | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 | |
-(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions; | |
+#endif | |
/* See if event is in a drag area, toggle on window dragging. */ | |
-(BOOL) processHitTest:(NSEvent *)theEvent; | |
@@ -102,7 +108,17 @@ typedef enum | |
-(void) touchesCancelledWithEvent:(NSEvent *) theEvent; | |
/* Touch event handling */ | |
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 | |
-(void) handleTouches:(NSTouchPhase) phase withEvent:(NSEvent*) theEvent; | |
+#else | |
+typedef enum { | |
+ COCOA_TOUCH_DOWN, | |
+ COCOA_TOUCH_UP, | |
+ COCOA_TOUCH_MOVE, | |
+ COCOA_TOUCH_CANCELLED | |
+} cocoaTouchType; | |
+-(void) handleTouches:(cocoaTouchType) type withEvent:(NSEvent*) event; | |
+#endif | |
@end | |
/* *INDENT-ON* */ | |
-- | |
2.8.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment