Fix SDL_GetWindowPosition to be properly monitor-aware and return the monitor x,y when fullscreened.
authorAlfred Reynolds <alfred@valvesoftware.com>
Wed, 29 Jul 2015 17:19:11 -0700
changeset 9818 cfeb59daba69
parent 9817 d71f8723dbe8
child 9819 2361f732e8cb
Fix SDL_GetWindowPosition to be properly monitor-aware and return the monitor x,y when fullscreened.
src/video/SDL_video.c
--- a/src/video/SDL_video.c	Wed Jul 29 17:19:09 2015 -0700
+++ b/src/video/SDL_video.c	Wed Jul 29 17:19:11 2015 -0700
@@ -1679,12 +1679,31 @@
 
     /* 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;