Commit e6b2da31 authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

user32: Use current width or height if a mode specifies zero width or height for…

user32: Use current width or height if a mode specifies zero width or height for ChangeDisplaySettingsExW(). Signed-off-by: 's avatarZhiyi Zhang <zzhang@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 2756cabb
......@@ -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);
......
......@@ -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));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment