Fix SDL_GetWindowPosition to be properly monitor-aware and return the monitor x,y when fullscreened.

This commit is contained in:
Alfred Reynolds 2015-07-29 17:19:11 -07:00
parent 6ebbf7ddd0
commit e09d95c36a
1 changed files with 19 additions and 0 deletions

View File

@ -1679,12 +1679,31 @@ SDL_GetWindowPosition(SDL_Window * window, int *x, int *y)
/* Fullscreen windows are always at their display's origin */ /* Fullscreen windows are always at their display's origin */
if (window->flags & SDL_WINDOW_FULLSCREEN) { if (window->flags & SDL_WINDOW_FULLSCREEN) {
int displayIndex;
if (x) { if (x) {
*x = 0; *x = 0;
} }
if (y) { if (y) {
*y = 0; *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 { } else {
if (x) { if (x) {
*x = window->x; *x = window->x;