macOS: Address more compiler warnings when building with a recent deployment target.
authorAlex Szpakowski <slime73@gmail.com>
Thu, 13 Jul 2017 23:09:37 -0300
changeset 11145a0327860b8fb
parent 11144 cccd37a9c28b
child 11146 42fd7dcd5f7e
macOS: Address more compiler warnings when building with a recent deployment target.
src/video/cocoa/SDL_cocoaevents.m
src/video/cocoa/SDL_cocoakeyboard.m
src/video/cocoa/SDL_cocoamessagebox.m
src/video/cocoa/SDL_cocoavideo.h
     1.1 --- a/src/video/cocoa/SDL_cocoaevents.m	Thu Jul 13 22:59:02 2017 -0300
     1.2 +++ b/src/video/cocoa/SDL_cocoaevents.m	Thu Jul 13 23:09:37 2017 -0300
     1.3 @@ -394,6 +394,7 @@
     1.4  Cocoa_PumpEvents(_THIS)
     1.5  { @autoreleasepool
     1.6  {
     1.7 +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     1.8      /* Update activity every 30 seconds to prevent screensaver */
     1.9      SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
    1.10      if (_this->suspend_screensaver && !data->screensaver_use_iopm) {
    1.11 @@ -404,6 +405,7 @@
    1.12              data->screensaver_activity = now;
    1.13          }
    1.14      }
    1.15 +#endif
    1.16  
    1.17      for ( ; ; ) {
    1.18          NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
     2.1 --- a/src/video/cocoa/SDL_cocoakeyboard.m	Thu Jul 13 22:59:02 2017 -0300
     2.2 +++ b/src/video/cocoa/SDL_cocoakeyboard.m	Thu Jul 13 23:09:37 2017 -0300
     2.3 @@ -143,10 +143,13 @@
     2.4              aRange.location, aRange.length, windowHeight,
     2.5              NSStringFromRect(rect));
     2.6  
     2.7 -    if ([window respondsToSelector:@selector(convertRectToScreen:)]) {
     2.8 +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     2.9 +    if (![window respondsToSelector:@selector(convertRectToScreen:)]) {
    2.10 +        rect.origin = [window convertBaseToScreen:rect.origin];
    2.11 +    } else
    2.12 +#endif
    2.13 +    {
    2.14          rect = [window convertRectToScreen:rect];
    2.15 -    } else {
    2.16 -        rect.origin = [window convertBaseToScreen:rect.origin];
    2.17      }
    2.18  
    2.19      return rect;
     3.1 --- a/src/video/cocoa/SDL_cocoamessagebox.m	Thu Jul 13 22:59:02 2017 -0300
     3.2 +++ b/src/video/cocoa/SDL_cocoamessagebox.m	Thu Jul 13 23:09:37 2017 -0300
     3.3 @@ -57,11 +57,24 @@
     3.4  - (void)showAlert:(NSAlert*)alert
     3.5  {
     3.6      if (nswindow) {
     3.7 -        [alert beginSheetModalForWindow:nswindow modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:nil];
     3.8 +#ifdef MAC_OS_X_VERSION_10_9
     3.9 +        if ([alert respondsToSelector:@selector(beginSheetModalForWindow:completionHandler:)]) {
    3.10 +            [alert beginSheetModalForWindow:nswindow completionHandler:^(NSModalResponse returnCode) {
    3.11 +                clicked = returnCode;
    3.12 +            }];
    3.13 +        } else
    3.14 +#endif
    3.15 +        {
    3.16 +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
    3.17 +            [alert beginSheetModalForWindow:nswindow modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:nil];
    3.18 +#endif
    3.19 +        }
    3.20 +
    3.21          while (clicked < 0) {
    3.22              SDL_PumpEvents();
    3.23              SDL_Delay(100);
    3.24          }
    3.25 +
    3.26          [nswindow release];
    3.27      } else {
    3.28          clicked = [alert runModal];
     4.1 --- a/src/video/cocoa/SDL_cocoavideo.h	Thu Jul 13 22:59:02 2017 -0300
     4.2 +++ b/src/video/cocoa/SDL_cocoavideo.h	Thu Jul 13 23:09:37 2017 -0300
     4.3 @@ -86,7 +86,7 @@
     4.4  static const unsigned int NSWindowStyleMaskDocModalWindow = NSDocModalWindowMask;
     4.5  #undef DECLARE_WINDOW_MASK
     4.6  
     4.7 -#define DECLARE_ALERT_STYLE(name) static NSUInteger NSAlertStyle##name = NS##name##AlertStyle
     4.8 +#define DECLARE_ALERT_STYLE(name) static const NSUInteger NSAlertStyle##name = NS##name##AlertStyle
     4.9  DECLARE_ALERT_STYLE(Warning);
    4.10  DECLARE_ALERT_STYLE(Informational);
    4.11  DECLARE_ALERT_STYLE(Critical);