Fixed forcing the window size when creating a non-resizable window on Windows.
authorSam Lantinga <slouken@libsdl.org>
Thu, 01 Oct 2015 11:21:06 -0700
changeset 9886 adb374e144d6
parent 9885 3a25a7f73e5f
child 9887 77f017f7f16d
Fixed forcing the window size when creating a non-resizable window on Windows.
src/video/windows/SDL_windowswindow.c
--- a/src/video/windows/SDL_windowswindow.c	Wed Sep 30 16:00:21 2015 -0700
+++ b/src/video/windows/SDL_windowswindow.c	Thu Oct 01 11:21:06 2015 -0700
@@ -109,7 +109,7 @@
     y = window->y + rect.top;
 
     data->expected_resize = SDL_TRUE;
-    SetWindowPos( hwnd, top, x, y, w, h, flags );
+    SetWindowPos(hwnd, top, x, y, w, h, flags);
     data->expected_resize = SDL_FALSE;
 }
 
@@ -165,7 +165,26 @@
             int h = rect.bottom;
             if ((window->w && window->w != w) || (window->h && window->h != h)) {
                 /* We tried to create a window larger than the desktop and Windows didn't allow it.  Override! */
-                WIN_SetWindowPositionInternal(_this, window, SWP_NOCOPYBITS | SWP_NOZORDER | SWP_NOACTIVATE);
+                RECT rect;
+                DWORD style;
+                BOOL menu;
+                int x, y;
+                int w, h;
+
+                /* Figure out what the window area will be */
+                style = GetWindowLong(hwnd, GWL_STYLE);
+                rect.left = 0;
+                rect.top = 0;
+                rect.right = window->w;
+                rect.bottom = window->h;
+                menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
+                AdjustWindowRectEx(&rect, style, menu, 0);
+                w = (rect.right - rect.left);
+                h = (rect.bottom - rect.top);
+                x = window->x + rect.left;
+                y = window->y + rect.top;
+
+                SetWindowPos(hwnd, HWND_NOTOPMOST, x, y, w, h, SWP_NOCOPYBITS | SWP_NOZORDER | SWP_NOACTIVATE);
             } else {
                 window->w = w;
                 window->h = h;
@@ -492,7 +511,7 @@
     }
 
     data->in_border_change = SDL_TRUE;
-    SetWindowLong( hwnd, GWL_STYLE, style );
+    SetWindowLong(hwnd, GWL_STYLE, style);
     WIN_SetWindowPositionInternal(_this, window, SWP_NOCOPYBITS | SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOACTIVATE);
     data->in_border_change = SDL_FALSE;
 }