Commit e2ff36e2 authored by Sam Lantinga's avatar Sam Lantinga

Fixed compilation on Mac OS X 10.4

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404268
parent 21f0a007
......@@ -180,9 +180,10 @@ typedef unsigned int NSUInteger;
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
......
......@@ -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);
......
......@@ -200,6 +200,21 @@ Cocoa_InitModes(_THIS)
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)
{
......
......@@ -68,7 +68,7 @@ Cocoa_HandleMouseEvent(_THIS, NSEvent *event)
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;
......
......@@ -384,7 +384,7 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
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;
......@@ -414,7 +414,9 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
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 &&
......@@ -483,7 +485,7 @@ Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment