From 422fa30d4ad89f5c03ed2ad8e78ed46fff0ea95b Mon Sep 17 00:00:00 2001
From: FunkyFr3sh <cc.red.alert.1@googlemail.com>
Date: Tue, 7 Aug 2018 02:08:40 +0200
Subject: [PATCH] use MoveWindow - fixes a bug where the window always showed
 up in the top left of the screen

---
 ddraw.rc   |  2 +-
 src/main.c | 10 ++++++----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/ddraw.rc b/ddraw.rc
index 00cf7ae..dcd5c82 100644
--- a/ddraw.rc
+++ b/ddraw.rc
@@ -2,7 +2,7 @@
 #define vxstr(a,b,c,d) str(a##.##b##.##c##.##d)
 #define str(s) #s
 
-#define VERSION 1,1,8,2
+#define VERSION 1,1,8,3
 
 1 VERSIONINFO
 FILEVERSION VERSION
diff --git a/src/main.c b/src/main.c
index f12d98c..f13122a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -422,8 +422,8 @@ HRESULT __stdcall ddraw_SetDisplayMode(IDirectDrawImpl *This, DWORD width, DWORD
             int y = (WindowPosY != -1) ? WindowPosY : (This->mode.dmPelsHeight / 2) - (This->render.height / 2);
             RECT dst = { x, y, This->render.width+x, This->render.height+y };
             AdjustWindowRect(&dst, GetWindowLong(This->hWnd, GWL_STYLE), FALSE);
-            SetWindowPos(This->hWnd, HWND_NOTOPMOST, dst.left, dst.top, (dst.right - dst.left), (dst.bottom - dst.top), SWP_SHOWWINDOW);
-
+            SetWindowPos(ddraw->hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
+            MoveWindow(This->hWnd, dst.left, dst.top, (dst.right - dst.left), (dst.bottom - dst.top), TRUE);
             This->windowed_init = TRUE;
         }
     }
@@ -518,8 +518,10 @@ void ToggleFullscreen()
             int y = (WindowPosY != -1) ? WindowPosY : (ddraw->mode.dmPelsHeight / 2) - (ddraw->render.height / 2);
             RECT dst = { x, y, ddraw->render.width+x, ddraw->render.height+y };
             AdjustWindowRect(&dst, GetWindowLong(ddraw->hWnd, GWL_STYLE), FALSE);
-            SetWindowPos(ddraw->hWnd, HWND_NOTOPMOST, dst.left, dst.top, (dst.right - dst.left), (dst.bottom - dst.top), SWP_SHOWWINDOW);
-            
+
+            SetWindowPos(ddraw->hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
+            MoveWindow(ddraw->hWnd, dst.left, dst.top, (dst.right - dst.left), (dst.bottom - dst.top), TRUE);
+
             ddraw->windowed = TRUE;
             ddraw->windowed_init = TRUE;
         }