src/video/SDL_video.c
changeset 7195 d206c3a59b2e
parent 7191 75360622e65f
child 7210 5b35f3e503c4
     1.1 --- a/src/video/SDL_video.c	Sun May 19 22:28:10 2013 -0700
     1.2 +++ b/src/video/SDL_video.c	Sun May 19 22:36:54 2013 -0700
     1.3 @@ -1497,26 +1497,28 @@
     1.4  {
     1.5      CHECK_WINDOW_MAGIC(window, );
     1.6  
     1.7 +    if (SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) {
     1.8 +        SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
     1.9 +        int displayIndex;
    1.10 +        SDL_Rect bounds;
    1.11 +
    1.12 +        displayIndex = SDL_GetIndexOfDisplay(display);
    1.13 +        SDL_GetDisplayBounds(displayIndex, &bounds);
    1.14 +        if (SDL_WINDOWPOS_ISCENTERED(x)) {
    1.15 +            x = bounds.x + (bounds.w - window->w) / 2;
    1.16 +        }
    1.17 +        if (SDL_WINDOWPOS_ISCENTERED(y)) {
    1.18 +            y = bounds.y + (bounds.h - window->h) / 2;
    1.19 +        }
    1.20 +    }
    1.21 +
    1.22      if (!SDL_WINDOWPOS_ISUNDEFINED(x)) {
    1.23          window->x = x;
    1.24      }
    1.25      if (!SDL_WINDOWPOS_ISUNDEFINED(y)) {
    1.26          window->y = y;
    1.27      }
    1.28 -    if (SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) {
    1.29 -        SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    1.30 -        int displayIndex;
    1.31 -        SDL_Rect bounds;
    1.32 -
    1.33 -        displayIndex = SDL_GetIndexOfDisplay(display);
    1.34 -        SDL_GetDisplayBounds(displayIndex, &bounds);
    1.35 -        if (SDL_WINDOWPOS_ISCENTERED(x)) {
    1.36 -            window->x = bounds.x + (bounds.w - window->w) / 2;
    1.37 -        }
    1.38 -        if (SDL_WINDOWPOS_ISCENTERED(y)) {
    1.39 -            window->y = bounds.y + (bounds.h - window->h) / 2;
    1.40 -        }
    1.41 -    }
    1.42 +
    1.43      if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
    1.44          if (_this->SetWindowPosition) {
    1.45              _this->SetWindowPosition(_this, window);