Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed compilation on Mac OS X 10.4
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Dec 5, 2009
1 parent f590484 commit fb4c460
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/video/cocoa/SDL_cocoakeyboard.m
Expand Up @@ -180,9 +180,10 @@ - (NSAttributedString *) attributedSubstringFromRange: (NSRange) theRange
return nil;
}

- (NSInteger) conversationIdentifier
/* Needs long instead of NSInteger for compilation on Mac OS X 10.4 */
- (long) conversationIdentifier
{
return (NSInteger) self;
return (long) self;
}

// This method returns the index for character that is
Expand Down
1 change: 1 addition & 0 deletions src/video/cocoa/SDL_cocoamodes.h
Expand Up @@ -35,6 +35,7 @@ typedef struct
} SDL_DisplayModeData;

extern void Cocoa_InitModes(_THIS);
extern NSRect Cocoa_DisplayBounds(CGDirectDisplayID display);
extern void Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
extern int Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
extern void Cocoa_QuitModes(_THIS);
Expand Down
15 changes: 15 additions & 0 deletions src/video/cocoa/SDL_cocoamodes.m
Expand Up @@ -200,6 +200,21 @@ - (void) setFrame:(NSRect)frame;
SDL_stack_free(displays);
}

/* This is needed on 10.4, where NSRect and CGRect are different */
NSRect
Cocoa_DisplayBounds(CGDirectDisplayID display)
{
NSRect nsrect;
CGRect cgrect;

cgrect = CGDisplayBounds(display);
nsrect.origin.x = cgrect.origin.x;
nsrect.origin.y = cgrect.origin.y;
nsrect.size.width = cgrect.size.width;
nsrect.size.height = cgrect.size.height;
return nsrect;
}

static void
AddDisplayMode(const void *moderef, void *context)
{
Expand Down
2 changes: 1 addition & 1 deletion src/video/cocoa/SDL_cocoamouse.m
Expand Up @@ -68,7 +68,7 @@

if (candidate) {
SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
NSRect rect = CGDisplayBounds(displaydata->display);
NSRect rect = Cocoa_DisplayBounds(displaydata->display);

point = [NSEvent mouseLocation];
point.x = point.x - rect.origin.x;
Expand Down
8 changes: 5 additions & 3 deletions src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -384,7 +384,7 @@ - (BOOL)canBecomeMainWindow
NSString *title;
int status;

rect = CGDisplayBounds(displaydata->display);
rect = Cocoa_DisplayBounds(displaydata->display);
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|| window->x == SDL_WINDOWPOS_CENTERED) {
rect.origin.x += (rect.size.width - window->w) / 2;
Expand Down Expand Up @@ -414,7 +414,9 @@ - (BOOL)canBecomeMainWindow
NSArray *screens = [NSScreen screens];
NSScreen *screen = nil;
NSScreen *candidate;
for (candidate in screens) {
int i, count = [screens count];
for (i = 0; i < count; ++i) {
screen = [screens objectAtIndex:i];
NSRect screenRect = [candidate frame];
if (rect.origin.x >= screenRect.origin.x &&
rect.origin.x < screenRect.origin.x + screenRect.size.width &&
Expand Down Expand Up @@ -483,7 +485,7 @@ - (BOOL)canBecomeMainWindow
SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
NSRect rect;

rect = CGDisplayBounds(displaydata->display);
rect = Cocoa_DisplayBounds(displaydata->display);
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|| window->x == SDL_WINDOWPOS_CENTERED) {
rect.origin.x += (rect.size.width - window->w) / 2;
Expand Down

0 comments on commit fb4c460

Please sign in to comment.