src/video/cocoa/SDL_cocoawindow.m
changeset 3528 59ff7a2beb57
parent 3525 455a6c47d2c6
child 3529 09155ec3e291
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Sun Dec 06 06:21:39 2009 +0000
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Sun Dec 06 08:03:38 2009 +0000
     1.3 @@ -378,23 +378,28 @@
     1.4  {
     1.5      NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1.6      NSWindow *nswindow;
     1.7 -    SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
     1.8 +    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
     1.9      NSRect rect;
    1.10 +    SDL_Rect bounds;
    1.11      unsigned int style;
    1.12      NSString *title;
    1.13      int status;
    1.14  
    1.15 -    rect = Cocoa_DisplayBounds(displaydata->display);
    1.16 +    Cocoa_GetDisplayBounds(_this, display, &bounds);
    1.17      if ((window->flags & SDL_WINDOW_FULLSCREEN)
    1.18          || window->x == SDL_WINDOWPOS_CENTERED) {
    1.19 -        rect.origin.x += (rect.size.width - window->w) / 2;
    1.20 -    } else if (window->x != SDL_WINDOWPOS_UNDEFINED) {
    1.21 +        rect.origin.x = bounds.x + (bounds.w - window->w) / 2;
    1.22 +    } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
    1.23 +        rect.origin.x = bounds.x;
    1.24 +    } else {
    1.25          rect.origin.x = window->x;
    1.26      }
    1.27      if ((window->flags & SDL_WINDOW_FULLSCREEN)
    1.28          || window->y == SDL_WINDOWPOS_CENTERED) {
    1.29 -        rect.origin.y += (rect.size.height - window->h) / 2;
    1.30 -    } else if (window->x != SDL_WINDOWPOS_UNDEFINED) {
    1.31 +        rect.origin.y = bounds.y + (bounds.h - window->h) / 2;
    1.32 +    } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
    1.33 +        rect.origin.y = bounds.y;
    1.34 +    } else {
    1.35          rect.origin.y = window->y;
    1.36      }
    1.37      rect.size.width = window->w;
    1.38 @@ -482,19 +487,20 @@
    1.39  {
    1.40      NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    1.41      NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
    1.42 -    SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
    1.43 +    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
    1.44      NSRect rect;
    1.45 +    SDL_Rect bounds;
    1.46  
    1.47 -    rect = Cocoa_DisplayBounds(displaydata->display);
    1.48 +    Cocoa_GetDisplayBounds(_this, display, &bounds);
    1.49      if ((window->flags & SDL_WINDOW_FULLSCREEN)
    1.50          || window->x == SDL_WINDOWPOS_CENTERED) {
    1.51 -        rect.origin.x += (rect.size.width - window->w) / 2;
    1.52 +        rect.origin.x = bounds.x + (bounds.w - window->w) / 2;
    1.53      } else {
    1.54          rect.origin.x = window->x;
    1.55      }
    1.56      if ((window->flags & SDL_WINDOW_FULLSCREEN)
    1.57          || window->y == SDL_WINDOWPOS_CENTERED) {
    1.58 -        rect.origin.y += (rect.size.height - window->h) / 2;
    1.59 +        rect.origin.y = bounds.y + (bounds.h - window->h) / 2;
    1.60      } else {
    1.61          rect.origin.y = window->y;
    1.62      }