Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- v3: Supersede 195318. Don't call ChangeDisplaySettings() when restoring to the same display mode for fixing ddraw test failures. Also note that ChangeDisplaySettings() may reapply mode changes with or without CDS_RESET on Windows with the same display mode. See https://testbot.winehq.org/JobDetails.pl?Key=81319. So it's better to avoid setting redundant modes in wined3d as it is inconclusive that ChangeDisplaySettings() should filter out redundant mode changes.
dlls/d3d8/tests/device.c | 30 +++---- dlls/d3d9/tests/device.c | 30 +++---- dlls/ddraw/ddraw.c | 2 +- dlls/ddraw/tests/ddraw1.c | 10 +-- dlls/ddraw/tests/ddraw2.c | 10 +-- dlls/ddraw/tests/ddraw4.c | 10 +-- dlls/ddraw/tests/ddraw7.c | 10 +-- dlls/dxgi/tests/dxgi.c | 14 ++-- dlls/wined3d/directx.c | 170 +++++++++++++++++++++++++++++--------- dlls/wined3d/swapchain.c | 55 ++++++------ dlls/wined3d/wined3d.spec | 1 + include/wine/wined3d.h | 1 + 12 files changed, 221 insertions(+), 122 deletions(-)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index 8d33026d6e5..45cf0f20eda 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -4326,7 +4326,7 @@ static void test_mode_change(void)
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode); ok(ret, "Failed to get display mode.\n"); - todo_wine ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth + ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth && devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Expected resolution %ux%u, got %ux%u.\n", registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, devmode.dmPelsWidth, devmode.dmPelsHeight); @@ -4399,7 +4399,7 @@ static void test_mode_change(void)
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(equal_mode_rect(&devmode2, &devmode), "Got a different mode.\n"); + ok(equal_mode_rect(&devmode2, &devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(equal_mode_rect(&devmode2, &devmode), "Got a different mode.\n"); @@ -4434,7 +4434,7 @@ static void test_mode_change(void)
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(equal_mode_rect(&devmode2, &devmode), "Got a different mode.\n"); + ok(equal_mode_rect(&devmode2, &devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(equal_mode_rect(&devmode2, &devmode), "Got a different mode.\n"); @@ -4517,15 +4517,15 @@ static void test_mode_change(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); hr = IDirect3D8_GetAdapterDisplayMode(d3d8, 1, &d3ddm); ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#x.\n", hr); - todo_wine ok(d3ddm.Width == old_devmode.dmPelsWidth, "Expected width %u, got %u.\n", + ok(d3ddm.Width == old_devmode.dmPelsWidth, "Expected width %u, got %u.\n", old_devmode.dmPelsWidth, d3ddm.Width); - todo_wine ok(d3ddm.Height == old_devmode.dmPelsHeight, "Expected height %u, got %u.\n", + ok(d3ddm.Height == old_devmode.dmPelsHeight, "Expected height %u, got %u.\n", old_devmode.dmPelsHeight, d3ddm.Height);
refcount = IDirect3DDevice8_Release(device); @@ -4550,15 +4550,15 @@ static void test_mode_change(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); hr = IDirect3D8_GetAdapterDisplayMode(d3d8, 1, &d3ddm); ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#x.\n", hr); - todo_wine ok(d3ddm.Width == old_devmode.dmPelsWidth, "Expected width %u, got %u.\n", + ok(d3ddm.Width == old_devmode.dmPelsWidth, "Expected width %u, got %u.\n", old_devmode.dmPelsWidth, d3ddm.Width); - todo_wine ok(d3ddm.Height == old_devmode.dmPelsHeight, "Expected height %u, got %u.\n", + ok(d3ddm.Height == old_devmode.dmPelsHeight, "Expected height %u, got %u.\n", old_devmode.dmPelsHeight, d3ddm.Height); ret = restore_display_modes(original_modes, display_count); ok(ret, "Failed to restore display modes.\n"); @@ -4576,7 +4576,7 @@ static void test_mode_change(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight, + ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight, "Expected resolution %ux%u, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight, devmode2.dmPelsWidth, devmode2.dmPelsHeight); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); @@ -4586,7 +4586,7 @@ static void test_mode_change(void) devmode2.dmPelsWidth, devmode2.dmPelsHeight); hr = IDirect3D8_GetAdapterDisplayMode(d3d8, 1, &d3ddm); ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#x.\n", hr); - todo_wine ok(d3ddm.Width == devmode.dmPelsWidth && d3ddm.Height == devmode.dmPelsHeight, + ok(d3ddm.Width == devmode.dmPelsWidth && d3ddm.Height == devmode.dmPelsHeight, "Expected resolution %ux%u, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight, d3ddm.Width, d3ddm.Height); ret = restore_display_modes(original_modes, display_count); @@ -4613,13 +4613,13 @@ static void test_mode_change(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); hr = IDirect3D8_GetAdapterDisplayMode(d3d8, 1, &d3ddm); ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#x.\n", hr); - todo_wine ok(d3ddm.Width == old_devmode.dmPelsWidth && d3ddm.Height == old_devmode.dmPelsHeight, + ok(d3ddm.Width == old_devmode.dmPelsWidth && d3ddm.Height == old_devmode.dmPelsHeight, "Expected resolution %ux%u, got %ux%u.\n", old_devmode.dmPelsWidth, old_devmode.dmPelsHeight, d3ddm.Width, d3ddm.Height);
@@ -4645,13 +4645,13 @@ static void test_mode_change(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); hr = IDirect3D8_GetAdapterDisplayMode(d3d8, 1, &d3ddm); ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#x.\n", hr); - todo_wine ok(d3ddm.Width == old_devmode.dmPelsWidth && d3ddm.Height == old_devmode.dmPelsHeight, + ok(d3ddm.Width == old_devmode.dmPelsWidth && d3ddm.Height == old_devmode.dmPelsHeight, "Expected resolution %ux%u, got %ux%u.\n", old_devmode.dmPelsWidth, old_devmode.dmPelsHeight, d3ddm.Width, d3ddm.Height);
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index 3f18678291e..2791e91a068 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -5413,7 +5413,7 @@ static void test_mode_change(void)
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode); ok(ret, "Failed to get display mode.\n"); - todo_wine ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth + ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth && devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Expected resolution %ux%u, got %ux%u.\n", registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, devmode.dmPelsWidth, devmode.dmPelsHeight); @@ -5486,7 +5486,7 @@ static void test_mode_change(void)
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(equal_mode_rect(&devmode2, &devmode), "Got a different mode.\n"); + ok(equal_mode_rect(&devmode2, &devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(equal_mode_rect(&devmode2, &devmode), "Got a different mode.\n"); @@ -5521,7 +5521,7 @@ static void test_mode_change(void)
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(equal_mode_rect(&devmode2, &devmode), "Got a different mode.\n"); + ok(equal_mode_rect(&devmode2, &devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(equal_mode_rect(&devmode2, &devmode), "Got a different mode.\n"); @@ -5604,15 +5604,15 @@ static void test_mode_change(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); hr = IDirect3D9_GetAdapterDisplayMode(d3d9, 1, &d3ddm); ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#x.\n", hr); - todo_wine ok(d3ddm.Width == old_devmode.dmPelsWidth, "Expected width %u, got %u.\n", + ok(d3ddm.Width == old_devmode.dmPelsWidth, "Expected width %u, got %u.\n", old_devmode.dmPelsWidth, d3ddm.Width); - todo_wine ok(d3ddm.Height == old_devmode.dmPelsHeight, "Expected height %u, got %u.\n", + ok(d3ddm.Height == old_devmode.dmPelsHeight, "Expected height %u, got %u.\n", old_devmode.dmPelsHeight, d3ddm.Height);
refcount = IDirect3DDevice9_Release(device); @@ -5637,15 +5637,15 @@ static void test_mode_change(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); hr = IDirect3D9_GetAdapterDisplayMode(d3d9, 1, &d3ddm); ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#x.\n", hr); - todo_wine ok(d3ddm.Width == old_devmode.dmPelsWidth, "Expected width %u, got %u.\n", + ok(d3ddm.Width == old_devmode.dmPelsWidth, "Expected width %u, got %u.\n", old_devmode.dmPelsWidth, d3ddm.Width); - todo_wine ok(d3ddm.Height == old_devmode.dmPelsHeight, "Expected height %u, got %u.\n", + ok(d3ddm.Height == old_devmode.dmPelsHeight, "Expected height %u, got %u.\n", old_devmode.dmPelsHeight, d3ddm.Height); ret = restore_display_modes(original_modes, display_count); ok(ret, "Failed to restore display modes.\n"); @@ -5663,7 +5663,7 @@ static void test_mode_change(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight, + ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight, "Expected resolution %ux%u, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight, devmode2.dmPelsWidth, devmode2.dmPelsHeight); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); @@ -5673,7 +5673,7 @@ static void test_mode_change(void) devmode2.dmPelsWidth, devmode2.dmPelsHeight); hr = IDirect3D9_GetAdapterDisplayMode(d3d9, 1, &d3ddm); ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#x.\n", hr); - todo_wine ok(d3ddm.Width == devmode.dmPelsWidth && d3ddm.Height == devmode.dmPelsHeight, + ok(d3ddm.Width == devmode.dmPelsWidth && d3ddm.Height == devmode.dmPelsHeight, "Expected resolution %ux%u, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight, d3ddm.Width, d3ddm.Height); ret = restore_display_modes(original_modes, display_count); @@ -5700,13 +5700,13 @@ static void test_mode_change(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); hr = IDirect3D9_GetAdapterDisplayMode(d3d9, 1, &d3ddm); ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#x.\n", hr); - todo_wine ok(d3ddm.Width == old_devmode.dmPelsWidth && d3ddm.Height == old_devmode.dmPelsHeight, + ok(d3ddm.Width == old_devmode.dmPelsWidth && d3ddm.Height == old_devmode.dmPelsHeight, "Expected resolution %ux%u, got %ux%u.\n", old_devmode.dmPelsWidth, old_devmode.dmPelsHeight, d3ddm.Width, d3ddm.Height);
@@ -5732,13 +5732,13 @@ static void test_mode_change(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); hr = IDirect3D9_GetAdapterDisplayMode(d3d9, 1, &d3ddm); ok(hr == S_OK, "GetAdapterDisplayMode failed, hr %#x.\n", hr); - todo_wine ok(d3ddm.Width == old_devmode.dmPelsWidth && d3ddm.Height == old_devmode.dmPelsHeight, + ok(d3ddm.Width == old_devmode.dmPelsWidth && d3ddm.Height == old_devmode.dmPelsHeight, "Expected resolution %ux%u, got %ux%u.\n", old_devmode.dmPelsWidth, old_devmode.dmPelsHeight, d3ddm.Width, d3ddm.Height);
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index 11a16f8d535..f78d344c085 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -698,7 +698,7 @@ static HRESULT WINAPI ddraw7_RestoreDisplayMode(IDirectDraw7 *iface) return DDERR_NOEXCLUSIVEMODE; }
- if (SUCCEEDED(hr = wined3d_output_set_display_mode(ddraw->wined3d_output, NULL))) + if (SUCCEEDED(hr = wined3d_restore_display_modes(ddraw->wined3d))) { ddraw->flags &= ~DDRAW_RESTORE_MODE; if (ddraw->cooperative_level & DDSCL_EXCLUSIVE && diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index 783c1b961a0..e1a315f291f 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -3784,7 +3784,7 @@ static void test_coop_level_mode_set_multi(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); @@ -3805,7 +3805,7 @@ static void test_coop_level_mode_set_multi(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); @@ -3830,7 +3830,7 @@ static void test_coop_level_mode_set_multi(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight, + ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight, "Expected resolution %ux%u, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight, devmode2.dmPelsWidth, devmode2.dmPelsHeight); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); @@ -3860,7 +3860,7 @@ static void test_coop_level_mode_set_multi(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); @@ -3891,7 +3891,7 @@ static void test_coop_level_mode_set_multi(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index 23d3e0c1f02..849d510a349 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -3944,7 +3944,7 @@ static void test_coop_level_mode_set_multi(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); @@ -3965,7 +3965,7 @@ static void test_coop_level_mode_set_multi(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); @@ -3990,7 +3990,7 @@ static void test_coop_level_mode_set_multi(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight, + ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight, "Expected resolution %ux%u, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight, devmode2.dmPelsWidth, devmode2.dmPelsHeight); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); @@ -4020,7 +4020,7 @@ static void test_coop_level_mode_set_multi(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); @@ -4051,7 +4051,7 @@ static void test_coop_level_mode_set_multi(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 12cfbc3784f..56a4777add5 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -4172,7 +4172,7 @@ static void test_coop_level_mode_set_multi(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); @@ -4193,7 +4193,7 @@ static void test_coop_level_mode_set_multi(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); @@ -4218,7 +4218,7 @@ static void test_coop_level_mode_set_multi(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight, + ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight, "Expected resolution %ux%u, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight, devmode2.dmPelsWidth, devmode2.dmPelsHeight); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); @@ -4248,7 +4248,7 @@ static void test_coop_level_mode_set_multi(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); @@ -4279,7 +4279,7 @@ static void test_coop_level_mode_set_multi(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index c214cbc221e..c9ba50287be 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -3819,7 +3819,7 @@ static void test_coop_level_mode_set_multi(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); @@ -3840,7 +3840,7 @@ static void test_coop_level_mode_set_multi(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); @@ -3865,7 +3865,7 @@ static void test_coop_level_mode_set_multi(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight, + ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight, "Expected resolution %ux%u, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight, devmode2.dmPelsWidth, devmode2.dmPelsHeight); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); @@ -3895,7 +3895,7 @@ static void test_coop_level_mode_set_multi(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); @@ -3926,7 +3926,7 @@ static void test_coop_level_mode_set_multi(void)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); diff --git a/dlls/dxgi/tests/dxgi.c b/dlls/dxgi/tests/dxgi.c index 4d9677b3762..e6c8e0eb8c4 100644 --- a/dlls/dxgi/tests/dxgi.c +++ b/dlls/dxgi/tests/dxgi.c @@ -7097,7 +7097,7 @@ static void test_mode_change(IUnknown *device, BOOL is_d3d12)
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(equal_mode_rect(&devmode2, &devmode), "Got a different mode.\n"); + ok(equal_mode_rect(&devmode2, &devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(equal_mode_rect(&devmode2, &devmode), "Got a different mode.\n"); @@ -7196,16 +7196,16 @@ static void test_mode_change(IUnknown *device, BOOL is_d3d12)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); + ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); ok(equal_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n"); hr = IDXGIOutput_GetDesc(second_output, &output_desc); ok(hr == S_OK, "GetDesc failed, hr %#x.\n", hr); - todo_wine ok(output_desc.DesktopCoordinates.right - output_desc.DesktopCoordinates.left == + ok(output_desc.DesktopCoordinates.right - output_desc.DesktopCoordinates.left == old_devmode.dmPelsWidth, "Expected width %u, got %u.\n", old_devmode.dmPelsWidth, output_desc.DesktopCoordinates.right - output_desc.DesktopCoordinates.left); - todo_wine ok(output_desc.DesktopCoordinates.bottom - output_desc.DesktopCoordinates.top == + ok(output_desc.DesktopCoordinates.bottom - output_desc.DesktopCoordinates.top == old_devmode.dmPelsHeight, "Expected height %u, got %u.\n", old_devmode.dmPelsHeight, output_desc.DesktopCoordinates.bottom - output_desc.DesktopCoordinates.top);
@@ -7228,7 +7228,7 @@ static void test_mode_change(IUnknown *device, BOOL is_d3d12)
ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2); ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError()); - todo_wine ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight, + ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight, "Expected resolution %ux%u, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight, devmode2.dmPelsWidth, devmode2.dmPelsHeight); ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2); @@ -7238,10 +7238,10 @@ static void test_mode_change(IUnknown *device, BOOL is_d3d12) devmode2.dmPelsWidth, devmode2.dmPelsHeight); hr = IDXGIOutput_GetDesc(second_output, &output_desc); ok(hr == S_OK, "GetDesc failed, hr %#x.\n", hr); - todo_wine ok(output_desc.DesktopCoordinates.right - output_desc.DesktopCoordinates.left == + ok(output_desc.DesktopCoordinates.right - output_desc.DesktopCoordinates.left == devmode.dmPelsWidth, "Expected width %u, got %u.\n", devmode.dmPelsWidth, output_desc.DesktopCoordinates.right - output_desc.DesktopCoordinates.left); - todo_wine ok(output_desc.DesktopCoordinates.bottom - output_desc.DesktopCoordinates.top == + ok(output_desc.DesktopCoordinates.bottom - output_desc.DesktopCoordinates.top == devmode.dmPelsHeight, "Expected height %u, got %u.\n", devmode.dmPelsHeight, output_desc.DesktopCoordinates.bottom - output_desc.DesktopCoordinates.top);
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index c11fa22cc38..50b1376a75b 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -1320,67 +1320,155 @@ HRESULT CDECL wined3d_output_get_display_mode(const struct wined3d_output *outpu return WINED3D_OK; }
+static BOOL equal_display_mode(const DEVMODEW *mode1, const DEVMODEW *mode2) +{ + if (mode1->dmFields & mode2->dmFields & DM_PELSWIDTH + && mode1->dmPelsWidth != mode2->dmPelsWidth) + return FALSE; + + if (mode1->dmFields & mode2->dmFields & DM_PELSHEIGHT + && mode1->dmPelsHeight != mode2->dmPelsHeight) + return FALSE; + + if (mode1->dmFields & mode2->dmFields & DM_BITSPERPEL + && mode1->dmBitsPerPel != mode2->dmBitsPerPel) + return FALSE; + + if (mode1->dmFields & mode2->dmFields & DM_DISPLAYFLAGS + && mode1->u2.dmDisplayFlags != mode2->u2.dmDisplayFlags) + return FALSE; + + if (mode1->dmFields & mode2->dmFields & DM_DISPLAYFREQUENCY + && mode1->dmDisplayFrequency != mode2->dmDisplayFrequency) + return FALSE; + + if (mode1->dmFields & mode2->dmFields & DM_DISPLAYORIENTATION + && mode1->u1.s2.dmDisplayOrientation != mode2->u1.s2.dmDisplayOrientation) + return FALSE; + + if (mode1->dmFields & mode2->dmFields & DM_POSITION + && (mode1->u1.s2.dmPosition.x != mode2->u1.s2.dmPosition.x + || mode1->u1.s2.dmPosition.y != mode2->u1.s2.dmPosition.y)) + return FALSE; + + return TRUE; +} + +HRESULT CDECL wined3d_restore_display_modes(struct wined3d *wined3d) +{ + unsigned int adapter_idx, output_idx = 0; + DEVMODEW current_mode, registry_mode; + struct wined3d_adapter *adapter; + DISPLAY_DEVICEW display_device; + struct wined3d_output *output; + BOOL do_mode_change = FALSE; + LONG ret; + + TRACE("wined3d %p.\n", wined3d); + + memset(¤t_mode, 0, sizeof(current_mode)); + memset(®istry_mode, 0, sizeof(registry_mode)); + current_mode.dmSize = sizeof(current_mode); + registry_mode.dmSize = sizeof(registry_mode); + display_device.cb = sizeof(display_device); + while (EnumDisplayDevicesW(NULL, output_idx++, &display_device, 0)) + { + if (!EnumDisplaySettingsExW(display_device.DeviceName, ENUM_CURRENT_SETTINGS, ¤t_mode, 0)) + { + ERR("Failed to read the current display mode for %s.\n", + wine_dbgstr_w(display_device.DeviceName)); + return WINED3DERR_NOTAVAILABLE; + } + + if (!EnumDisplaySettingsExW(display_device.DeviceName, ENUM_REGISTRY_SETTINGS, ®istry_mode, 0)) + { + ERR("Failed to read the registry display mode for %s.\n", + wine_dbgstr_w(display_device.DeviceName)); + return WINED3DERR_NOTAVAILABLE; + } + + if (!equal_display_mode(¤t_mode, ®istry_mode)) + { + do_mode_change = TRUE; + break; + } + } + + if (do_mode_change) + { + ret = ChangeDisplaySettingsExW(NULL, NULL, NULL, 0, NULL); + if (ret != DISP_CHANGE_SUCCESSFUL) + { + ERR("Failed to restore all outputs to their registry display settings, error %d.\n", ret); + return WINED3DERR_NOTAVAILABLE; + } + } + else + { + TRACE("Skipping redundant mode setting call.\n"); + } + + for (adapter_idx = 0; adapter_idx < wined3d->adapter_count; ++adapter_idx) + { + adapter = wined3d->adapters[adapter_idx]; + for (output_idx = 0; output_idx < adapter->output_count; ++output_idx) + { + output = &adapter->outputs[output_idx]; + + if (!EnumDisplaySettingsExW(output->device_name, ENUM_CURRENT_SETTINGS, ¤t_mode, 0)) + { + ERR("Failed to read the current display mode for %s.\n", + wine_dbgstr_w(output->device_name)); + return WINED3DERR_NOTAVAILABLE; + } + + output->screen_format = pixelformat_for_depth(current_mode.dmBitsPerPel); + } + } + + return WINED3D_OK; +} + HRESULT CDECL wined3d_output_set_display_mode(struct wined3d_output *output, const struct wined3d_display_mode *mode) { + enum wined3d_format_id new_format_id; + const struct wined3d_format *format; DEVMODEW new_mode, current_mode; LONG ret; - enum wined3d_format_id new_format_id;
TRACE("output %p, mode %p.\n", output, mode); + TRACE("mode %ux%u@%u %s %#x.\n", mode->width, mode->height, mode->refresh_rate, + debug_d3dformat(mode->format_id), mode->scanline_ordering);
memset(&new_mode, 0, sizeof(new_mode)); new_mode.dmSize = sizeof(new_mode); memset(¤t_mode, 0, sizeof(current_mode)); current_mode.dmSize = sizeof(current_mode); - if (mode) + + format = wined3d_get_format(output->adapter, mode->format_id, WINED3D_BIND_RENDER_TARGET); + + new_mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; + new_mode.dmBitsPerPel = format->byte_count * CHAR_BIT; + new_mode.dmPelsWidth = mode->width; + new_mode.dmPelsHeight = mode->height; + new_mode.dmDisplayFrequency = mode->refresh_rate; + if (mode->refresh_rate) + new_mode.dmFields |= DM_DISPLAYFREQUENCY; + if (mode->scanline_ordering != WINED3D_SCANLINE_ORDERING_UNKNOWN) { - const struct wined3d_format *format; - - TRACE("mode %ux%u@%u %s %#x.\n", mode->width, mode->height, mode->refresh_rate, - debug_d3dformat(mode->format_id), mode->scanline_ordering); - - format = wined3d_get_format(output->adapter, mode->format_id, WINED3D_BIND_RENDER_TARGET); - - new_mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; - new_mode.dmBitsPerPel = format->byte_count * CHAR_BIT; - new_mode.dmPelsWidth = mode->width; - new_mode.dmPelsHeight = mode->height; - - new_mode.dmDisplayFrequency = mode->refresh_rate; - if (mode->refresh_rate) - new_mode.dmFields |= DM_DISPLAYFREQUENCY; - - if (mode->scanline_ordering != WINED3D_SCANLINE_ORDERING_UNKNOWN) - { - new_mode.dmFields |= DM_DISPLAYFLAGS; - if (mode->scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED) - new_mode.u2.dmDisplayFlags |= DM_INTERLACED; - } - new_format_id = mode->format_id; - } - else - { - if (!EnumDisplaySettingsW(output->device_name, ENUM_REGISTRY_SETTINGS, &new_mode)) - { - ERR("Failed to read mode from registry.\n"); - return WINED3DERR_NOTAVAILABLE; - } - new_format_id = pixelformat_for_depth(new_mode.dmBitsPerPel); + new_mode.dmFields |= DM_DISPLAYFLAGS; + if (mode->scanline_ordering == WINED3D_SCANLINE_ORDERING_INTERLACED) + new_mode.u2.dmDisplayFlags |= DM_INTERLACED; } + new_format_id = mode->format_id;
/* Only change the mode if necessary. */ if (!EnumDisplaySettingsW(output->device_name, ENUM_CURRENT_SETTINGS, ¤t_mode)) { ERR("Failed to get current display mode.\n"); } - else if (current_mode.dmPelsWidth == new_mode.dmPelsWidth - && current_mode.dmPelsHeight == new_mode.dmPelsHeight - && current_mode.dmBitsPerPel == new_mode.dmBitsPerPel - && (current_mode.dmDisplayFrequency == new_mode.dmDisplayFrequency - || !(new_mode.dmFields & DM_DISPLAYFREQUENCY)) - && (current_mode.u2.dmDisplayFlags == new_mode.u2.dmDisplayFlags - || !(new_mode.dmFields & DM_DISPLAYFLAGS))) + else if (equal_display_mode(¤t_mode, &new_mode)) { TRACE("Skipping redundant mode setting call.\n"); output->screen_format = new_format_id; diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index 847907c6d4c..7e46e5c6150 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -28,8 +28,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d);
void wined3d_swapchain_cleanup(struct wined3d_swapchain *swapchain) { - struct wined3d_output *output; - HRESULT hr = E_FAIL; + HRESULT hr; UINT i;
TRACE("Destroying swapchain %p.\n", swapchain); @@ -71,9 +70,7 @@ void wined3d_swapchain_cleanup(struct wined3d_swapchain *swapchain) { if (swapchain->state.desc.auto_restore_display_mode) { - output = wined3d_swapchain_get_output(swapchain); - if (!output || FAILED(hr = wined3d_output_set_display_mode(output, - &swapchain->state.original_mode))) + if (FAILED(hr = wined3d_restore_display_modes(swapchain->device->wined3d))) ERR("Failed to restore display mode, hr %#x.\n", hr);
if (swapchain->state.desc.flags & WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT) @@ -1543,8 +1540,7 @@ static HRESULT wined3d_swapchain_init(struct wined3d_swapchain *swapchain, struc err: if (displaymode_set) { - if (FAILED(wined3d_output_set_display_mode(desc->output, - &swapchain->state.original_mode))) + if (FAILED(wined3d_restore_display_modes(device->wined3d))) ERR("Failed to restore display mode.\n"); }
@@ -1791,13 +1787,6 @@ void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activa if (!(focus_messages = device->wined3d->flags & WINED3D_FOCUS_MESSAGES)) filter = wined3d_filter_messages(window, TRUE);
- output = wined3d_swapchain_get_output(swapchain); - if (!output) - { - ERR("Failed to get output from swapchain %p.\n", swapchain); - return; - } - if (activate) { SystemParametersInfoW(SPI_GETSCREENSAVEACTIVE, 0, &screensaver_active, 0); @@ -1813,6 +1802,13 @@ void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activa * * Guild Wars 1 wants a WINDOWPOSCHANGED message on the device window to * resume drawing after a focus loss. */ + output = wined3d_swapchain_get_output(swapchain); + if (!output) + { + ERR("Failed to get output from swapchain %p.\n", swapchain); + return; + } + if (SUCCEEDED(hr = wined3d_output_get_desc(output, &output_desc))) SetWindowPos(window, NULL, output_desc.desktop_rect.left, output_desc.desktop_rect.top, swapchain->state.desc.backbuffer_width, @@ -1823,6 +1819,13 @@ void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activa
if (device->wined3d->flags & WINED3D_RESTORE_MODE_ON_ACTIVATE) { + output = wined3d_swapchain_get_output(swapchain); + if (!output) + { + ERR("Failed to get output from swapchain %p.\n", swapchain); + return; + } + if (FAILED(hr = wined3d_output_set_display_mode(output, &swapchain->state.d3d_mode))) ERR("Failed to set display mode, hr %#x.\n", hr); @@ -1839,8 +1842,8 @@ void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activa device->restore_screensaver = FALSE; }
- if (FAILED(hr = wined3d_output_set_display_mode(output, NULL))) - ERR("Failed to set display mode, hr %#x.\n", hr); + if (FAILED(hr = wined3d_restore_display_modes(device->wined3d))) + ERR("Failed to restore display modes, hr %#x.\n", hr);
swapchain->reapply_mode = TRUE;
@@ -1974,9 +1977,9 @@ static HRESULT wined3d_swapchain_state_set_display_mode(struct wined3d_swapchain
if (output != state->desc.output) { - if (FAILED(hr = wined3d_output_set_display_mode(state->desc.output, &state->original_mode))) + if (FAILED(hr = wined3d_restore_display_modes(state->wined3d))) { - WARN("Failed to set display mode, hr %#x.\n", hr); + WARN("Failed to restore display modes, hr %#x.\n", hr); return hr; }
@@ -2199,6 +2202,9 @@ HRESULT CDECL wined3d_swapchain_state_set_fullscreen(struct wined3d_swapchain_st if (mode) { actual_mode = *mode; + if (FAILED(hr = wined3d_swapchain_state_set_display_mode(state, swapchain_desc->output, + &actual_mode))) + return hr; } else { @@ -2210,16 +2216,19 @@ HRESULT CDECL wined3d_swapchain_state_set_fullscreen(struct wined3d_swapchain_st actual_mode.format_id = adapter_format_from_backbuffer_format(swapchain_desc->output->adapter, swapchain_desc->backbuffer_format); actual_mode.scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN; + if (FAILED(hr = wined3d_swapchain_state_set_display_mode(state, swapchain_desc->output, + &actual_mode))) + return hr; } else { - actual_mode = state->original_mode; + if (FAILED(hr = wined3d_restore_display_modes(state->wined3d))) + { + WARN("Failed to restore display modes for all outputs, hr %#x.\n", hr); + return hr; + } } } - - if (FAILED(hr = wined3d_swapchain_state_set_display_mode(state, swapchain_desc->output, - &actual_mode))) - return hr; } else { diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index e4ff1161bce..44008119a8d 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -15,6 +15,7 @@ @ cdecl wined3d_incref(ptr) @ cdecl wined3d_register_software_device(ptr ptr) @ cdecl wined3d_register_window(ptr ptr ptr long) +@ cdecl wined3d_restore_display_modes(ptr) @ cdecl wined3d_unregister_windows(ptr)
@ cdecl wined3d_adapter_get_identifier(ptr long ptr) diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 62ea3960118..4a06b511211 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2313,6 +2313,7 @@ ULONG __cdecl wined3d_incref(struct wined3d *wined3d); HRESULT __cdecl wined3d_register_software_device(struct wined3d *wined3d, void *init_function); BOOL __cdecl wined3d_register_window(struct wined3d *wined3d, HWND window, struct wined3d_device *device, unsigned int flags); +HRESULT __cdecl wined3d_restore_display_modes(struct wined3d *wined3d); void __cdecl wined3d_unregister_windows(struct wined3d *wined3d);
HRESULT __cdecl wined3d_adapter_get_identifier(const struct wined3d_adapter *adapter,
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=81343
Your paranoid android.
=== w1064v1809 (32 bit report) ===
ddraw: ddraw7.c:16810: Test failed: WM_KILLFOCUS was not received. ddraw7.c:16972: Test failed: Got unexpected hr 0x887600e1. ddraw7.c:16975: Test failed: Got unexpected hr 0x887600ff. 18c8:ddraw7: unhandled exception c0000005 at 004FC35A
=== w864 (64 bit report) ===
ddraw: ddraw7.c:3254: Test failed: Failed to create surface, hr 0x887601c2. 0870:ddraw7: unhandled exception c0000005 at 0000000000504B60
=== w1064v1809 (32 bit report) ===
dxgi: dxgi.c:5689: Test failed: Got unexpected message 0x31f, hwnd 000900E4, wparam 0x1, lparam 0.
=== debiant (32 bit report) ===
ddraw: ddraw1.c:14162: Test failed: Expect window rect (0,0)-(1024,768), got (0,0)-(1010,706). ddraw1.c:14180: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw1.c:14187: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw2.c:15054: Test failed: Expect window rect (0,0)-(1024,768), got (7,26)-(1031,794). ddraw2.c:15072: Test failed: Expect window rect (0,0)-(1024,768), got (1024,-8)-(2048,760). ddraw2.c:15079: Test failed: Expect window rect (0,0)-(1024,768), got (1024,-8)-(2048,760). ddraw4.c:18114: Test failed: Expect window rect (0,0)-(1024,768), got (7,26)-(1031,794). ddraw4.c:18132: Test failed: Expect window rect (0,0)-(1024,768), got (0,-8)-(1024,760). ddraw4.c:18139: Test failed: Expect window rect (0,0)-(1024,768), got (0,-8)-(1024,760). ddraw4.c:18114: Test failed: Expect window rect (0,0)-(1024,768), got (0,0)-(1010,706). ddraw7.c:18394: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw7.c:18401: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw7.c:18376: Test failed: Expect window rect (0,0)-(1024,768), got (0,0)-(1010,706).
=== debiant (32 bit French report) ===
ddraw: ddraw1.c:14162: Test failed: Expect window rect (0,0)-(1024,768), got (0,0)-(1010,706). ddraw1.c:14180: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw1.c:14187: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw2.c:15054: Test failed: Expect window rect (0,0)-(1024,768), got (0,0)-(1010,706). ddraw2.c:15072: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw2.c:15079: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw4.c:18114: Test failed: Expect window rect (0,0)-(1024,768), got (7,26)-(1031,794). ddraw4.c:18132: Test failed: Expect window rect (0,0)-(1024,768), got (0,-8)-(1024,760). ddraw4.c:18139: Test failed: Expect window rect (0,0)-(1024,768), got (0,-8)-(1024,760). ddraw4.c:18114: Test failed: Expect window rect (0,0)-(1024,768), got (7,26)-(1031,794). ddraw4.c:18132: Test failed: Expect window rect (0,0)-(1024,768), got (1024,-8)-(2048,760). ddraw4.c:18139: Test failed: Expect window rect (0,0)-(1024,768), got (1024,-8)-(2048,760). ddraw7.c:18376: Test failed: Expect window rect (0,0)-(1024,768), got (7,26)-(1031,794). ddraw7.c:18394: Test failed: Expect window rect (0,0)-(1024,768), got (0,-8)-(1024,760). ddraw7.c:18401: Test failed: Expect window rect (0,0)-(1024,768), got (0,-8)-(1024,760). ddraw7.c:18376: Test failed: Expect window rect (0,0)-(1024,768), got (7,26)-(1031,794). ddraw7.c:18394: Test failed: Expect window rect (0,0)-(1024,768), got (1024,-8)-(2048,760). ddraw7.c:18401: Test failed: Expect window rect (0,0)-(1024,768), got (1024,-8)-(2048,760).
=== debiant (32 bit Japanese:Japan report) ===
ddraw: ddraw1.c:14162: Test failed: Expect window rect (0,0)-(1024,768), got (0,0)-(1010,706). ddraw1.c:14180: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw1.c:14187: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw2.c:15054: Test failed: Expect window rect (0,0)-(1024,768), got (0,0)-(1010,706). ddraw2.c:15072: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw2.c:15079: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw4.c:18114: Test failed: Expect window rect (0,0)-(1024,768), got (0,0)-(1010,706). ddraw4.c:18132: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw4.c:18139: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw7.c:18394: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw7.c:18401: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw7.c:18376: Test failed: Expect window rect (0,0)-(1024,768), got (0,0)-(1010,706).
=== debiant (32 bit Chinese:China report) ===
ddraw: ddraw1.c:14162: Test failed: Expect window rect (0,0)-(1024,768), got (0,0)-(1010,706). ddraw1.c:14180: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw1.c:14187: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw2.c:15054: Test failed: Expect window rect (0,0)-(1024,768), got (0,0)-(1010,706). ddraw2.c:15072: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw2.c:15079: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw4.c:18114: Test failed: Expect window rect (0,0)-(1024,768), got (0,0)-(1010,706). ddraw4.c:18132: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw4.c:18139: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw7.c:18376: Test failed: Expect window rect (0,0)-(1024,768), got (7,26)-(1031,794). ddraw7.c:18394: Test failed: Expect window rect (0,0)-(1024,768), got (0,-8)-(1024,760). ddraw7.c:18401: Test failed: Expect window rect (0,0)-(1024,768), got (0,-8)-(1024,760). ddraw7.c:18376: Test failed: Expect window rect (0,0)-(1024,768), got (0,0)-(1010,706).
=== debiant (32 bit WoW report) ===
ddraw: ddraw1.c:14162: Test failed: Expect window rect (0,0)-(1024,768), got (0,0)-(1010,706). ddraw1.c:14180: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw1.c:14187: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw2.c:15054: Test failed: Expect window rect (0,0)-(1024,768), got (1031,26)-(2041,732). ddraw2.c:15072: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw2.c:15079: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw4.c:18114: Test failed: Expect window rect (0,0)-(1024,768), got (7,26)-(1031,794). ddraw4.c:18132: Test failed: Expect window rect (0,0)-(1024,768), got (1024,-8)-(2048,760). ddraw4.c:18139: Test failed: Expect window rect (0,0)-(1024,768), got (1024,-8)-(2048,760). ddraw7.c:18376: Test failed: Expect window rect (0,0)-(1024,768), got (7,26)-(1031,794). ddraw7.c:18394: Test failed: Expect window rect (0,0)-(1024,768), got (0,-8)-(1024,760). ddraw7.c:18401: Test failed: Expect window rect (0,0)-(1024,768), got (0,-8)-(1024,760). ddraw7.c:18376: Test failed: Expect window rect (0,0)-(1024,768), got (1031,26)-(2041,732).
=== debiant (64 bit WoW report) ===
ddraw: ddraw1.c:14162: Test failed: Expect window rect (0,0)-(1024,768), got (1031,26)-(2041,732). ddraw1.c:14180: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw1.c:14187: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw2.c:15054: Test failed: Expect window rect (0,0)-(1024,768), got (0,0)-(1010,706). ddraw2.c:15072: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw2.c:15079: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw4.c:18114: Test failed: Expect window rect (0,0)-(1024,768), got (7,26)-(1017,761). ddraw4.c:18114: Test failed: Expect window rect (0,0)-(1024,768), got (1031,26)-(2041,732). ddraw4.c:18132: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw4.c:18139: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw7.c:18394: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw7.c:18401: Test failed: Expect window rect (0,0)-(1024,768), got (0,1)-(1024,769). ddraw7.c:18376: Test failed: Expect window rect (0,0)-(1024,768), got (0,0)-(1010,706).