changeset 3075:4c28a9655933

Fixed bug using SDL_WINDOWPOS_CENTERED with SDL_SetWindowPosition()
author Sam Lantinga <slouken@libsdl.org>
date Thu, 19 Feb 2009 04:15:04 +0000
parents caffd6a5555d
children 085e46423377
files src/video/cocoa/SDL_cocoawindow.m
diffstat 1 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/cocoa/SDL_cocoawindow.m	Thu Feb 19 04:03:05 2009 +0000
+++ b/src/video/cocoa/SDL_cocoawindow.m	Thu Feb 19 04:15:04 2009 +0000
@@ -387,14 +387,16 @@
 
     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 @@
     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);