From e09d95c36a6762fbecb1f8897f3b140bd049b708 Mon Sep 17 00:00:00 2001 From: Alfred Reynolds Date: Wed, 29 Jul 2015 17:19:11 -0700 Subject: [PATCH] Fix SDL_GetWindowPosition to be properly monitor-aware and return the monitor x,y when fullscreened. --- src/video/SDL_video.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 944c07d3d3cdb..a89399d9dc602 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1679,12 +1679,31 @@ SDL_GetWindowPosition(SDL_Window * window, int *x, int *y) /* Fullscreen windows are always at their display's origin */ if (window->flags & SDL_WINDOW_FULLSCREEN) { + int displayIndex; + if (x) { *x = 0; } if (y) { *y = 0; } + + /* Find the window's monitor and update to the + monitor offset. */ + displayIndex = SDL_GetWindowDisplayIndex(window); + if (displayIndex >= 0) { + SDL_Rect bounds; + + SDL_zero(bounds); + + SDL_GetDisplayBounds(displayIndex, &bounds); + if (x) { + *x = bounds.x; + } + if (y) { + *y = bounds.y; + } + } } else { if (x) { *x = window->x;