[PATCH] Resize fullscreen window when DirectDraw changes the display mode [resubmit 4]
Johan Gill
johan.gill at gmail.com
Wed Jul 29 16:55:40 CDT 2009
This patch fixes bug 17215. Since the patch was seemingly dropped, I made
some test improvements and resubmit it.
The tests pass on Windows XP, and of course Wine.
Suggested changelog:
In DirectDraw fullscreen mode, make sure the fullscreen window is resized
when the display mode changes
Johan Gill
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20090729/356e258e/attachment.htm>
-------------- next part --------------
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index bd96418..84ede5c 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -590,6 +590,17 @@ IDirectDrawImpl_SetDisplayModeNoOverride(IDirectDraw7 *iface,
hr = IWineD3DDevice_SetDisplayMode(This->wineD3DDevice,
0, /* First swapchain */
&Mode);
+
+ if (hr == WINED3D_OK) {
+ /* If in fullscreen mode, the cooperating window must be resized
+ * with the screen
+ */
+ 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..75c5942 100644
--- a/dlls/ddraw/tests/ddrawmodes.c
+++ b/dlls/ddraw/tests/ddrawmodes.c
@@ -219,6 +219,15 @@ static void destroysurface(void)
}
}
+static void checkrect(RECT *rect, RECT *ref, const char *rect_desc)
+{
+ ok((rect->left == ref->left) && (rect->top == ref->top) &&
+ (rect->right == ref->right) && (rect->bottom == ref->bottom),
+ "Expected (%d,%d)-(%d,%d) %s, got (%d,%d)-(%d,%d)\n",
+ ref->left, ref->top, ref->right, ref->bottom, rect_desc,
+ rect->left, rect->top, rect->right, rect->bottom);
+}
+
static void testsurface(void)
{
const char* testMsg = "ddraw device context test";
@@ -266,6 +275,7 @@ static void testdisplaymodes(void)
static void testcooperativelevels_normal(void)
{
HRESULT rc;
+ RECT ref_clientrect, ref_windowrect, cr, wr;
DDSURFACEDESC surfacedesc;
IDirectDrawSurface *surface = (IDirectDrawSurface *) 0xdeadbeef;
@@ -293,6 +303,20 @@ static void testcooperativelevels_normal(void)
}
if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface);
+ /* Get current rects for the window, for use in comparisons below */
+ GetClientRect(hwnd, &ref_clientrect);
+ GetWindowRect(hwnd, &ref_windowrect);
+
+ /* Switch to 640x480, and check that the window is not resized */
+ rc = IDirectDraw_SetDisplayMode(lpDD, 640, 480, 16);
+ ok(rc==DD_OK, "SetDisplayMode(640, 480, 16) returned: %x\n",rc);
+ GetClientRect(hwnd, &cr);
+ GetWindowRect(hwnd, &wr);
+ checkrect(&cr, &ref_clientrect, "client rect");
+ checkrect(&wr, &ref_windowrect, "window rect");
+ rc = IDirectDraw_RestoreDisplayMode(lpDD);
+ ok(rc==DD_OK, "RestoreDisplayMode returned: %x\n",rc);
+
/* Set the focus window */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_SETFOCUSWINDOW);
@@ -365,6 +389,7 @@ static void testcooperativelevels_normal(void)
static void testcooperativelevels_exclusive(void)
{
HRESULT rc;
+ RECT cr1, cr2, cr3, wr1, wr2, wr3, ref;
/* Do some tests with DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN mode */
@@ -389,6 +414,31 @@ static void testcooperativelevels_exclusive(void)
ok(rc==DDERR_HWNDALREADYSET ||
broken(rc==DDERR_INVALIDPARAMS) /* NT4/Win95 */,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
+ /* Get current rects for the window, so we can check that the window size
+ * is properly restored later on
+ */
+ GetClientRect(hwnd, &cr1);
+ GetWindowRect(hwnd, &wr1);
+
+ /* Switch to 640x480, and check that the window size is updated */
+ 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.left = 0;
+ ref.top = 0;
+ ref.right = 640;
+ ref.bottom = 480;
+ checkrect(&cr2, &ref, "client rect");
+ checkrect(&wr2, &ref, "window rect");
+
+ /* Restore the display mode, and check that the window size is restored */
+ 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