Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/d3d8/tests/device.c | 2 --
dlls/d3d9/tests/device.c | 2 --
dlls/ddraw/ddraw.c | 31 +++++++++++++++++++++++++++----
dlls/ddraw/tests/ddrawmodes.c | 4 ----
dlls/dxgi/tests/dxgi.c | 2 --
dlls/wined3d/directx.c | 5 -----
6 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index ead5f47bf14..b9d838e5cd4 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -10152,7 +10152,6 @@ static void test_cursor_clipping(void)
get_virtual_rect(&virtual_rect);
ok(GetClipCursor(&clip_rect), "Adapter %u: GetClipCursor failed, error %#x.\n", adapter_idx,
GetLastError());
- todo_wine_if(!EqualRect(&clip_rect, &virtual_rect))
ok(EqualRect(&clip_rect, &virtual_rect), "Adapter %u: Expect clip rect %s, got %s.\n",
adapter_idx, wine_dbgstr_rect(&virtual_rect), wine_dbgstr_rect(&clip_rect));
@@ -10161,7 +10160,6 @@ static void test_cursor_clipping(void)
get_virtual_rect(&virtual_rect);
ok(GetClipCursor(&clip_rect), "Adapter %u: GetClipCursor failed, error %#x.\n", adapter_idx,
GetLastError());
- todo_wine_if(!EqualRect(&clip_rect, &virtual_rect))
ok(EqualRect(&clip_rect, &virtual_rect), "Adapter %u: Expect clip rect %s, got %s.\n",
adapter_idx, wine_dbgstr_rect(&virtual_rect), wine_dbgstr_rect(&clip_rect));
}
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index b84a35714cd..c65f0cd04da 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -13893,7 +13893,6 @@ static void test_cursor_clipping(void)
get_virtual_rect(&virtual_rect);
ok(GetClipCursor(&clip_rect), "Adapter %u: GetClipCursor failed, error %#x.\n", adapter_idx,
GetLastError());
- todo_wine_if(!EqualRect(&clip_rect, &virtual_rect))
ok(EqualRect(&clip_rect, &virtual_rect), "Adapter %u: Expect clip rect %s, got %s.\n",
adapter_idx, wine_dbgstr_rect(&virtual_rect), wine_dbgstr_rect(&clip_rect));
@@ -13902,7 +13901,6 @@ static void test_cursor_clipping(void)
get_virtual_rect(&virtual_rect);
ok(GetClipCursor(&clip_rect), "Adapter %u: GetClipCursor failed, error %#x.\n", adapter_idx,
GetLastError());
- todo_wine_if(!EqualRect(&clip_rect, &virtual_rect))
ok(EqualRect(&clip_rect, &virtual_rect), "Adapter %u: Expect clip rect %s, got %s.\n",
adapter_idx, wine_dbgstr_rect(&virtual_rect), wine_dbgstr_rect(&clip_rect));
}
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index db7fc2c9486..95e9fba9011 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -665,6 +665,8 @@ static HRESULT ddraw_create_swapchain(struct ddraw *ddraw, HWND window, BOOL win
static HRESULT WINAPI ddraw7_RestoreDisplayMode(IDirectDraw7 *iface)
{
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
+ struct wined3d_display_mode mode;
+ RECT clip_rect;
HRESULT hr;
TRACE("iface %p.\n", iface);
@@ -684,7 +686,15 @@ static HRESULT WINAPI ddraw7_RestoreDisplayMode(IDirectDraw7 *iface)
}
if (SUCCEEDED(hr = wined3d_output_set_display_mode(ddraw->wined3d_output, NULL)))
+ {
ddraw->flags &= ~DDRAW_RESTORE_MODE;
+ if (ddraw->cooperative_level & DDSCL_EXCLUSIVE &&
+ SUCCEEDED(hr = wined3d_output_get_display_mode(ddraw->wined3d_output, &mode, NULL)))
+ {
+ SetRect(&clip_rect, 0, 0, mode.width, mode.height);
+ ClipCursor(&clip_rect);
+ }
+ }
InterlockedCompareExchange(&ddraw->device_state, DDRAW_DEVICE_STATE_NOT_RESTORED, DDRAW_DEVICE_STATE_OK);
@@ -768,6 +778,7 @@ static HRESULT ddraw_set_cooperative_level(struct ddraw *ddraw, HWND window,
struct wined3d_rendertarget_view *rtv = NULL, *dsv = NULL;
struct wined3d_stateblock *stateblock;
BOOL restore_state = FALSE;
+ RECT clip_rect;
HRESULT hr;
TRACE("ddraw %p, window %p, flags %#x, restore_mode_on_normal %x.\n", ddraw, window, cooplevel,
@@ -942,12 +953,11 @@ static HRESULT ddraw_set_cooperative_level(struct ddraw *ddraw, HWND window,
wined3d_stateblock_decref(stateblock);
}
- if (!(cooplevel & DDSCL_EXCLUSIVE) && (ddraw->cooperative_level & DDSCL_EXCLUSIVE)
- && restore_mode_on_normal)
+ if (!(cooplevel & DDSCL_EXCLUSIVE) && (ddraw->cooperative_level & DDSCL_EXCLUSIVE))
{
- hr = ddraw7_RestoreDisplayMode(&ddraw->IDirectDraw7_iface);
- if (FAILED(hr))
+ if (restore_mode_on_normal && FAILED(ddraw7_RestoreDisplayMode(&ddraw->IDirectDraw7_iface)))
ERR("RestoreDisplayMode failed\n");
+ ClipCursor(NULL);
}
if ((ddraw->cooperative_level & DDSCL_EXCLUSIVE)
@@ -965,6 +975,12 @@ static HRESULT ddraw_set_cooperative_level(struct ddraw *ddraw, HWND window,
}
}
+ if (cooplevel & DDSCL_EXCLUSIVE)
+ {
+ SetRect(&clip_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
+ ClipCursor(&clip_rect);
+ }
+
/* Unhandled flags */
if (cooplevel & DDSCL_ALLOWREBOOT)
WARN("Unhandled flag DDSCL_ALLOWREBOOT, harmless\n");
@@ -1059,6 +1075,7 @@ static HRESULT WINAPI ddraw7_SetDisplayMode(IDirectDraw7 *iface, DWORD width, DW
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
struct wined3d_display_mode mode;
enum wined3d_format_id format;
+ RECT clip_rect;
HRESULT hr;
TRACE("iface %p, width %u, height %u, bpp %u, refresh_rate %u, flags %#x.\n",
@@ -1117,6 +1134,12 @@ static HRESULT WINAPI ddraw7_SetDisplayMode(IDirectDraw7 *iface, DWORD width, DW
ddrawformat_from_wined3dformat(&ddraw->primary->surface_desc.u4.ddpfPixelFormat, mode.format_id);
}
ddraw->flags |= DDRAW_RESTORE_MODE;
+
+ if (ddraw->cooperative_level & DDSCL_EXCLUSIVE)
+ {
+ SetRect(&clip_rect, 0, 0, width, height);
+ ClipCursor(&clip_rect);
+ }
}
InterlockedCompareExchange(&ddraw->device_state, DDRAW_DEVICE_STATE_NOT_RESTORED, DDRAW_DEVICE_STATE_OK);
diff --git a/dlls/ddraw/tests/ddrawmodes.c b/dlls/ddraw/tests/ddrawmodes.c
index 144f284b76c..d5b90effc18 100644
--- a/dlls/ddraw/tests/ddrawmodes.c
+++ b/dlls/ddraw/tests/ddrawmodes.c
@@ -613,7 +613,6 @@ static void testcursorclipping(void)
flush_events();
get_virtual_rect(&rect);
ok(GetClipCursor(&clip_rect), "GetClipCursor failed, error %#x.\n", GetLastError());
- todo_wine_if(!EqualRect(&clip_rect, &rect))
ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
wine_dbgstr_rect(&clip_rect));
@@ -622,7 +621,6 @@ static void testcursorclipping(void)
flush_events();
get_virtual_rect(&rect);
ok(GetClipCursor(&clip_rect), "GetClipCursor failed, error %#x.\n", GetLastError());
- todo_wine_if(GetSystemMetrics(SM_CMONITORS) > 1)
ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
wine_dbgstr_rect(&clip_rect));
@@ -633,7 +631,6 @@ static void testcursorclipping(void)
flush_events();
SetRect(&rect, 0, 0, primary_width, primary_height);
ok(GetClipCursor(&clip_rect), "GetClipCursor failed, error %#x.\n", GetLastError());
- todo_wine_if(GetSystemMetrics(SM_CMONITORS) > 1)
ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
wine_dbgstr_rect(&clip_rect));
@@ -666,7 +663,6 @@ static void testcursorclipping(void)
flush_events();
get_virtual_rect(&rect);
ok(GetClipCursor(&clip_rect), "GetClipCursor failed, error %#x.\n", GetLastError());
- todo_wine_if(GetSystemMetrics(SM_CMONITORS) > 1)
ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
wine_dbgstr_rect(&clip_rect));
}
diff --git a/dlls/dxgi/tests/dxgi.c b/dlls/dxgi/tests/dxgi.c
index e44bfa30657..5b09dedb5b4 100644
--- a/dlls/dxgi/tests/dxgi.c
+++ b/dlls/dxgi/tests/dxgi.c
@@ -6120,7 +6120,6 @@ static void test_cursor_clipping(IUnknown *device, BOOL is_d3d12)
ok(GetClipCursor(&clip_rect),
"Adapter %u output %u: GetClipCursor failed, error %#x.\n", adapter_idx,
output_idx, GetLastError());
- todo_wine_if(!EqualRect(&clip_rect, &virtual_rect))
ok(EqualRect(&clip_rect, &virtual_rect),
"Adapter %u output %u: Expect clip rect %s, got %s.\n", adapter_idx, output_idx,
wine_dbgstr_rect(&virtual_rect), wine_dbgstr_rect(&clip_rect));
@@ -6140,7 +6139,6 @@ static void test_cursor_clipping(IUnknown *device, BOOL is_d3d12)
ok(GetClipCursor(&clip_rect),
"Adapter %u output %u: GetClipCursor failed, error %#x.\n", adapter_idx,
output_idx, GetLastError());
- todo_wine_if(!EqualRect(&clip_rect, &virtual_rect))
ok(EqualRect(&clip_rect, &virtual_rect),
"Adapter %u output %u: Expect clip rect %s, got %s.\n", adapter_idx, output_idx,
wine_dbgstr_rect(&virtual_rect), wine_dbgstr_rect(&clip_rect));
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index cb3e0dd1041..42e1578561f 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -1260,7 +1260,6 @@ HRESULT CDECL wined3d_output_set_display_mode(struct wined3d_output *output,
const struct wined3d_display_mode *mode)
{
DEVMODEW new_mode, current_mode;
- RECT clip_rc;
LONG ret;
enum wined3d_format_id new_format_id;
@@ -1341,10 +1340,6 @@ HRESULT CDECL wined3d_output_set_display_mode(struct wined3d_output *output,
/* Store the new values. */
output->screen_format = new_format_id;
- /* And finally clip mouse to our screen. */
- SetRect(&clip_rc, 0, 0, new_mode.dmPelsWidth, new_mode.dmPelsHeight);
- ClipCursor(&clip_rc);
-
return WINED3D_OK;
}
--
2.20.1