Fixed compilation on Mac OS X 10.4
authorSam Lantinga <slouken@libsdl.org>
Sat, 05 Dec 2009 19:57:49 +0000
changeset 3525455a6c47d2c6
parent 3524 5668e43c256b
child 3526 e6f2f312780f
Fixed compilation on Mac OS X 10.4
src/video/cocoa/SDL_cocoakeyboard.m
src/video/cocoa/SDL_cocoamodes.h
src/video/cocoa/SDL_cocoamodes.m
src/video/cocoa/SDL_cocoamouse.m
src/video/cocoa/SDL_cocoawindow.m
     1.1 --- a/src/video/cocoa/SDL_cocoakeyboard.m	Sat Dec 05 19:46:24 2009 +0000
     1.2 +++ b/src/video/cocoa/SDL_cocoakeyboard.m	Sat Dec 05 19:57:49 2009 +0000
     1.3 @@ -180,9 +180,10 @@
     1.4      return nil;
     1.5  }
     1.6  
     1.7 -- (NSInteger) conversationIdentifier
     1.8 +/* Needs long instead of NSInteger for compilation on Mac OS X 10.4 */
     1.9 +- (long) conversationIdentifier
    1.10  {
    1.11 -    return (NSInteger) self;
    1.12 +    return (long) self;
    1.13  }
    1.14  
    1.15  // This method returns the index for character that is 
     2.1 --- a/src/video/cocoa/SDL_cocoamodes.h	Sat Dec 05 19:46:24 2009 +0000
     2.2 +++ b/src/video/cocoa/SDL_cocoamodes.h	Sat Dec 05 19:57:49 2009 +0000
     2.3 @@ -35,6 +35,7 @@
     2.4  } SDL_DisplayModeData;
     2.5  
     2.6  extern void Cocoa_InitModes(_THIS);
     2.7 +extern NSRect Cocoa_DisplayBounds(CGDirectDisplayID display);
     2.8  extern void Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
     2.9  extern int Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
    2.10  extern void Cocoa_QuitModes(_THIS);
     3.1 --- a/src/video/cocoa/SDL_cocoamodes.m	Sat Dec 05 19:46:24 2009 +0000
     3.2 +++ b/src/video/cocoa/SDL_cocoamodes.m	Sat Dec 05 19:57:49 2009 +0000
     3.3 @@ -200,6 +200,21 @@
     3.4      SDL_stack_free(displays);
     3.5  }
     3.6  
     3.7 +/* This is needed on 10.4, where NSRect and CGRect are different */
     3.8 +NSRect
     3.9 +Cocoa_DisplayBounds(CGDirectDisplayID display)
    3.10 +{
    3.11 +    NSRect nsrect;
    3.12 +    CGRect cgrect;
    3.13 +
    3.14 +    cgrect = CGDisplayBounds(display);
    3.15 +    nsrect.origin.x = cgrect.origin.x;
    3.16 +    nsrect.origin.y = cgrect.origin.y;
    3.17 +    nsrect.size.width = cgrect.size.width;
    3.18 +    nsrect.size.height = cgrect.size.height;
    3.19 +    return nsrect;
    3.20 +}
    3.21 +
    3.22  static void
    3.23  AddDisplayMode(const void *moderef, void *context)
    3.24  {
     4.1 --- a/src/video/cocoa/SDL_cocoamouse.m	Sat Dec 05 19:46:24 2009 +0000
     4.2 +++ b/src/video/cocoa/SDL_cocoamouse.m	Sat Dec 05 19:57:49 2009 +0000
     4.3 @@ -68,7 +68,7 @@
     4.4  
     4.5          if (candidate) {
     4.6              SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
     4.7 -            NSRect rect = CGDisplayBounds(displaydata->display);
     4.8 +            NSRect rect = Cocoa_DisplayBounds(displaydata->display);
     4.9  
    4.10              point = [NSEvent mouseLocation];
    4.11              point.x = point.x - rect.origin.x;
     5.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Sat Dec 05 19:46:24 2009 +0000
     5.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Sat Dec 05 19:57:49 2009 +0000
     5.3 @@ -384,7 +384,7 @@
     5.4      NSString *title;
     5.5      int status;
     5.6  
     5.7 -    rect = CGDisplayBounds(displaydata->display);
     5.8 +    rect = Cocoa_DisplayBounds(displaydata->display);
     5.9      if ((window->flags & SDL_WINDOW_FULLSCREEN)
    5.10          || window->x == SDL_WINDOWPOS_CENTERED) {
    5.11          rect.origin.x += (rect.size.width - window->w) / 2;
    5.12 @@ -414,7 +414,9 @@
    5.13      NSArray *screens = [NSScreen screens];
    5.14      NSScreen *screen = nil;
    5.15      NSScreen *candidate;
    5.16 -    for (candidate in screens) {
    5.17 +    int i, count = [screens count];
    5.18 +    for (i = 0; i < count; ++i) {
    5.19 +        screen = [screens objectAtIndex:i];
    5.20          NSRect screenRect = [candidate frame];
    5.21          if (rect.origin.x >= screenRect.origin.x &&
    5.22              rect.origin.x < screenRect.origin.x + screenRect.size.width &&
    5.23 @@ -483,7 +485,7 @@
    5.24      SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
    5.25      NSRect rect;
    5.26  
    5.27 -    rect = CGDisplayBounds(displaydata->display);
    5.28 +    rect = Cocoa_DisplayBounds(displaydata->display);
    5.29      if ((window->flags & SDL_WINDOW_FULLSCREEN)
    5.30          || window->x == SDL_WINDOWPOS_CENTERED) {
    5.31          rect.origin.x += (rect.size.width - window->w) / 2;