Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/wined3d/device.c | 9 ++++++++- dlls/wined3d/swapchain.c | 13 +++++++++++++ dlls/wined3d/wined3d_main.c | 8 +++++++- dlls/wined3d/wined3d_private.h | 1 + 4 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 4a5397b2e67..88c745f1e67 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -5097,6 +5097,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, struct wined3d_swapchain *swapchain; struct wined3d_view_desc view_desc; BOOL backbuffer_resized, windowed; + struct wined3d_output *output; HRESULT hr = WINED3D_OK; unsigned int i;
@@ -5205,8 +5206,14 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, return hr; } } + + if (!(output = wined3d_swapchain_get_output(swapchain))) + { + ERR("Failed to get output from swapchain %p.\n", swapchain); + return E_FAIL; + } if (FAILED(hr = wined3d_swapchain_state_set_fullscreen(&swapchain->state, - swapchain_desc, device->wined3d, &device->adapter->outputs[0], mode))) + swapchain_desc, device->wined3d, output, mode))) return hr;
/* Switch from fullscreen to windowed. */ diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index a70b6c1e063..be41cc385e7 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -289,6 +289,19 @@ static struct wined3d_output * get_output_from_window(const struct wined3d *wine return &wined3d->adapters[0]->outputs[0]; }
+struct wined3d_output * wined3d_swapchain_get_output(const struct wined3d_swapchain *swapchain) +{ + HWND hwnd; + + TRACE("swapchain %p.\n", swapchain); + + hwnd = swapchain->state.device_window; + if (!hwnd) + hwnd = swapchain->win_handle; + + return get_output_from_window(swapchain->device->wined3d, hwnd); +} + HRESULT CDECL wined3d_swapchain_get_raster_status(const struct wined3d_swapchain *swapchain, struct wined3d_raster_status *raster_status) { diff --git a/dlls/wined3d/wined3d_main.c b/dlls/wined3d/wined3d_main.c index 3e852bd4e62..ea58f4473b8 100644 --- a/dlls/wined3d/wined3d_main.c +++ b/dlls/wined3d/wined3d_main.c @@ -541,6 +541,7 @@ static LRESULT CALLBACK wined3d_hook_proc(int code, WPARAM wparam, LPARAM lparam struct wined3d_swapchain_desc swapchain_desc; struct wined3d_swapchain *swapchain; struct wined3d_wndproc *entry; + struct wined3d_output *output; MSG *msg = (MSG *)lparam; unsigned int i;
@@ -564,8 +565,13 @@ static LRESULT CALLBACK wined3d_hook_proc(int code, WPARAM wparam, LPARAM lparam
wined3d_swapchain_get_desc(swapchain, &swapchain_desc); swapchain_desc.windowed = !swapchain_desc.windowed; + if (!(output = wined3d_swapchain_get_output(swapchain))) + { + ERR("Failed to get output from swapchain %p.\n", swapchain); + break; + } wined3d_swapchain_state_set_fullscreen(&swapchain->state, &swapchain_desc, - swapchain->device->wined3d, &swapchain->device->adapter->outputs[0], NULL); + swapchain->device->wined3d, output, NULL);
wined3d_wndproc_mutex_unlock();
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 4c7ea1f1628..23540295bb4 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4485,6 +4485,7 @@ struct wined3d_swapchain
void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activate) DECLSPEC_HIDDEN; void wined3d_swapchain_cleanup(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN; +struct wined3d_output * wined3d_swapchain_get_output(const struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN; void swapchain_update_draw_bindings(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN; void swapchain_set_max_frame_latency(struct wined3d_swapchain *swapchain, const struct wined3d_device *device) DECLSPEC_HIDDEN;