diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 57cc934df..f0f3380db 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1497,12 +1497,6 @@ SDL_SetWindowPosition(SDL_Window * window, int x, int y) { CHECK_WINDOW_MAGIC(window, ); - if (!SDL_WINDOWPOS_ISUNDEFINED(x)) { - window->x = x; - } - if (!SDL_WINDOWPOS_ISUNDEFINED(y)) { - window->y = y; - } if (SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) { SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); int displayIndex; @@ -1511,12 +1505,20 @@ SDL_SetWindowPosition(SDL_Window * window, int x, int y) displayIndex = SDL_GetIndexOfDisplay(display); SDL_GetDisplayBounds(displayIndex, &bounds); if (SDL_WINDOWPOS_ISCENTERED(x)) { - window->x = bounds.x + (bounds.w - window->w) / 2; + x = bounds.x + (bounds.w - window->w) / 2; } if (SDL_WINDOWPOS_ISCENTERED(y)) { - window->y = bounds.y + (bounds.h - window->h) / 2; + y = bounds.y + (bounds.h - window->h) / 2; } } + + if (!SDL_WINDOWPOS_ISUNDEFINED(x)) { + window->x = x; + } + if (!SDL_WINDOWPOS_ISUNDEFINED(y)) { + window->y = y; + } + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { if (_this->SetWindowPosition) { _this->SetWindowPosition(_this, window);