ddraw: Ensure fullscreen size of fullscreen windows
Johan Gill
johan.gill at gmail.com
Mon Jul 26 17:19:52 CDT 2010
This patch fixes the long-standing regression bug 17215.
Enjoy, and provide feedback if you don't ;)
-------------- next part --------------
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index 502cc84..a250b01 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -619,6 +619,11 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
}
This->dest_window = hwnd;
}
+
+ /* Make sure the window is fullscreen */
+ if (hwnd) {
+ update_fullscreen_window(hwnd);
+ }
}
else if(cooplevel & DDSCL_EXCLUSIVE)
{
@@ -758,6 +763,16 @@ static HRESULT ddraw_set_display_mode(IDirectDraw7 *iface, DWORD Width, DWORD He
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) {
+ update_fullscreen_window(This->dest_window);
+ }
+ }
+
LeaveCriticalSection(&ddraw_cs);
switch(hr)
{
diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h
index 789c163..d933900 100644
--- a/dlls/ddraw/ddraw_private.h
+++ b/dlls/ddraw/ddraw_private.h
@@ -679,6 +679,7 @@ void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps) DECLSPEC_HIDDEN;
DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) DECLSPEC_HIDDEN;
void DDRAW_dump_DDSCAPS2(const DDSCAPS2 *in) DECLSPEC_HIDDEN;
void DDRAW_dump_cooperativelevel(DWORD cooplevel) DECLSPEC_HIDDEN;
+void update_fullscreen_window(HWND hwnd);
/* This only needs to be here as long the processvertices functionality of
* IDirect3DExecuteBuffer isn't in WineD3D */
diff --git a/dlls/ddraw/tests/ddrawmodes.c b/dlls/ddraw/tests/ddrawmodes.c
index 7818255..1151fbf 100644
--- a/dlls/ddraw/tests/ddrawmodes.c
+++ b/dlls/ddraw/tests/ddrawmodes.c
@@ -429,7 +429,7 @@ static void setdisplaymode(int i)
rc = GetClientRect(hwnd, &test);
ok(rc!=0, "GetClientRect returned %x\n", rc);
rc = EqualRect(&scrn, &test);
- todo_wine ok(rc!=0, "Fullscreen window has wrong size\n");
+ ok(rc!=0, "Fullscreen window has wrong size\n");
/* Check that switching to normal cooperative level
does not restore the display mode */
@@ -645,10 +645,16 @@ static void testcooperativelevels_normal(void)
static void testcooperativelevels_exclusive(void)
{
+ BOOL success;
HRESULT rc;
+ RECT window_rect;
/* Do some tests with DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN mode */
+ /* First, resize the window so it is not the same size as any screen */
+ success = SetWindowPos(hwnd, 0, 0, 0, 281, 92, 0);
+ ok(success, "SetWindowPos failed\n");
+
/* Try to set exclusive mode only */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_EXCLUSIVE);
@@ -663,6 +669,10 @@ static void testcooperativelevels_exclusive(void)
rc = IDirectDraw_SetCooperativeLevel(lpDD,
hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN) returned: %x\n",rc);
+ GetClientRect(hwnd, &window_rect);
+ /* rect_before_create is assumed to hold the screen rect */
+ rc = EqualRect(&rect_before_create, &window_rect);
+ ok(rc!=0, "Fullscreen window has wrong size\n");
/* Set the focus window. Should fail */
rc = IDirectDraw_SetCooperativeLevel(lpDD,
diff --git a/dlls/ddraw/utils.c b/dlls/ddraw/utils.c
index ed8b480..cc8348a 100644
--- a/dlls/ddraw/utils.c
+++ b/dlls/ddraw/utils.c
@@ -1232,3 +1232,11 @@ hr_ddraw_from_wined3d(HRESULT hr)
default: return hr;
}
}
+
+void update_fullscreen_window(HWND hwnd)
+{
+ int width, height;
+ width = GetSystemMetrics(SM_CXSCREEN);
+ height = GetSystemMetrics(SM_CYSCREEN);
+ SetWindowPos(hwnd, HWND_TOP, 0, 0, width, height, SWP_SHOWWINDOW);
+}
More information about the wine-patches
mailing list