Fixed bug using SDL_WINDOWPOS_CENTERED with SDL_SetWindowPosition()
authorSam Lantinga <slouken@libsdl.org>
Thu, 19 Feb 2009 04:15:04 +0000
changeset 3075 4c28a9655933
parent 3074 caffd6a5555d
child 3076 085e46423377
Fixed bug using SDL_WINDOWPOS_CENTERED with SDL_SetWindowPosition()
src/video/cocoa/SDL_cocoawindow.m
--- 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);