[PATCH] Resize fullscreen window when DirectDraw changes the display mode

Johan Gill johan.gill at gmail.com
Tue Jul 21 09:22:31 CDT 2009


Resize fullscreen window when DirectDraw changes the display mode.

Windows does it, and Sid Meier's Alpha Centauri needs it. I also added a
test for it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20090721/667a9277/attachment-0001.htm>
-------------- next part --------------
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index bd96418..16104a1 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -590,6 +590,13 @@ IDirectDrawImpl_SetDisplayModeNoOverride(IDirectDraw7 *iface,
     hr = IWineD3DDevice_SetDisplayMode(This->wineD3DDevice,
                                        0, /* First swapchain */
                                        &Mode);
+
+    /* Fullscreen windows are resized if the display mode is changed */
+    if (This->cooperative_level & DDSCL_FULLSCREEN) {
+        SetWindowPos(This->dest_window, HWND_TOP,
+                     0, 0, Width, Height, SWP_SHOWWINDOW);
+    }
+
     LeaveCriticalSection(&ddraw_cs);
     switch(hr)
     {
diff --git a/dlls/ddraw/tests/ddrawmodes.c b/dlls/ddraw/tests/ddrawmodes.c
index 03ac673..001899c 100644
--- a/dlls/ddraw/tests/ddrawmodes.c
+++ b/dlls/ddraw/tests/ddrawmodes.c
@@ -219,6 +219,13 @@ static void destroysurface(void)
     }
 }
 
+static void checkrect(RECT *rect, RECT *ref, const char *string)
+{
+    ok((rect->right == ref->right) && (rect->bottom == ref->bottom),
+       "Expected (0,0)-(%d,%d) %s, got (%d,%d)-(%d,%d)\n",
+       ref->right, ref->bottom, string, rect->left, rect->top, rect->right, rect->bottom);
+}
+
 static void testsurface(void)
 {
     const char* testMsg = "ddraw device context test";
@@ -365,6 +372,8 @@ static void testcooperativelevels_normal(void)
 static void testcooperativelevels_exclusive(void)
 {
     HRESULT rc;
+    RECT cr1, cr2, cr3, wr1, wr2, wr3;
+    RECT ref;
 
     /* Do some tests with DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN mode */
 
@@ -390,6 +399,26 @@ static void testcooperativelevels_exclusive(void)
        broken(rc==DDERR_INVALIDPARAMS) /* NT4/Win95 */,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
 
 
+    /* Test resizing of the fullscreen window */
+
+    GetClientRect(hwnd, &cr1);
+    GetWindowRect(hwnd, &wr1);
+    rc = IDirectDraw_SetDisplayMode(lpDD, 640, 480, 16);
+    ok(rc==DD_OK, "SetDisplayMode(640, 480, 16) returned: %x\n",rc);
+    GetClientRect(hwnd, &cr2);
+    GetWindowRect(hwnd, &wr2);
+    ref.right = 640;
+    ref.bottom = 480;
+    checkrect(&cr2, &ref, "client rect");
+    checkrect(&wr2, &ref, "window rect");
+
+    rc = IDirectDraw_RestoreDisplayMode(lpDD);
+    ok(rc==DD_OK, "RestoreDisplayMode returned: %x\n",rc);
+    GetClientRect(hwnd, &cr3);
+    GetWindowRect(hwnd, &wr3);
+    checkrect(&cr3, &cr1, "client rect");
+    checkrect(&wr3, &wr1, "window rect");
+
     /* All done */
 }
 


More information about the wine-patches mailing list