Fixed bug using SDL_WINDOWPOS_CENTERED with SDL_SetWindowPosition()
authorSam Lantinga <slouken@libsdl.org>
Thu, 19 Feb 2009 04:15:04 +0000
changeset 30754c28a9655933
parent 3074 caffd6a5555d
child 3076 085e46423377
Fixed bug using SDL_WINDOWPOS_CENTERED with SDL_SetWindowPosition()
src/video/cocoa/SDL_cocoawindow.m
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Thu Feb 19 04:03:05 2009 +0000
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Thu Feb 19 04:15:04 2009 +0000
     1.3 @@ -387,14 +387,16 @@
     1.4  
     1.5      pool = [[NSAutoreleasePool alloc] init];
     1.6  
     1.7 -    if (window->x == SDL_WINDOWPOS_CENTERED) {
     1.8 +    if ((window->flags & SDL_WINDOW_FULLSCREEN)
     1.9 +        || window->x == SDL_WINDOWPOS_CENTERED) {
    1.10          rect.origin.x = (CGDisplayPixelsWide(kCGDirectMainDisplay) - window->w) / 2;
    1.11      } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
    1.12          rect.origin.x = 0;
    1.13      } else {
    1.14          rect.origin.x = window->x;
    1.15      }
    1.16 -    if (window->y == SDL_WINDOWPOS_CENTERED) {
    1.17 +    if ((window->flags & SDL_WINDOW_FULLSCREEN)
    1.18 +        || window->y == SDL_WINDOWPOS_CENTERED) {
    1.19          rect.origin.y = (CGDisplayPixelsHigh(kCGDirectMainDisplay) - window->h) / 2;
    1.20      } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
    1.21          rect.origin.y = 0;
    1.22 @@ -471,8 +473,18 @@
    1.23      NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
    1.24      NSRect rect;
    1.25  
    1.26 -    rect.origin.x = window->x;
    1.27 -    rect.origin.y = window->y;
    1.28 +    if ((window->flags & SDL_WINDOW_FULLSCREEN)
    1.29 +        || window->x == SDL_WINDOWPOS_CENTERED) {
    1.30 +        rect.origin.x = (CGDisplayPixelsWide(kCGDirectMainDisplay) - window->w) / 2;
    1.31 +    } else {
    1.32 +        rect.origin.x = window->x;
    1.33 +    }
    1.34 +    if ((window->flags & SDL_WINDOW_FULLSCREEN)
    1.35 +        || window->y == SDL_WINDOWPOS_CENTERED) {
    1.36 +        rect.origin.y = (CGDisplayPixelsHigh(kCGDirectMainDisplay) - window->h) / 2;
    1.37 +    } else {
    1.38 +        rect.origin.y = window->y;
    1.39 +    }
    1.40      rect.size.width = window->w;
    1.41      rect.size.height = window->h;
    1.42      ConvertNSRect(&rect);