Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fixed bug using SDL_WINDOWPOS_CENTERED with SDL_SetWindowPosition()

  • Loading branch information
slouken committed Feb 19, 2009
1 parent f9e9515 commit 88b40069bb1246e94b1fb298e88d6bdf2521d867
Showing with 16 additions and 4 deletions.
  1. +16 −4 src/video/cocoa/SDL_cocoawindow.m
@@ -387,14 +387,16 @@ - (BOOL)canBecomeMainWindow

pool = [[NSAutoreleasePool alloc] init];

if (window->x == SDL_WINDOWPOS_CENTERED) {
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|| window->x == SDL_WINDOWPOS_CENTERED) {
rect.origin.x = (CGDisplayPixelsWide(kCGDirectMainDisplay) - window->w) / 2;
} else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
rect.origin.x = 0;
} else {
rect.origin.x = window->x;
}
if (window->y == SDL_WINDOWPOS_CENTERED) {
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|| window->y == SDL_WINDOWPOS_CENTERED) {
rect.origin.y = (CGDisplayPixelsHigh(kCGDirectMainDisplay) - window->h) / 2;
} else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
rect.origin.y = 0;
@@ -471,8 +473,18 @@ - (BOOL)canBecomeMainWindow
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
NSRect rect;

rect.origin.x = window->x;
rect.origin.y = window->y;
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|| window->x == SDL_WINDOWPOS_CENTERED) {
rect.origin.x = (CGDisplayPixelsWide(kCGDirectMainDisplay) - window->w) / 2;
} else {
rect.origin.x = window->x;
}
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|| window->y == SDL_WINDOWPOS_CENTERED) {
rect.origin.y = (CGDisplayPixelsHigh(kCGDirectMainDisplay) - window->h) / 2;
} else {
rect.origin.y = window->y;
}
rect.size.width = window->w;
rect.size.height = window->h;
ConvertNSRect(&rect);

0 comments on commit 88b4006

Please sign in to comment.