From 562473c1f4d495042b561acc86035bc2cd20cd91 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Thu, 13 Jul 2017 23:09:37 -0300 Subject: [PATCH] macOS: Address more compiler warnings when building with a recent deployment target. --- src/video/cocoa/SDL_cocoaevents.m | 2 ++ src/video/cocoa/SDL_cocoakeyboard.m | 9 ++++++--- src/video/cocoa/SDL_cocoamessagebox.m | 15 ++++++++++++++- src/video/cocoa/SDL_cocoavideo.h | 2 +- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/video/cocoa/SDL_cocoaevents.m b/src/video/cocoa/SDL_cocoaevents.m index f5b015ab76360..e428e4374dd9f 100644 --- a/src/video/cocoa/SDL_cocoaevents.m +++ b/src/video/cocoa/SDL_cocoaevents.m @@ -394,6 +394,7 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenam Cocoa_PumpEvents(_THIS) { @autoreleasepool { +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 /* Update activity every 30 seconds to prevent screensaver */ SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; if (_this->suspend_screensaver && !data->screensaver_use_iopm) { @@ -404,6 +405,7 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenam data->screensaver_activity = now; } } +#endif for ( ; ; ) { NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ]; diff --git a/src/video/cocoa/SDL_cocoakeyboard.m b/src/video/cocoa/SDL_cocoakeyboard.m index 16f37ba0435bd..b2ce5a31d1f65 100644 --- a/src/video/cocoa/SDL_cocoakeyboard.m +++ b/src/video/cocoa/SDL_cocoakeyboard.m @@ -143,10 +143,13 @@ - (NSRect)firstRectForCharacterRange:(NSRange)aRange actualRange:(NSRangePointer aRange.location, aRange.length, windowHeight, NSStringFromRect(rect)); - if ([window respondsToSelector:@selector(convertRectToScreen:)]) { - rect = [window convertRectToScreen:rect]; - } else { +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 + if (![window respondsToSelector:@selector(convertRectToScreen:)]) { rect.origin = [window convertBaseToScreen:rect.origin]; + } else +#endif + { + rect = [window convertRectToScreen:rect]; } return rect; diff --git a/src/video/cocoa/SDL_cocoamessagebox.m b/src/video/cocoa/SDL_cocoamessagebox.m index fc2fcb3ceb04d..ea554493864a1 100644 --- a/src/video/cocoa/SDL_cocoamessagebox.m +++ b/src/video/cocoa/SDL_cocoamessagebox.m @@ -57,11 +57,24 @@ - (id) initWithParentWindow:(SDL_Window *)window - (void)showAlert:(NSAlert*)alert { if (nswindow) { - [alert beginSheetModalForWindow:nswindow modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:nil]; +#ifdef MAC_OS_X_VERSION_10_9 + if ([alert respondsToSelector:@selector(beginSheetModalForWindow:completionHandler:)]) { + [alert beginSheetModalForWindow:nswindow completionHandler:^(NSModalResponse returnCode) { + clicked = returnCode; + }]; + } else +#endif + { +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 + [alert beginSheetModalForWindow:nswindow modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:nil]; +#endif + } + while (clicked < 0) { SDL_PumpEvents(); SDL_Delay(100); } + [nswindow release]; } else { clicked = [alert runModal]; diff --git a/src/video/cocoa/SDL_cocoavideo.h b/src/video/cocoa/SDL_cocoavideo.h index c6ca524599604..b051ffd95c4c8 100644 --- a/src/video/cocoa/SDL_cocoavideo.h +++ b/src/video/cocoa/SDL_cocoavideo.h @@ -86,7 +86,7 @@ static const unsigned int NSWindowStyleMaskUtilityWindow = NSUtilityWindowMask; static const unsigned int NSWindowStyleMaskDocModalWindow = NSDocModalWindowMask; #undef DECLARE_WINDOW_MASK -#define DECLARE_ALERT_STYLE(name) static NSUInteger NSAlertStyle##name = NS##name##AlertStyle +#define DECLARE_ALERT_STYLE(name) static const NSUInteger NSAlertStyle##name = NS##name##AlertStyle DECLARE_ALERT_STYLE(Warning); DECLARE_ALERT_STYLE(Informational); DECLARE_ALERT_STYLE(Critical);