diff src/video/win32/SDL_win32window.c @ 3530:e96be66e3673

The window position is display relative, at least for now...
author Sam Lantinga <slouken@libsdl.org>
date Sun, 06 Dec 2009 08:39:01 +0000
parents 59ff7a2beb57
children 07c8339c95c6
line wrap: on
line diff
--- a/src/video/win32/SDL_win32window.c	Sun Dec 06 08:16:23 2009 +0000
+++ b/src/video/win32/SDL_win32window.c	Sun Dec 06 08:39:01 2009 +0000
@@ -86,6 +86,7 @@
 SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
 {
     SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
+    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
     SDL_WindowData *data;
 
     /* Allocate the window data */
@@ -123,8 +124,10 @@
         point.x = 0;
         point.y = 0;
         if (ClientToScreen(hwnd, &point)) {
-            window->x = point.x;
-            window->y = point.y;
+            SDL_Rect bounds;
+            WIN_GetDisplayBounds(_this, display, &bounds);
+            window->x = point.x - bounds.x;
+            window->y = point.y - bounds.y;
         }
     }
     {
@@ -232,7 +235,7 @@
             x = bounds.x;
         }
     } else {
-        x = window->x + rect.left;
+        x = bounds.x + window->x + rect.left;
     }
     if ((window->flags & SDL_WINDOW_FULLSCREEN)
         || window->y == SDL_WINDOWPOS_CENTERED) {
@@ -244,7 +247,7 @@
             y = bounds.y;
         }
     } else {
-        y = window->y + rect.top;
+        y = bounds.y + window->y + rect.top;
     }
 
     hwnd =
@@ -459,13 +462,13 @@
         || window->x == SDL_WINDOWPOS_CENTERED) {
         x = bounds.x + (bounds.w - window->w) / 2;
     } else {
-        x = window->x + rect.left;
+        x = bounds.x + window->x + rect.left;
     }
     if ((window->flags & SDL_WINDOW_FULLSCREEN)
         || window->y == SDL_WINDOWPOS_CENTERED) {
         y = bounds.y + (bounds.h - window->h) / 2;
     } else {
-        y = window->y + rect.top;
+        y = bounds.y + window->y + rect.top;
     }
 
     SetWindowPos(hwnd, top, x, y, 0, 0, (SWP_NOCOPYBITS | SWP_NOSIZE));