Commit 079caeaa authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

ddraw: Get new window size from the primary output after display mode changes.

MonitorFromWindow() may return a different monitor if switching to a smaller display mode. Fix Railroad Tycoon II crashes. Signed-off-by: 's avatarZhiyi Zhang <zzhang@codeweavers.com> Signed-off-by: 's avatarHenri Verbeet <hverbeet@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 8805f042
...@@ -4926,8 +4926,7 @@ static void CDECL device_parent_wined3d_device_created(struct wined3d_device_par ...@@ -4926,8 +4926,7 @@ static void CDECL device_parent_wined3d_device_created(struct wined3d_device_par
static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent) static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
{ {
struct ddraw *ddraw = ddraw_from_device_parent(device_parent); struct ddraw *ddraw = ddraw_from_device_parent(device_parent);
MONITORINFO monitor_info; struct wined3d_output_desc output_desc;
HMONITOR monitor;
RECT *r; RECT *r;
TRACE("device_parent %p.\n", device_parent); TRACE("device_parent %p.\n", device_parent);
...@@ -4938,15 +4937,13 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic ...@@ -4938,15 +4937,13 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic
return; return;
} }
monitor = MonitorFromWindow(ddraw->swapchain_window, MONITOR_DEFAULTTOPRIMARY); if (FAILED(wined3d_output_get_desc(ddraw->wined3d_output, &output_desc)))
monitor_info.cbSize = sizeof(monitor_info);
if (!GetMonitorInfoW(monitor, &monitor_info))
{ {
ERR("Failed to get monitor info.\n"); ERR("Failed to get output description.\n");
return; return;
} }
r = &monitor_info.rcMonitor; r = &output_desc.desktop_rect;
TRACE("Resizing window %p to %s.\n", ddraw->swapchain_window, wine_dbgstr_rect(r)); TRACE("Resizing window %p to %s.\n", ddraw->swapchain_window, wine_dbgstr_rect(r));
if (!SetWindowPos(ddraw->swapchain_window, HWND_TOP, r->left, r->top, if (!SetWindowPos(ddraw->swapchain_window, HWND_TOP, r->left, r->top,
......
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