Fixed bug 2631 - Mac: minor code cleanup
authorSam Lantinga <slouken@libsdl.org>
Mon, 07 Jul 2014 12:48:25 -0700
changeset 89861c81316ac642
parent 8985 a89acd7254f2
child 8987 d0fd8420b019
Fixed bug 2631 - Mac: minor code cleanup

Alex Szpakowski

Some minor changes to the Mac-specific backend code:

- Fixed up some code style issues (mostly brace style inconsistencies).

- Fixed a compiler warning in SDL_cocoaevents.m.

- Removed some useless code now that the 10.7 SDK is required to build SDL.

- Removed Gestalt(gestaltSystemVersion, ...) call and switched to NSAppKitVersionNumber for version checking code. Using Gestalt with gestaltSystemVersion will give 0x1090 in Mac OS 10.10+, and the whole Gestalt function was deprecated in Mac OS 10.8.
src/file/cocoa/SDL_rwopsbundlesupport.m
src/haptic/darwin/SDL_syshaptic.c
src/joystick/darwin/SDL_sysjoystick.c
src/video/cocoa/SDL_cocoaclipboard.m
src/video/cocoa/SDL_cocoaevents.m
src/video/cocoa/SDL_cocoakeyboard.m
src/video/cocoa/SDL_cocoamessagebox.m
src/video/cocoa/SDL_cocoamodes.m
src/video/cocoa/SDL_cocoamouse.m
src/video/cocoa/SDL_cocoamousetap.m
src/video/cocoa/SDL_cocoaopengl.m
src/video/cocoa/SDL_cocoashape.m
src/video/cocoa/SDL_cocoavideo.h
src/video/cocoa/SDL_cocoavideo.m
src/video/cocoa/SDL_cocoawindow.h
src/video/cocoa/SDL_cocoawindow.m
     1.1 --- a/src/file/cocoa/SDL_rwopsbundlesupport.m	Mon Jul 07 11:44:14 2014 -0700
     1.2 +++ b/src/file/cocoa/SDL_rwopsbundlesupport.m	Mon Jul 07 12:48:25 2014 -0700
     1.3 @@ -37,8 +37,7 @@
     1.4      FILE* fp = NULL;
     1.5  
     1.6      /* If the file mode is writable, skip all the bundle stuff because generally the bundle is read-only. */
     1.7 -    if(strcmp("r", mode) && strcmp("rb", mode))
     1.8 -    {
     1.9 +    if(strcmp("r", mode) && strcmp("rb", mode)) {
    1.10          return fopen(file, mode);
    1.11      }
    1.12  
    1.13 @@ -51,12 +50,10 @@
    1.14      NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
    1.15  
    1.16      NSString* full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component];
    1.17 -    if([file_manager fileExistsAtPath:full_path_with_file_to_try])
    1.18 -    {
    1.19 +    if([file_manager fileExistsAtPath:full_path_with_file_to_try]) {
    1.20          fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
    1.21      }
    1.22 -    else
    1.23 -    {
    1.24 +    else {
    1.25          fp = fopen(file, mode);
    1.26      }
    1.27  
     2.1 --- a/src/haptic/darwin/SDL_syshaptic.c	Mon Jul 07 11:44:14 2014 -0700
     2.2 +++ b/src/haptic/darwin/SDL_syshaptic.c	Mon Jul 07 12:48:25 2014 -0700
     2.3 @@ -257,21 +257,18 @@
     2.4                                                 kCFAllocatorDefault,
     2.5                                                 kNilOptions);
     2.6      if ((result == KERN_SUCCESS) && hidProperties) {
     2.7 -        refCF =
     2.8 -        CFDictionaryGetValue(hidProperties,
     2.9 -                             CFSTR(kIOHIDPrimaryUsagePageKey));
    2.10 +        refCF = CFDictionaryGetValue(hidProperties,
    2.11 +                                     CFSTR(kIOHIDPrimaryUsagePageKey));
    2.12          if (refCF) {
    2.13 -            if (!CFNumberGetValue(refCF, kCFNumberLongType,
    2.14 -                                  &item->usagePage))
    2.15 -                SDL_SetError
    2.16 -                ("Haptic: Recieving device's usage page.");
    2.17 -            refCF =
    2.18 -            CFDictionaryGetValue(hidProperties,
    2.19 -                                 CFSTR(kIOHIDPrimaryUsageKey));
    2.20 +            if (!CFNumberGetValue(refCF, kCFNumberLongType, &item->usagePage)) {
    2.21 +                SDL_SetError("Haptic: Recieving device's usage page.");
    2.22 +            }
    2.23 +            refCF = CFDictionaryGetValue(hidProperties,
    2.24 +                                         CFSTR(kIOHIDPrimaryUsageKey));
    2.25              if (refCF) {
    2.26 -                if (!CFNumberGetValue(refCF, kCFNumberLongType,
    2.27 -                                      &item->usage))
    2.28 +                if (!CFNumberGetValue(refCF, kCFNumberLongType, &item->usage)) {
    2.29                      SDL_SetError("Haptic: Recieving device's usage.");
    2.30 +                }
    2.31              }
    2.32          }
    2.33          CFRelease(hidProperties);
    2.34 @@ -377,24 +374,21 @@
    2.35  
    2.36  
    2.37              /* Get product name */
    2.38 -            refCF =
    2.39 -                CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey));
    2.40 -            if (!refCF)
    2.41 -                refCF =
    2.42 -                    CFDictionaryGetValue(usbProperties,
    2.43 -                                         CFSTR("USB Product Name"));
    2.44 +            refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey));
    2.45 +            if (!refCF) {
    2.46 +                refCF = CFDictionaryGetValue(usbProperties,
    2.47 +                                             CFSTR("USB Product Name"));
    2.48 +            }
    2.49              if (refCF) {
    2.50                  if (!CFStringGetCString(refCF, name, 256,
    2.51                                          CFStringGetSystemEncoding())) {
    2.52 -                    return SDL_SetError
    2.53 -                        ("Haptic: CFStringGetCString error retrieving pDevice->product.");
    2.54 +                    return SDL_SetError("Haptic: CFStringGetCString error retrieving pDevice->product.");
    2.55                  }
    2.56              }
    2.57  
    2.58              CFRelease(usbProperties);
    2.59          } else {
    2.60 -            return SDL_SetError
    2.61 -                ("Haptic: IORegistryEntryCreateCFProperties failed to create usbProperties.");
    2.62 +            return SDL_SetError("Haptic: IORegistryEntryCreateCFProperties failed to create usbProperties.");
    2.63          }
    2.64  
    2.65          /* Release stuff. */
    2.66 @@ -457,9 +451,9 @@
    2.67      /* Check if supports gain. */
    2.68      ret = FFDeviceGetForceFeedbackProperty(device, FFPROP_FFGAIN,
    2.69                                             &val, sizeof(val));
    2.70 -    if (ret == FF_OK)
    2.71 +    if (ret == FF_OK) {
    2.72          supported |= SDL_HAPTIC_GAIN;
    2.73 -    else if (ret != FFERR_UNSUPPORTED) {
    2.74 +    } else if (ret != FFERR_UNSUPPORTED) {
    2.75          return SDL_SetError("Haptic: Unable to get if device supports gain: %s.",
    2.76                              FFStrError(ret));
    2.77      }
    2.78 @@ -467,9 +461,9 @@
    2.79      /* Checks if supports autocenter. */
    2.80      ret = FFDeviceGetForceFeedbackProperty(device, FFPROP_AUTOCENTER,
    2.81                                             &val, sizeof(val));
    2.82 -    if (ret == FF_OK)
    2.83 +    if (ret == FF_OK) {
    2.84          supported |= SDL_HAPTIC_AUTOCENTER;
    2.85 -    else if (ret != FFERR_UNSUPPORTED) {
    2.86 +    } else if (ret != FFERR_UNSUPPORTED) {
    2.87          return SDL_SetError
    2.88              ("Haptic: Unable to get if device supports autocenter: %s.",
    2.89               FFStrError(ret));
    2.90 @@ -604,8 +598,9 @@
    2.91  int
    2.92  SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
    2.93  {
    2.94 -    if (joystick->hwdata->ffservice != 0)
    2.95 +    if (joystick->hwdata->ffservice != 0) {
    2.96          return SDL_TRUE;
    2.97 +    }
    2.98      return SDL_FALSE;
    2.99  }
   2.100  
   2.101 @@ -617,8 +612,9 @@
   2.102  SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
   2.103  {
   2.104      if (IOObjectIsEqualTo((io_object_t) ((size_t)haptic->hwdata->device),
   2.105 -                          joystick->hwdata->ffservice))
   2.106 +                          joystick->hwdata->ffservice)) {
   2.107          return 1;
   2.108 +    }
   2.109      return 0;
   2.110  }
   2.111  
   2.112 @@ -739,18 +735,22 @@
   2.113      case SDL_HAPTIC_CARTESIAN:
   2.114          effect->dwFlags |= FFEFF_CARTESIAN;
   2.115          rglDir[0] = dir->dir[0];
   2.116 -        if (naxes > 1)
   2.117 +        if (naxes > 1) {
   2.118              rglDir[1] = dir->dir[1];
   2.119 -        if (naxes > 2)
   2.120 +        }
   2.121 +        if (naxes > 2) {
   2.122              rglDir[2] = dir->dir[2];
   2.123 +        }
   2.124          return 0;
   2.125      case SDL_HAPTIC_SPHERICAL:
   2.126          effect->dwFlags |= FFEFF_SPHERICAL;
   2.127          rglDir[0] = dir->dir[0];
   2.128 -        if (naxes > 1)
   2.129 +        if (naxes > 1) {
   2.130              rglDir[1] = dir->dir[1];
   2.131 -        if (naxes > 2)
   2.132 +        }
   2.133 +        if (naxes > 2) {
   2.134              rglDir[2] = dir->dir[2];
   2.135 +        }
   2.136          return 0;
   2.137  
   2.138      default:
   2.139 @@ -767,8 +767,7 @@
   2.140   * Creates the FFEFFECT from a SDL_HapticEffect.
   2.141   */
   2.142  static int
   2.143 -SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest,
   2.144 -                   SDL_HapticEffect * src)
   2.145 +SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src)
   2.146  {
   2.147      int i;
   2.148      FFCONSTANTFORCE *constant;
   2.149 @@ -1269,8 +1268,7 @@
   2.150  {
   2.151      HRESULT ret;
   2.152  
   2.153 -    ret =
   2.154 -        FFDeviceReleaseEffect(haptic->hwdata->device, effect->hweffect->ref);
   2.155 +    ret = FFDeviceReleaseEffect(haptic->hwdata->device, effect->hweffect->ref);
   2.156      if (ret != FF_OK) {
   2.157          SDL_SetError("Haptic: Error removing the effect from the device: %s.",
   2.158                       FFStrError(ret));
   2.159 @@ -1299,8 +1297,9 @@
   2.160          return -1;
   2.161      }
   2.162  
   2.163 -    if (status == 0)
   2.164 +    if (status == 0) {
   2.165          return SDL_FALSE;
   2.166 +    }
   2.167      return SDL_TRUE;            /* Assume it's playing or emulated. */
   2.168  }
   2.169  
   2.170 @@ -1315,9 +1314,8 @@
   2.171      Uint32 val;
   2.172  
   2.173      val = gain * 100;           /* Mac OS X uses 0 to 10,000 */
   2.174 -    ret =
   2.175 -        FFDeviceSetForceFeedbackProperty(haptic->hwdata->device,
   2.176 -                                         FFPROP_FFGAIN, &val);
   2.177 +    ret = FFDeviceSetForceFeedbackProperty(haptic->hwdata->device,
   2.178 +                                           FFPROP_FFGAIN, &val);
   2.179      if (ret != FF_OK) {
   2.180          return SDL_SetError("Haptic: Error setting gain: %s.", FFStrError(ret));
   2.181      }
   2.182 @@ -1336,10 +1334,11 @@
   2.183      Uint32 val;
   2.184  
   2.185      /* Mac OS X only has 0 (off) and 1 (on) */
   2.186 -    if (autocenter == 0)
   2.187 +    if (autocenter == 0) {
   2.188          val = 0;
   2.189 -    else
   2.190 +    } else {
   2.191          val = 1;
   2.192 +    }
   2.193  
   2.194      ret = FFDeviceSetForceFeedbackProperty(haptic->hwdata->device,
   2.195                                             FFPROP_AUTOCENTER, &val);
     3.1 --- a/src/joystick/darwin/SDL_sysjoystick.c	Mon Jul 07 11:44:14 2014 -0700
     3.2 +++ b/src/joystick/darwin/SDL_sysjoystick.c	Mon Jul 07 12:48:25 2014 -0700
     3.3 @@ -406,17 +406,13 @@
     3.4      s_bDeviceAdded = SDL_TRUE;
     3.5  
     3.6      /* Add device to the end of the list */
     3.7 -    if ( !gpDeviceList )
     3.8 -    {
     3.9 +    if ( !gpDeviceList ) {
    3.10          gpDeviceList = device;
    3.11 -    }
    3.12 -    else
    3.13 -    {
    3.14 +    } else {
    3.15          recDevice *curdevice;
    3.16  
    3.17          curdevice = gpDeviceList;
    3.18 -        while ( curdevice->pNext )
    3.19 -        {
    3.20 +        while ( curdevice->pNext ) {
    3.21              curdevice = curdevice->pNext;
    3.22          }
    3.23          curdevice->pNext = device;
     4.1 --- a/src/video/cocoa/SDL_cocoaclipboard.m	Mon Jul 07 11:44:14 2014 -0700
     4.2 +++ b/src/video/cocoa/SDL_cocoaclipboard.m	Mon Jul 07 12:48:25 2014 -0700
     4.3 @@ -28,9 +28,7 @@
     4.4  static NSString *
     4.5  GetTextFormat(_THIS)
     4.6  {
     4.7 -    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
     4.8 -
     4.9 -    if (data->osversion >= 0x1060) {
    4.10 +    if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) {
    4.11          return NSPasteboardTypeString;
    4.12      } else {
    4.13          return NSStringPboardType;
    4.14 @@ -96,7 +94,7 @@
    4.15      char *text = Cocoa_GetClipboardText(_this);
    4.16      if (text) {
    4.17          result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE;
    4.18 -    SDL_free(text);
    4.19 +        SDL_free(text);
    4.20      }
    4.21      return result;
    4.22  }
     5.1 --- a/src/video/cocoa/SDL_cocoaevents.m	Mon Jul 07 11:44:14 2014 -0700
     5.2 +++ b/src/video/cocoa/SDL_cocoaevents.m	Mon Jul 07 12:48:25 2014 -0700
     5.3 @@ -27,16 +27,6 @@
     5.4  #include "../../events/SDL_events_c.h"
     5.5  #include "SDL_assert.h"
     5.6  
     5.7 -#if !defined(UsrActivity) && defined(__LP64__) && !defined(__POWER__)
     5.8 -/*
     5.9 - * Workaround for a bug in the 10.5 SDK: By accident, OSService.h does
    5.10 - * not include Power.h at all when compiling in 64bit mode. This has
    5.11 - * been fixed in 10.6, but for 10.5, we manually define UsrActivity
    5.12 - * to ensure compilation works.
    5.13 - */
    5.14 -#define UsrActivity 1
    5.15 -#endif
    5.16 -
    5.17  @interface SDLApplication : NSApplication
    5.18  
    5.19  - (void)terminate:(id)sender;
    5.20 @@ -58,7 +48,7 @@
    5.21  - (void)setAppleMenu:(NSMenu *)menu;
    5.22  @end
    5.23  
    5.24 -@interface SDLAppDelegate : NSObject {
    5.25 +@interface SDLAppDelegate : NSObject <NSApplicationDelegate> {
    5.26  @public
    5.27      BOOL seenFirstActivate;
    5.28  }
    5.29 @@ -70,7 +60,6 @@
    5.30  - (id)init
    5.31  {
    5.32      self = [super init];
    5.33 -
    5.34      if (self) {
    5.35          seenFirstActivate = NO;
    5.36          [[NSNotificationCenter defaultCenter] addObserver:self
    5.37 @@ -101,15 +90,12 @@
    5.38      }
    5.39  
    5.40      SDL_VideoDevice *device = SDL_GetVideoDevice();
    5.41 -    if (device && device->windows)
    5.42 -    {
    5.43 +    if (device && device->windows) {
    5.44          SDL_Window *window = device->windows;
    5.45          int i;
    5.46 -        for (i = 0; i < device->num_displays; ++i)
    5.47 -        {
    5.48 +        for (i = 0; i < device->num_displays; ++i) {
    5.49              SDL_Window *fullscreen_window = device->displays[i].fullscreen_window;
    5.50 -            if (fullscreen_window)
    5.51 -            {
    5.52 +            if (fullscreen_window) {
    5.53                  if (fullscreen_window->flags & SDL_WINDOW_MINIMIZED) {
    5.54                      SDL_RestoreWindow(fullscreen_window);
    5.55                  }
    5.56 @@ -140,11 +126,13 @@
    5.57  
    5.58      /* Determine the application name */
    5.59      appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
    5.60 -    if (!appName)
    5.61 +    if (!appName) {
    5.62          appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"];
    5.63 +    }
    5.64  
    5.65 -    if (![appName length])
    5.66 +    if (![appName length]) {
    5.67          appName = [[NSProcessInfo processInfo] processName];
    5.68 +    }
    5.69  
    5.70      return appName;
    5.71  }
    5.72 @@ -294,7 +282,7 @@
    5.73           * termination into SDL_Quit, and we can't handle application:openFile:
    5.74           */
    5.75          if (![NSApp delegate]) {
    5.76 -            [NSApp setDelegate:appDelegate];
    5.77 +            [(NSApplication *)NSApp setDelegate:appDelegate];
    5.78          } else {
    5.79              appDelegate->seenFirstActivate = YES;
    5.80          }
     6.1 --- a/src/video/cocoa/SDL_cocoakeyboard.m	Mon Jul 07 11:44:14 2014 -0700
     6.2 +++ b/src/video/cocoa/SDL_cocoakeyboard.m	Mon Jul 07 12:48:25 2014 -0700
     6.3 @@ -32,33 +32,7 @@
     6.4  /*#define DEBUG_IME NSLog */
     6.5  #define DEBUG_IME(...)
     6.6  
     6.7 -#ifndef NX_DEVICERCTLKEYMASK
     6.8 -    #define NX_DEVICELCTLKEYMASK    0x00000001
     6.9 -#endif
    6.10 -#ifndef NX_DEVICELSHIFTKEYMASK
    6.11 -    #define NX_DEVICELSHIFTKEYMASK  0x00000002
    6.12 -#endif
    6.13 -#ifndef NX_DEVICERSHIFTKEYMASK
    6.14 -    #define NX_DEVICERSHIFTKEYMASK  0x00000004
    6.15 -#endif
    6.16 -#ifndef NX_DEVICELCMDKEYMASK
    6.17 -    #define NX_DEVICELCMDKEYMASK    0x00000008
    6.18 -#endif
    6.19 -#ifndef NX_DEVICERCMDKEYMASK
    6.20 -    #define NX_DEVICERCMDKEYMASK    0x00000010
    6.21 -#endif
    6.22 -#ifndef NX_DEVICELALTKEYMASK
    6.23 -    #define NX_DEVICELALTKEYMASK    0x00000020
    6.24 -#endif
    6.25 -#ifndef NX_DEVICERALTKEYMASK
    6.26 -    #define NX_DEVICERALTKEYMASK    0x00000040
    6.27 -#endif
    6.28 -#ifndef NX_DEVICERCTLKEYMASK
    6.29 -    #define NX_DEVICERCTLKEYMASK    0x00002000
    6.30 -#endif
    6.31 -
    6.32 -@interface SDLTranslatorResponder : NSView <NSTextInput>
    6.33 -{
    6.34 +@interface SDLTranslatorResponder : NSView <NSTextInput> {
    6.35      NSString *_markedText;
    6.36      NSRange   _markedRange;
    6.37      NSRange   _selectedRange;
    6.38 @@ -83,10 +57,11 @@
    6.39  
    6.40      /* Could be NSString or NSAttributedString, so we have
    6.41       * to test and convert it before return as SDL event */
    6.42 -    if ([aString isKindOfClass: [NSAttributedString class]])
    6.43 +    if ([aString isKindOfClass: [NSAttributedString class]]) {
    6.44          str = [[aString string] UTF8String];
    6.45 -    else
    6.46 +    } else {
    6.47          str = [aString UTF8String];
    6.48 +    }
    6.49  
    6.50      SDL_SendKeyboardText(str);
    6.51  }
    6.52 @@ -117,17 +92,16 @@
    6.53  - (void) setMarkedText:(id) aString
    6.54           selectedRange:(NSRange) selRange
    6.55  {
    6.56 -    if ([aString isKindOfClass: [NSAttributedString class]])
    6.57 +    if ([aString isKindOfClass: [NSAttributedString class]]) {
    6.58          aString = [aString string];
    6.59 +    }
    6.60  
    6.61 -    if ([aString length] == 0)
    6.62 -    {
    6.63 +    if ([aString length] == 0) {
    6.64          [self unmarkText];
    6.65          return;
    6.66      }
    6.67  
    6.68 -    if (_markedText != aString)
    6.69 -    {
    6.70 +    if (_markedText != aString) {
    6.71          [_markedText release];
    6.72          _markedText = [aString retain];
    6.73      }
    6.74 @@ -443,10 +417,11 @@
    6.75  
    6.76      /* Try Unicode data first */
    6.77      CFDataRef uchrDataRef = TISGetInputSourceProperty(key_layout, kTISPropertyUnicodeKeyLayoutData);
    6.78 -    if (uchrDataRef)
    6.79 +    if (uchrDataRef) {
    6.80          chr_data = CFDataGetBytePtr(uchrDataRef);
    6.81 -    else
    6.82 +    } else {
    6.83          goto cleanup;
    6.84 +    }
    6.85  
    6.86      if (chr_data) {
    6.87          UInt32 keyboard_type = LMGetKbdType();
    6.88 @@ -470,8 +445,9 @@
    6.89                                    0, keyboard_type,
    6.90                                    kUCKeyTranslateNoDeadKeysMask,
    6.91                                    &dead_key_state, 8, &len, s);
    6.92 -            if (err != noErr)
    6.93 +            if (err != noErr) {
    6.94                  continue;
    6.95 +            }
    6.96  
    6.97              if (len > 0 && s[0] != 0x10) {
    6.98                  keymap[scancode] = s[0];
    6.99 @@ -508,8 +484,9 @@
   6.100      NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   6.101      SDL_Window *window = SDL_GetKeyboardFocus();
   6.102      NSWindow *nswindow = nil;
   6.103 -    if (window)
   6.104 +    if (window) {
   6.105          nswindow = ((SDL_WindowData*)window->driverdata)->nswindow;
   6.106 +    }
   6.107  
   6.108      NSView *parentView = [nswindow contentView];
   6.109  
   6.110 @@ -523,8 +500,7 @@
   6.111              [[SDLTranslatorResponder alloc] initWithFrame: NSMakeRect(0.0, 0.0, 0.0, 0.0)];
   6.112      }
   6.113  
   6.114 -    if (![[data->fieldEdit superview] isEqual: parentView])
   6.115 -    {
   6.116 +    if (![[data->fieldEdit superview] isEqual: parentView]) {
   6.117          /* DEBUG_IME(@"add fieldEdit to window contentView"); */
   6.118          [data->fieldEdit removeFromSuperview];
   6.119          [parentView addSubview: data->fieldEdit];
   6.120 @@ -554,8 +530,8 @@
   6.121      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   6.122  
   6.123      if (!rect) {
   6.124 -    SDL_InvalidParamError("rect");
   6.125 -    return;
   6.126 +        SDL_InvalidParamError("rect");
   6.127 +        return;
   6.128      }
   6.129  
   6.130      [data->fieldEdit setInputRect: rect];
   6.131 @@ -579,10 +555,10 @@
   6.132          /* see comments in SDL_cocoakeys.h */
   6.133          scancode = 60 - scancode;
   6.134      }
   6.135 +
   6.136      if (scancode < SDL_arraysize(darwin_scancode_table)) {
   6.137          code = darwin_scancode_table[scancode];
   6.138 -    }
   6.139 -    else {
   6.140 +    } else {
   6.141          /* Hmm, does this ever happen?  If so, need to extend the keymap... */
   6.142          code = SDL_SCANCODE_UNKNOWN;
   6.143      }
     7.1 --- a/src/video/cocoa/SDL_cocoamessagebox.m	Mon Jul 07 11:44:14 2014 -0700
     7.2 +++ b/src/video/cocoa/SDL_cocoamessagebox.m	Mon Jul 07 12:48:25 2014 -0700
     7.3 @@ -22,13 +22,6 @@
     7.4  
     7.5  #if SDL_VIDEO_DRIVER_COCOA
     7.6  
     7.7 -#if defined(__APPLE__) && defined(__POWERPC__) && !defined(__APPLE_ALTIVEC__)
     7.8 -#include <altivec.h>
     7.9 -#undef bool
    7.10 -#undef vector
    7.11 -#undef pixel
    7.12 -#endif
    7.13 -
    7.14  #include "SDL_events.h"
    7.15  #include "SDL_timer.h"
    7.16  #include "SDL_messagebox.h"
    7.17 @@ -125,13 +118,10 @@
    7.18  
    7.19      int returnValue = 0;
    7.20      NSInteger clicked = presenter->clicked;
    7.21 -    if (clicked >= NSAlertFirstButtonReturn)
    7.22 -    {
    7.23 +    if (clicked >= NSAlertFirstButtonReturn) {
    7.24          clicked -= NSAlertFirstButtonReturn;
    7.25          *buttonid = buttons[clicked].buttonid;
    7.26 -    }
    7.27 -    else
    7.28 -    {
    7.29 +    } else {
    7.30          returnValue = SDL_SetError("Did not get a valid `clicked button' id: %ld", (long)clicked);
    7.31      }
    7.32  
     8.1 --- a/src/video/cocoa/SDL_cocoamodes.m	Mon Jul 07 11:44:14 2014 -0700
     8.2 +++ b/src/video/cocoa/SDL_cocoamodes.m	Mon Jul 07 12:48:25 2014 -0700
     8.3 @@ -43,10 +43,11 @@
     8.4       *  we can just simply do without it on newer OSes...
     8.5       */
     8.6  #if (MAC_OS_X_VERSION_MIN_REQUIRED < 1070) && !defined(__LP64__)
     8.7 -    if (show)
     8.8 +    if (show) {
     8.9          ShowMenuBar();
    8.10 -    else
    8.11 +    } else {
    8.12          HideMenuBar();
    8.13 +    }
    8.14  #endif
    8.15  }
    8.16  
    8.17 @@ -60,12 +61,12 @@
    8.18  #endif
    8.19  
    8.20  static BOOL
    8.21 -IS_SNOW_LEOPARD_OR_LATER(_THIS)
    8.22 +IS_SNOW_LEOPARD_OR_LATER()
    8.23  {
    8.24  #if FORCE_OLD_API
    8.25      return NO;
    8.26  #else
    8.27 -    return ((((SDL_VideoData *) _this->driverdata))->osversion >= 0x1060);
    8.28 +    return floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5;
    8.29  #endif
    8.30  }
    8.31  
    8.32 @@ -127,7 +128,7 @@
    8.33      }
    8.34      data->moderef = moderef;
    8.35  
    8.36 -    if (IS_SNOW_LEOPARD_OR_LATER(_this)) {
    8.37 +    if (IS_SNOW_LEOPARD_OR_LATER()) {
    8.38          CGDisplayModeRef vidmode = (CGDisplayModeRef) moderef;
    8.39          CFStringRef fmt = CGDisplayModeCopyPixelEncoding(vidmode);
    8.40          width = (long) CGDisplayModeGetWidth(vidmode);
    8.41 @@ -148,7 +149,7 @@
    8.42      }
    8.43  
    8.44      #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
    8.45 -    if (!IS_SNOW_LEOPARD_OR_LATER(_this)) {
    8.46 +    if (!IS_SNOW_LEOPARD_OR_LATER()) {
    8.47          CFNumberRef number;
    8.48          CFDictionaryRef vidmode = (CFDictionaryRef) moderef;
    8.49          number = CFDictionaryGetValue(vidmode, kCGDisplayWidth);
    8.50 @@ -184,7 +185,7 @@
    8.51  static void
    8.52  Cocoa_ReleaseDisplayMode(_THIS, const void *moderef)
    8.53  {
    8.54 -    if (IS_SNOW_LEOPARD_OR_LATER(_this)) {
    8.55 +    if (IS_SNOW_LEOPARD_OR_LATER()) {
    8.56          CGDisplayModeRelease((CGDisplayModeRef) moderef);  /* NULL is ok */
    8.57      }
    8.58  }
    8.59 @@ -192,7 +193,7 @@
    8.60  static void
    8.61  Cocoa_ReleaseDisplayModeList(_THIS, CFArrayRef modelist)
    8.62  {
    8.63 -    if (IS_SNOW_LEOPARD_OR_LATER(_this)) {
    8.64 +    if (IS_SNOW_LEOPARD_OR_LATER()) {
    8.65          CFRelease(modelist);  /* NULL is ok */
    8.66      }
    8.67  }
    8.68 @@ -257,12 +258,12 @@
    8.69                  continue;
    8.70              }
    8.71  
    8.72 -            if (IS_SNOW_LEOPARD_OR_LATER(_this)) {
    8.73 +            if (IS_SNOW_LEOPARD_OR_LATER()) {
    8.74                  moderef = CGDisplayCopyDisplayMode(displays[i]);
    8.75              }
    8.76  
    8.77              #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
    8.78 -            if (!IS_SNOW_LEOPARD_OR_LATER(_this)) {
    8.79 +            if (!IS_SNOW_LEOPARD_OR_LATER()) {
    8.80                  moderef = CGDisplayCurrentMode(displays[i]);
    8.81              }
    8.82              #endif
    8.83 @@ -319,12 +320,12 @@
    8.84      SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
    8.85      CFArrayRef modes = NULL;
    8.86  
    8.87 -    if (IS_SNOW_LEOPARD_OR_LATER(_this)) {
    8.88 +    if (IS_SNOW_LEOPARD_OR_LATER()) {
    8.89          modes = CGDisplayCopyAllDisplayModes(data->display, NULL);
    8.90      }
    8.91  
    8.92      #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
    8.93 -    if (!IS_SNOW_LEOPARD_OR_LATER(_this)) {
    8.94 +    if (!IS_SNOW_LEOPARD_OR_LATER()) {
    8.95          modes = CGDisplayAvailableModes(data->display);
    8.96      }
    8.97      #endif
    8.98 @@ -337,7 +338,7 @@
    8.99              const void *moderef = CFArrayGetValueAtIndex(modes, i);
   8.100              SDL_DisplayMode mode;
   8.101              if (GetDisplayMode(_this, moderef, &mode)) {
   8.102 -                if (IS_SNOW_LEOPARD_OR_LATER(_this)) {
   8.103 +                if (IS_SNOW_LEOPARD_OR_LATER()) {
   8.104                      CGDisplayModeRetain((CGDisplayModeRef) moderef);
   8.105                  }
   8.106                  SDL_AddDisplayMode(display, &mode);
   8.107 @@ -351,12 +352,12 @@
   8.108  static CGError
   8.109  Cocoa_SwitchMode(_THIS, CGDirectDisplayID display, const void *mode)
   8.110  {
   8.111 -    if (IS_SNOW_LEOPARD_OR_LATER(_this)) {
   8.112 +    if (IS_SNOW_LEOPARD_OR_LATER()) {
   8.113          return CGDisplaySetDisplayMode(display, (CGDisplayModeRef) mode, NULL);
   8.114      }
   8.115   
   8.116      #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
   8.117 -    if (!IS_SNOW_LEOPARD_OR_LATER(_this)) {
   8.118 +    if (!IS_SNOW_LEOPARD_OR_LATER()) {
   8.119          return CGDisplaySwitchToMode(display, (CFDictionaryRef) mode);
   8.120      }
   8.121      #endif
     9.1 --- a/src/video/cocoa/SDL_cocoamouse.m	Mon Jul 07 11:44:14 2014 -0700
     9.2 +++ b/src/video/cocoa/SDL_cocoamouse.m	Mon Jul 07 12:48:25 2014 -0700
     9.3 @@ -120,8 +120,7 @@
     9.4      NSCursor *nscursor = NULL;
     9.5      SDL_Cursor *cursor = NULL;
     9.6  
     9.7 -    switch(id)
     9.8 -    {
     9.9 +    switch(id) {
    9.10      case SDL_SYSTEM_CURSOR_ARROW:
    9.11          nscursor = [NSCursor arrowCursor];
    9.12          break;
    9.13 @@ -212,8 +211,7 @@
    9.14  Cocoa_WarpMouse(SDL_Window * window, int x, int y)
    9.15  {
    9.16      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    9.17 -    if ([data->listener isMoving])
    9.18 -    {
    9.19 +    if ([data->listener isMoving]) {
    9.20          DLog("Postponing warp, window being moved.");
    9.21          [data->listener setPendingMoveX:x
    9.22                                        Y:y];
    9.23 @@ -370,8 +368,7 @@
    9.24  void
    9.25  Cocoa_HandleMouseEvent(_THIS, NSEvent *event)
    9.26  {
    9.27 -    switch ([event type])
    9.28 -    {
    9.29 +    switch ([event type]) {
    9.30          case NSMouseMoved:
    9.31          case NSLeftMouseDragged:
    9.32          case NSRightMouseDragged:
    9.33 @@ -415,8 +412,7 @@
    9.34      float deltaX = [event deltaX];
    9.35      float deltaY = [event deltaY];
    9.36  
    9.37 -    if (seenWarp)
    9.38 -    {
    9.39 +    if (seenWarp) {
    9.40          deltaX += (lastMoveX - driverdata->lastWarpX);
    9.41          deltaY += ((CGDisplayPixelsHigh(kCGDirectMainDisplay) - lastMoveY) - driverdata->lastWarpY);
    9.42  
    10.1 --- a/src/video/cocoa/SDL_cocoamousetap.m	Mon Jul 07 11:44:14 2014 -0700
    10.2 +++ b/src/video/cocoa/SDL_cocoamousetap.m	Mon Jul 07 12:48:25 2014 -0700
    10.3 @@ -67,8 +67,7 @@
    10.4      NSRect windowRect;
    10.5      CGPoint eventLocation;
    10.6  
    10.7 -    switch (type)
    10.8 -    {
    10.9 +    switch (type) {
   10.10          case kCGEventTapDisabledByTimeout:
   10.11          case kCGEventTapDisabledByUserInput:
   10.12              {
    11.1 --- a/src/video/cocoa/SDL_cocoaopengl.m	Mon Jul 07 11:44:14 2014 -0700
    11.2 +++ b/src/video/cocoa/SDL_cocoaopengl.m	Mon Jul 07 12:48:25 2014 -0700
    11.3 @@ -35,16 +35,6 @@
    11.4  
    11.5  #define DEFAULT_OPENGL  "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"
    11.6  
    11.7 -#ifndef NSOpenGLPFAOpenGLProfile
    11.8 -#define NSOpenGLPFAOpenGLProfile 99
    11.9 -#endif
   11.10 -#ifndef NSOpenGLProfileVersionLegacy
   11.11 -#define NSOpenGLProfileVersionLegacy 0x1000
   11.12 -#endif
   11.13 -#ifndef NSOpenGLProfileVersion3_2Core
   11.14 -#define NSOpenGLProfileVersion3_2Core 0x3200
   11.15 -#endif
   11.16 -
   11.17  @implementation SDLOpenGLContext : NSOpenGLContext
   11.18  
   11.19  - (id)initWithFormat:(NSOpenGLPixelFormat *)format
   11.20 @@ -161,10 +151,10 @@
   11.21  SDL_GLContext
   11.22  Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
   11.23  {
   11.24 -    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   11.25      NSAutoreleasePool *pool;
   11.26      SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
   11.27      SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
   11.28 +    SDL_bool lion_or_later = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6;
   11.29      NSOpenGLPixelFormatAttribute attr[32];
   11.30      NSOpenGLPixelFormat *fmt;
   11.31      SDLOpenGLContext *context;
   11.32 @@ -178,7 +168,7 @@
   11.33          SDL_SetError ("OpenGL ES is not supported on this platform");
   11.34          return NULL;
   11.35      }
   11.36 -    if ((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) && (data->osversion < 0x1070)) {
   11.37 +    if ((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) && !lion_or_later) {
   11.38          SDL_SetError ("OpenGL Core Profile is not supported on this platform version");
   11.39          return NULL;
   11.40      }
   11.41 @@ -186,7 +176,7 @@
   11.42      pool = [[NSAutoreleasePool alloc] init];
   11.43  
   11.44      /* specify a profile if we're on Lion (10.7) or later. */
   11.45 -    if (data->osversion >= 0x1070) {
   11.46 +    if (lion_or_later) {
   11.47          NSOpenGLPixelFormatAttribute profile = NSOpenGLProfileVersionLegacy;
   11.48          if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) {
   11.49              profile = NSOpenGLProfileVersion3_2Core;
    12.1 --- a/src/video/cocoa/SDL_cocoashape.m	Mon Jul 07 11:44:14 2014 -0700
    12.2 +++ b/src/video/cocoa/SDL_cocoashape.m	Mon Jul 07 12:48:25 2014 -0700
    12.3 @@ -30,7 +30,8 @@
    12.4  #include "SDL_assert.h"
    12.5  
    12.6  SDL_WindowShaper*
    12.7 -Cocoa_CreateShaper(SDL_Window* window) {
    12.8 +Cocoa_CreateShaper(SDL_Window* window)
    12.9 +{
   12.10      SDL_WindowData* windata = (SDL_WindowData*)window->driverdata;
   12.11      [windata->nswindow setOpaque:NO];
   12.12  
   12.13 @@ -63,7 +64,8 @@
   12.14  } SDL_CocoaClosure;
   12.15  
   12.16  void
   12.17 -ConvertRects(SDL_ShapeTree* tree,void* closure) {
   12.18 +ConvertRects(SDL_ShapeTree* tree, void* closure)
   12.19 +{
   12.20      SDL_CocoaClosure* data = (SDL_CocoaClosure*)closure;
   12.21      if(tree->kind == OpaqueShape) {
   12.22          NSRect rect = NSMakeRect(tree->data.shape.x,data->window->h - tree->data.shape.y,tree->data.shape.w,tree->data.shape.h);
   12.23 @@ -72,7 +74,8 @@
   12.24  }
   12.25  
   12.26  int
   12.27 -Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) {
   12.28 +Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode)
   12.29 +{
   12.30      SDL_ShapeData* data = (SDL_ShapeData*)shaper->driverdata;
   12.31      SDL_WindowData* windata = (SDL_WindowData*)shaper->window->driverdata;
   12.32      SDL_CocoaClosure closure;
   12.33 @@ -102,7 +105,8 @@
   12.34  }
   12.35  
   12.36  int
   12.37 -Cocoa_ResizeWindowShape(SDL_Window *window) {
   12.38 +Cocoa_ResizeWindowShape(SDL_Window *window)
   12.39 +{
   12.40      SDL_ShapeData* data = window->shaper->driverdata;
   12.41      SDL_assert(data != NULL);
   12.42      return 0;
    13.1 --- a/src/video/cocoa/SDL_cocoavideo.h	Mon Jul 07 11:44:14 2014 -0700
    13.2 +++ b/src/video/cocoa/SDL_cocoavideo.h	Mon Jul 07 12:48:25 2014 -0700
    13.3 @@ -45,7 +45,6 @@
    13.4  
    13.5  typedef struct SDL_VideoData
    13.6  {
    13.7 -    SInt32 osversion;
    13.8      int allow_spaces;
    13.9      unsigned int modifierFlags;
   13.10      void *key_layout;
    14.1 --- a/src/video/cocoa/SDL_cocoavideo.m	Mon Jul 07 11:44:14 2014 -0700
    14.2 +++ b/src/video/cocoa/SDL_cocoavideo.m	Mon Jul 07 12:48:25 2014 -0700
    14.3 @@ -22,13 +22,6 @@
    14.4  
    14.5  #if SDL_VIDEO_DRIVER_COCOA
    14.6  
    14.7 -#if defined(__APPLE__) && defined(__POWERPC__) && !defined(__APPLE_ALTIVEC__)
    14.8 -#include <altivec.h>
    14.9 -#undef bool
   14.10 -#undef vector
   14.11 -#undef pixel
   14.12 -#endif
   14.13 -
   14.14  #include "SDL.h"
   14.15  #include "SDL_endian.h"
   14.16  #include "SDL_cocoavideo.h"
   14.17 @@ -76,9 +69,6 @@
   14.18      }
   14.19      device->driverdata = data;
   14.20  
   14.21 -    /* Find out what version of Mac OS X we're running */
   14.22 -    Gestalt(gestaltSystemVersion, &data->osversion);
   14.23 -
   14.24      /* Set the function pointers */
   14.25      device->VideoInit = Cocoa_VideoInit;
   14.26      device->VideoQuit = Cocoa_VideoQuit;
   14.27 @@ -156,7 +146,7 @@
   14.28      Cocoa_InitMouse(_this);
   14.29  
   14.30      const char *hint = SDL_GetHint(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES);
   14.31 -    data->allow_spaces = ( (data->osversion >= 0x1070) && (!hint || (*hint != '0')) );
   14.32 +    data->allow_spaces = ( (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) && (!hint || (*hint != '0')) );
   14.33  
   14.34      return 0;
   14.35  }
    15.1 --- a/src/video/cocoa/SDL_cocoawindow.h	Mon Jul 07 11:44:14 2014 -0700
    15.2 +++ b/src/video/cocoa/SDL_cocoawindow.h	Mon Jul 07 12:48:25 2014 -0700
    15.3 @@ -97,13 +97,7 @@
    15.4  -(void) touchesCancelledWithEvent:(NSEvent *) theEvent;
    15.5  
    15.6  /* Touch event handling */
    15.7 -typedef enum {
    15.8 -    COCOA_TOUCH_DOWN,
    15.9 -    COCOA_TOUCH_UP,
   15.10 -    COCOA_TOUCH_MOVE,
   15.11 -    COCOA_TOUCH_CANCELLED
   15.12 -} cocoaTouchType;
   15.13 --(void) handleTouches:(cocoaTouchType)type withEvent:(NSEvent*) event;
   15.14 +-(void) handleTouches:(NSTouchPhase) phase withEvent:(NSEvent*) theEvent;
   15.15  
   15.16  @end
   15.17  /* *INDENT-ON* */
    16.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Mon Jul 07 11:44:14 2014 -0700
    16.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Mon Jul 07 12:48:25 2014 -0700
    16.3 @@ -362,8 +362,7 @@
    16.4         !!! FIXME:   http://bugzilla.libsdl.org/show_bug.cgi?id=1825
    16.5      */
    16.6      windows = [NSApp orderedWindows];
    16.7 -    for (NSWindow *win in windows)
    16.8 -    {
    16.9 +    for (NSWindow *win in windows) {
   16.10          if (win == window) {
   16.11              continue;
   16.12          }
   16.13 @@ -386,8 +385,7 @@
   16.14  
   16.15  - (void)windowDidFinishMoving
   16.16  {
   16.17 -    if ([self isMoving])
   16.18 -    {
   16.19 +    if ([self isMoving]) {
   16.20          isMoving = NO;
   16.21  
   16.22          SDL_Mouse *mouse = SDL_GetMouse();
   16.23 @@ -859,48 +857,29 @@
   16.24  
   16.25  - (void)touchesBeganWithEvent:(NSEvent *) theEvent
   16.26  {
   16.27 -    [self handleTouches:COCOA_TOUCH_DOWN withEvent:theEvent];
   16.28 +    [self handleTouches:NSTouchPhaseBegan withEvent:theEvent];
   16.29  }
   16.30  
   16.31  - (void)touchesMovedWithEvent:(NSEvent *) theEvent
   16.32  {
   16.33 -    [self handleTouches:COCOA_TOUCH_MOVE withEvent:theEvent];
   16.34 +    [self handleTouches:NSTouchPhaseMoved withEvent:theEvent];
   16.35  }
   16.36  
   16.37  - (void)touchesEndedWithEvent:(NSEvent *) theEvent
   16.38  {
   16.39 -    [self handleTouches:COCOA_TOUCH_UP withEvent:theEvent];
   16.40 +    [self handleTouches:NSTouchPhaseEnded withEvent:theEvent];
   16.41  }
   16.42  
   16.43  - (void)touchesCancelledWithEvent:(NSEvent *) theEvent
   16.44  {
   16.45 -    [self handleTouches:COCOA_TOUCH_CANCELLED withEvent:theEvent];
   16.46 +    [self handleTouches:NSTouchPhaseCancelled withEvent:theEvent];
   16.47  }
   16.48  
   16.49 -- (void)handleTouches:(cocoaTouchType)type withEvent:(NSEvent *)event
   16.50 +- (void)handleTouches:(NSTouchPhase) phase withEvent:(NSEvent *) theEvent
   16.51  {
   16.52 -    NSSet *touches = 0;
   16.53 -    NSEnumerator *enumerator;
   16.54 -    NSTouch *touch;
   16.55 +    NSSet *touches = [theEvent touchesMatchingPhase:phase inView:nil];
   16.56  
   16.57 -    switch (type) {
   16.58 -        case COCOA_TOUCH_DOWN:
   16.59 -            touches = [event touchesMatchingPhase:NSTouchPhaseBegan inView:nil];
   16.60 -            break;
   16.61 -        case COCOA_TOUCH_UP:
   16.62 -            touches = [event touchesMatchingPhase:NSTouchPhaseEnded inView:nil];
   16.63 -            break;
   16.64 -        case COCOA_TOUCH_CANCELLED:
   16.65 -            touches = [event touchesMatchingPhase:NSTouchPhaseCancelled inView:nil];
   16.66 -            break;
   16.67 -        case COCOA_TOUCH_MOVE:
   16.68 -            touches = [event touchesMatchingPhase:NSTouchPhaseMoved inView:nil];
   16.69 -            break;
   16.70 -    }
   16.71 -
   16.72 -    enumerator = [touches objectEnumerator];
   16.73 -    touch = (NSTouch*)[enumerator nextObject];
   16.74 -    while (touch) {
   16.75 +    for (NSTouch *touch in touches) {
   16.76          const SDL_TouchID touchId = (SDL_TouchID)(intptr_t)[touch device];
   16.77          if (!SDL_GetTouch(touchId)) {
   16.78              if (SDL_AddTouch(touchId, "") < 0) {
   16.79 @@ -914,20 +893,20 @@
   16.80          /* Make the origin the upper left instead of the lower left */
   16.81          y = 1.0f - y;
   16.82  
   16.83 -        switch (type) {
   16.84 -        case COCOA_TOUCH_DOWN:
   16.85 +        switch (phase) {
   16.86 +        case NSTouchPhaseBegan:
   16.87              SDL_SendTouch(touchId, fingerId, SDL_TRUE, x, y, 1.0f);
   16.88              break;
   16.89 -        case COCOA_TOUCH_UP:
   16.90 -        case COCOA_TOUCH_CANCELLED:
   16.91 +        case NSTouchPhaseEnded:
   16.92 +        case NSTouchPhaseCancelled:
   16.93              SDL_SendTouch(touchId, fingerId, SDL_FALSE, x, y, 1.0f);
   16.94              break;
   16.95 -        case COCOA_TOUCH_MOVE:
   16.96 +        case NSTouchPhaseMoved:
   16.97              SDL_SendTouchMotion(touchId, fingerId, x, y, 1.0f);
   16.98              break;
   16.99 +        default:
  16.100 +            break;
  16.101          }
  16.102 -
  16.103 -        touch = (NSTouch*)[enumerator nextObject];
  16.104      }
  16.105  }
  16.106  
  16.107 @@ -1065,23 +1044,20 @@
  16.108      NSRect rect;
  16.109      SDL_Rect bounds;
  16.110      unsigned int style;
  16.111 +    NSArray *screens = [NSScreen screens];
  16.112  
  16.113      Cocoa_GetDisplayBounds(_this, display, &bounds);
  16.114      rect.origin.x = window->x;
  16.115      rect.origin.y = window->y;
  16.116      rect.size.width = window->w;
  16.117      rect.size.height = window->h;
  16.118 -    ConvertNSRect([[NSScreen screens] objectAtIndex:0], (window->flags & FULLSCREEN_MASK), &rect);
  16.119 +    ConvertNSRect([screens objectAtIndex:0], (window->flags & FULLSCREEN_MASK), &rect);
  16.120  
  16.121      style = GetWindowStyle(window);
  16.122  
  16.123      /* Figure out which screen to place this window */
  16.124 -    NSArray *screens = [NSScreen screens];
  16.125      NSScreen *screen = nil;
  16.126 -    NSScreen *candidate;
  16.127 -    int i, count = [screens count];
  16.128 -    for (i = 0; i < count; ++i) {
  16.129 -        candidate = [screens objectAtIndex:i];
  16.130 +    for (NSScreen *candidate in screens) {
  16.131          NSRect screenRect = [candidate frame];
  16.132          if (rect.origin.x >= screenRect.origin.x &&
  16.133              rect.origin.x < screenRect.origin.x + screenRect.size.width &&
  16.134 @@ -1104,7 +1080,7 @@
  16.135      [nswindow setBackgroundColor:[NSColor blackColor]];
  16.136  
  16.137      if (videodata->allow_spaces) {
  16.138 -        SDL_assert(videodata->osversion >= 0x1070);
  16.139 +        SDL_assert(floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6);
  16.140          SDL_assert([nswindow respondsToSelector:@selector(toggleFullScreen:)]);
  16.141          /* we put FULLSCREEN_DESKTOP windows in their own Space, without a toggle button or menubar, later */
  16.142          if (window->flags & SDL_WINDOW_RESIZABLE) {