Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- Fix failures to change display modes like in https://test.winehq.org/data/93107c08f5aa7f37ad7ece9cd7ca248dba3030ce/linux_...
dlls/user32/sysparams.c | 16 ++++++++++++++++ dlls/user32/tests/monitor.c | 16 +++------------- 2 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index d4640e0068e..1381f387e03 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -3182,6 +3182,22 @@ LONG WINAPI ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmode, HWND return DISP_CHANGE_BADMODE; }
+ if (!is_detached_mode(devmode) && (!devmode->dmPelsWidth || !devmode->dmPelsHeight)) + { + memset(&dm, 0, sizeof(dm)); + dm.dmSize = sizeof(dm); + if (!EnumDisplaySettingsExW(devname, ENUM_CURRENT_SETTINGS, &dm, 0)) + { + ERR("Current mode not found!\n"); + return DISP_CHANGE_BADMODE; + } + + if (!devmode->dmPelsWidth) + devmode->dmPelsWidth = dm.dmPelsWidth; + if (!devmode->dmPelsHeight) + devmode->dmPelsHeight = dm.dmPelsHeight; + } + ret = USER_Driver->pChangeDisplaySettingsEx(devname, devmode, hwnd, flags, lparam); if (ret != DISP_CHANGE_SUCCESSFUL) ERR("Changing %s display settings returned %d.\n", wine_dbgstr_w(devname), ret); diff --git a/dlls/user32/tests/monitor.c b/dlls/user32/tests/monitor.c index d7d9086672d..009fc0d626e 100644 --- a/dlls/user32/tests/monitor.c +++ b/dlls/user32/tests/monitor.c @@ -602,8 +602,7 @@ static void test_ChangeDisplaySettingsEx(void) }
/* Test changing to a mode with depth set but with zero width and height */ - /* This test is only ran for non-primary adapters for now as it may detach the adapters on Wine */ - for (device = 1; device < device_count; ++device) + for (device = 0; device < device_count; ++device) { for (test = 0; test < ARRAY_SIZE(depths); ++test) { @@ -689,10 +688,8 @@ static void test_ChangeDisplaySettingsEx(void) dd.cb = sizeof(dd); res = EnumDisplayDevicesA(NULL, devices[device].index, &dd, 0); ok(res, "EnumDisplayDevicesA %s failed, error %#x.\n", devices[device].name, GetLastError()); - todo_wine ok(dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP, "Expect %s attached.\n", - devices[device].name); - if (!(dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) - continue; + ok(dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP, "Expect %s attached.\n", + devices[device].name);
memset(&dm, 0, sizeof(dm)); dm.dmSize = sizeof(dm); @@ -715,13 +712,6 @@ static void test_ChangeDisplaySettingsEx(void) /* Detach all non-primary adapters to avoid position conflicts */ for (device = 1; device < device_count; ++device) { - dd.cb = sizeof(dd); - res = EnumDisplayDevicesA(NULL, devices[device].index, &dd, 0); - ok(res, "EnumDisplayDevicesA %s failed, error %#x.\n", devices[device].name, GetLastError()); - /* Already detached by previous tests */ - if (!(dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) - continue; - old_count = GetSystemMetrics(SM_CMONITORS);
memset(&dm, 0, sizeof(dm));