Commit 1aa7c9af authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

winex11.drv: Store a full display mode in registry.

parent fd29fe4e
...@@ -749,8 +749,8 @@ static void test_ChangeDisplaySettingsEx(void) ...@@ -749,8 +749,8 @@ static void test_ChangeDisplaySettingsEx(void)
"Expected dmPelsWidth %u, got %u.\n", dm3.dmPelsWidth, dm.dmPelsWidth); "Expected dmPelsWidth %u, got %u.\n", dm3.dmPelsWidth, dm.dmPelsWidth);
ok(dm.dmPelsHeight == dm3.dmPelsHeight || broken(dm.dmPelsHeight == dm2.dmPelsHeight), /* Win10 */ ok(dm.dmPelsHeight == dm3.dmPelsHeight || broken(dm.dmPelsHeight == dm2.dmPelsHeight), /* Win10 */
"Expected dmPelsHeight %u, got %u.\n", dm3.dmPelsHeight, dm.dmPelsHeight); "Expected dmPelsHeight %u, got %u.\n", dm3.dmPelsHeight, dm.dmPelsHeight);
todo_wine ok(dm.dmBitsPerPel, "Expected dmBitsPerPel not zero.\n"); ok(dm.dmBitsPerPel, "Expected dmBitsPerPel not zero.\n");
todo_wine ok(dm.dmDisplayFrequency, "Expected dmDisplayFrequency not zero.\n"); ok(dm.dmDisplayFrequency, "Expected dmDisplayFrequency not zero.\n");
} }
else else
{ {
...@@ -758,12 +758,7 @@ static void test_ChangeDisplaySettingsEx(void) ...@@ -758,12 +758,7 @@ static void test_ChangeDisplaySettingsEx(void)
} }
res = ChangeDisplaySettingsExA(devices[device].name, NULL, NULL, 0, NULL); res = ChangeDisplaySettingsExA(devices[device].name, NULL, NULL, 0, NULL);
todo_wine ok(res == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExA %s returned %d.\n", devices[device].name, res); ok(res == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExA %s returned %d.\n", devices[device].name, res);
if (res != DISP_CHANGE_SUCCESSFUL)
{
skip("ChangeDisplaySettingsExA %s returned %d.\n", devices[device].name, res);
continue;
}
flush_events(); flush_events();
res = EnumDisplaySettingsA(devices[device].name, ENUM_REGISTRY_SETTINGS, &dm); res = EnumDisplaySettingsA(devices[device].name, ENUM_REGISTRY_SETTINGS, &dm);
......
...@@ -456,12 +456,15 @@ BOOL is_detached_mode(const DEVMODEW *mode) ...@@ -456,12 +456,15 @@ BOOL is_detached_mode(const DEVMODEW *mode)
} }
/* Get the full display mode with all the necessary fields set. /* Get the full display mode with all the necessary fields set.
* Return NULL on failure. Caller should free the returned mode. */ * Return NULL on failure. Caller should call free_full_mode() to free the returned mode. */
static DEVMODEW *get_full_mode(ULONG_PTR id, const DEVMODEW *dev_mode) static DEVMODEW *get_full_mode(ULONG_PTR id, DEVMODEW *dev_mode)
{ {
DEVMODEW *modes, *full_mode, *found_mode = NULL; DEVMODEW *modes, *full_mode, *found_mode = NULL;
UINT mode_count, mode_idx; UINT mode_count, mode_idx;
if (is_detached_mode(dev_mode))
return dev_mode;
if (!handler.get_modes(id, 0, &modes, &mode_count)) if (!handler.get_modes(id, 0, &modes, &mode_count))
return NULL; return NULL;
...@@ -500,9 +503,18 @@ static DEVMODEW *get_full_mode(ULONG_PTR id, const DEVMODEW *dev_mode) ...@@ -500,9 +503,18 @@ static DEVMODEW *get_full_mode(ULONG_PTR id, const DEVMODEW *dev_mode)
memcpy(full_mode, found_mode, sizeof(*found_mode) + found_mode->dmDriverExtra); memcpy(full_mode, found_mode, sizeof(*found_mode) + found_mode->dmDriverExtra);
handler.free_modes(modes); handler.free_modes(modes);
full_mode->dmFields |= DM_POSITION;
full_mode->u1.s2.dmPosition = dev_mode->u1.s2.dmPosition;
return full_mode; return full_mode;
} }
static void free_full_mode(DEVMODEW *mode)
{
if (!is_detached_mode(mode))
heap_free(mode);
}
static LONG get_display_settings(struct x11drv_display_setting **new_displays, static LONG get_display_settings(struct x11drv_display_setting **new_displays,
INT *new_display_count, const WCHAR *dev_name, DEVMODEW *dev_mode) INT *new_display_count, const WCHAR *dev_name, DEVMODEW *dev_mode)
{ {
...@@ -781,19 +793,9 @@ static LONG apply_display_settings(struct x11drv_display_setting *displays, INT ...@@ -781,19 +793,9 @@ static LONG apply_display_settings(struct x11drv_display_setting *displays, INT
if ((attached_mode && !do_attach) || (!attached_mode && do_attach)) if ((attached_mode && !do_attach) || (!attached_mode && do_attach))
continue; continue;
if (attached_mode) full_mode = get_full_mode(displays[display_idx].id, &displays[display_idx].desired_mode);
{ if (!full_mode)
full_mode = get_full_mode(displays[display_idx].id, &displays[display_idx].desired_mode); return DISP_CHANGE_BADMODE;
if (!full_mode)
return DISP_CHANGE_BADMODE;
full_mode->dmFields |= DM_POSITION;
full_mode->u1.s2.dmPosition = displays[display_idx].desired_mode.u1.s2.dmPosition;
}
else
{
full_mode = &displays[display_idx].desired_mode;
}
TRACE("handler:%s changing %s to position:(%d,%d) resolution:%ux%u frequency:%uHz " TRACE("handler:%s changing %s to position:(%d,%d) resolution:%ux%u frequency:%uHz "
"depth:%ubits orientation:%#x.\n", handler.name, "depth:%ubits orientation:%#x.\n", handler.name,
...@@ -803,8 +805,7 @@ static LONG apply_display_settings(struct x11drv_display_setting *displays, INT ...@@ -803,8 +805,7 @@ static LONG apply_display_settings(struct x11drv_display_setting *displays, INT
full_mode->u1.s2.dmDisplayOrientation); full_mode->u1.s2.dmDisplayOrientation);
ret = handler.set_current_mode(displays[display_idx].id, full_mode); ret = handler.set_current_mode(displays[display_idx].id, full_mode);
if (attached_mode) free_full_mode(full_mode);
heap_free(full_mode);
if (ret != DISP_CHANGE_SUCCESSFUL) if (ret != DISP_CHANGE_SUCCESSFUL)
return ret; return ret;
} }
...@@ -834,6 +835,7 @@ LONG CDECL X11DRV_ChangeDisplaySettingsEx( LPCWSTR devname, LPDEVMODEW devmode, ...@@ -834,6 +835,7 @@ LONG CDECL X11DRV_ChangeDisplaySettingsEx( LPCWSTR devname, LPDEVMODEW devmode,
{ {
struct x11drv_display_setting *displays; struct x11drv_display_setting *displays;
INT display_idx, display_count; INT display_idx, display_count;
DEVMODEW *full_mode;
LONG ret; LONG ret;
ret = get_display_settings(&displays, &display_count, devname, devmode); ret = get_display_settings(&displays, &display_count, devname, devmode);
...@@ -846,12 +848,22 @@ LONG CDECL X11DRV_ChangeDisplaySettingsEx( LPCWSTR devname, LPDEVMODEW devmode, ...@@ -846,12 +848,22 @@ LONG CDECL X11DRV_ChangeDisplaySettingsEx( LPCWSTR devname, LPDEVMODEW devmode,
{ {
if (!lstrcmpiW(displays[display_idx].desired_mode.dmDeviceName, devname)) if (!lstrcmpiW(displays[display_idx].desired_mode.dmDeviceName, devname))
{ {
if (!write_registry_settings(devname, &displays[display_idx].desired_mode)) full_mode = get_full_mode(displays[display_idx].id, &displays[display_idx].desired_mode);
if (!full_mode)
{
heap_free(displays);
return DISP_CHANGE_BADMODE;
}
if (!write_registry_settings(devname, full_mode))
{ {
ERR("Failed to write %s display settings to registry.\n", wine_dbgstr_w(devname)); ERR("Failed to write %s display settings to registry.\n", wine_dbgstr_w(devname));
free_full_mode(full_mode);
heap_free(displays); heap_free(displays);
return DISP_CHANGE_NOTUPDATED; return DISP_CHANGE_NOTUPDATED;
} }
free_full_mode(full_mode);
break; break;
} }
} }
......
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