From 23f5b58d0935b2126e6004e910a3b78f148fa403 Mon Sep 17 00:00:00 2001 From: Edward Rudd Date: Mon, 19 Jan 2015 12:42:25 -0500 Subject: [PATCH] respect the display number for SDL_WINDOWPOS_CENTERED_DISPLAY in the SDL_SetWindowPosition function. This allows for this kind of code in an application int monitorID = 1; // the second monitor! SDL_SetWindowPosition(sdlWin, SDL_WINDOWPOS_CENTERED_DISPLAY(monitorID), SDL_WINDOWPOS_CENTERED_DISPLAY(monitorID)); --- src/video/SDL_video.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index db777db..1dcfabf 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1607,13 +1607,14 @@ SDL_SetWindowPosition(SDL_Window * window, int x, int y) CHECK_WINDOW_MAGIC(window,); if (SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) { - SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); - int displayIndex; + int displayIndex = (x & 0xFFFF); SDL_Rect bounds; + if (displayIndex > _this->num_displays) { + displayIndex = 0; + } SDL_zero(bounds); - displayIndex = SDL_GetIndexOfDisplay(display); SDL_GetDisplayBounds(displayIndex, &bounds); if (SDL_WINDOWPOS_ISCENTERED(x)) { x = bounds.x + (bounds.w - window->w) / 2; -- 1.8.5.2 (Apple Git-48)