From 5f96c5e26481bab17b5d0db9abf2b4f1c5af26e9 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Mon, 29 Jul 2019 16:00:52 +0430 Subject: [PATCH] wined3d: Setup/restore fullscreen window state inside wined3d. Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/d3d8/device.c | 10 +--------- dlls/d3d9/device.c | 10 ---------- dlls/ddraw/ddraw.c | 15 --------------- dlls/wined3d/device.c | 6 +++--- dlls/wined3d/swapchain.c | 29 ++++++++++++++++++++--------- dlls/wined3d/wined3d.spec | 2 -- dlls/wined3d/wined3d_private.h | 4 ++++ include/wine/wined3d.h | 4 ---- 8 files changed, 28 insertions(+), 52 deletions(-) diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 36197e3b31f..b5436241a9e 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -3602,10 +3602,8 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine if (!parameters->Windowed) { - HWND device_window = parameters->hDeviceWindow; - if (!focus_window) - focus_window = device_window; + focus_window = parameters->hDeviceWindow; if (FAILED(hr = wined3d_device_acquire_focus_window(device->wined3d_device, focus_window))) { ERR("Failed to acquire focus window, hr %#x.\n", hr); @@ -3614,12 +3612,6 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine heap_free(device->handle_table.entries); return hr; } - - if (!device_window) - device_window = focus_window; - wined3d_device_setup_fullscreen_window(device->wined3d_device, device_window, - parameters->BackBufferWidth, - parameters->BackBufferHeight); } if (flags & D3DCREATE_MULTITHREADED) diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 8f94eb0698f..dc3363bab8c 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -4503,16 +4503,6 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine wined3d_mutex_unlock(); return hr; } - - for (i = 0; i < count; ++i) - { - HWND device_window = parameters[i].hDeviceWindow; - - if (!device_window) device_window = focus_window; - wined3d_device_setup_fullscreen_window(device->wined3d_device, device_window, - parameters[i].BackBufferWidth, - parameters[i].BackBufferHeight); - } } if (!(swapchain_desc = heap_alloc(sizeof(*swapchain_desc) * count))) diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index 076289be094..2c7619016e1 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -884,21 +884,6 @@ static HRESULT ddraw_set_cooperative_level(struct ddraw *ddraw, HWND window, ddraw->focuswindow = NULL; } - if ((cooplevel & DDSCL_FULLSCREEN) != (ddraw->cooperative_level & DDSCL_FULLSCREEN) || window != ddraw->dest_window) - { - if (ddraw->cooperative_level & DDSCL_FULLSCREEN) - wined3d_device_restore_fullscreen_window(ddraw->wined3d_device, ddraw->dest_window, NULL); - - if (cooplevel & DDSCL_FULLSCREEN) - { - struct wined3d_display_mode display_mode; - - wined3d_get_adapter_display_mode(ddraw->wined3d, WINED3DADAPTER_DEFAULT, &display_mode, NULL); - wined3d_device_setup_fullscreen_window(ddraw->wined3d_device, window, - display_mode.width, display_mode.height); - } - } - if ((cooplevel & DDSCL_EXCLUSIVE) && exclusive_window != window) { ddraw->device_state = DDRAW_DEVICE_STATE_NOT_RESTORED; diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 2c768514c46..343e25b482c 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -927,7 +927,7 @@ static LONG fullscreen_exstyle(LONG exstyle) return exstyle; } -HRESULT CDECL wined3d_device_setup_fullscreen_window(struct wined3d_device *device, +HRESULT wined3d_device_setup_fullscreen_window(struct wined3d_device *device, HWND window, unsigned int w, unsigned int h) { BOOL filter_messages; @@ -968,8 +968,8 @@ HRESULT CDECL wined3d_device_setup_fullscreen_window(struct wined3d_device *devi return WINED3D_OK; } -void CDECL wined3d_device_restore_fullscreen_window(struct wined3d_device *device, HWND window, - const RECT *window_rect) +void wined3d_device_restore_fullscreen_window(struct wined3d_device *device, + HWND window, const RECT *window_rect) { unsigned int window_pos_flags = SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOACTIVATE; BOOL filter_messages; diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index 8603c8de7a0..366ce80bb59 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -75,17 +75,24 @@ static void swapchain_cleanup(struct wined3d_swapchain *swapchain) * desktop resolution. In case of d3d7 this will be a NOP because ddraw * sets the resolution before starting up Direct3D, thus orig_width and * orig_height will be equal to the modes in the presentation params. */ - if (!swapchain->desc.windowed && swapchain->desc.auto_restore_display_mode) + if (!swapchain->desc.windowed) { - if (FAILED(hr = wined3d_set_adapter_display_mode(swapchain->device->wined3d, - swapchain->device->adapter->ordinal, &swapchain->original_mode))) - ERR("Failed to restore display mode, hr %#x.\n", hr); - - if (swapchain->desc.flags & WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT) + if (swapchain->desc.auto_restore_display_mode) { - wined3d_device_restore_fullscreen_window(swapchain->device, swapchain->device_window, - &swapchain->original_window_rect); - wined3d_device_release_focus_window(swapchain->device); + if (FAILED(hr = wined3d_set_adapter_display_mode(swapchain->device->wined3d, + swapchain->device->adapter->ordinal, &swapchain->original_mode))) + ERR("Failed to restore display mode, hr %#x.\n", hr); + + if (swapchain->desc.flags & WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT) + { + wined3d_device_restore_fullscreen_window(swapchain->device, swapchain->device_window, + &swapchain->original_window_rect); + wined3d_device_release_focus_window(swapchain->device); + } + } + else + { + wined3d_device_restore_fullscreen_window(swapchain->device, swapchain->device_window, NULL); } } @@ -802,6 +809,10 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3 TRACE("Updating format to %s.\n", debug_d3dformat(swapchain->original_mode.format_id)); } } + else + { + wined3d_device_setup_fullscreen_window(device, window, desc->backbuffer_width, desc->backbuffer_height); + } swapchain->desc = *desc; wined3d_swapchain_apply_sample_count_override(swapchain, swapchain->desc.backbuffer_format, &swapchain->desc.multisample_type, &swapchain->desc.multisample_quality); diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 59f99c91e07..8b36753f458 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -127,7 +127,6 @@ @ cdecl wined3d_device_release_focus_window(ptr) @ cdecl wined3d_device_reset(ptr ptr ptr ptr long) @ cdecl wined3d_device_resolve_sub_resource(ptr ptr long ptr long long) -@ cdecl wined3d_device_restore_fullscreen_window(ptr ptr ptr) @ cdecl wined3d_device_set_base_vertex_index(ptr long) @ cdecl wined3d_device_set_blend_state(ptr ptr ptr) @ cdecl wined3d_device_set_clip_plane(ptr long ptr) @@ -187,7 +186,6 @@ @ cdecl wined3d_device_set_vs_consts_i(ptr long long ptr) @ cdecl wined3d_device_set_vs_resource_view(ptr long ptr) @ cdecl wined3d_device_set_vs_sampler(ptr long ptr) -@ cdecl wined3d_device_setup_fullscreen_window(ptr ptr long long) @ cdecl wined3d_device_show_cursor(ptr long) @ cdecl wined3d_device_update_sub_resource(ptr ptr long ptr ptr long long long) @ cdecl wined3d_device_update_texture(ptr ptr ptr) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index e76a272d665..85392900122 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3255,8 +3255,12 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL void device_resource_add(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN; void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN; void device_invalidate_state(const struct wined3d_device *device, DWORD state) DECLSPEC_HIDDEN; +void wined3d_device_restore_fullscreen_window(struct wined3d_device *device, + HWND window, const RECT *window_rect) DECLSPEC_HIDDEN; HRESULT wined3d_device_set_implicit_swapchain(struct wined3d_device *device, struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN; +HRESULT wined3d_device_setup_fullscreen_window(struct wined3d_device *device, + HWND window, unsigned int w, unsigned int h) DECLSPEC_HIDDEN; void wined3d_device_uninit_3d(struct wined3d_device *device) DECLSPEC_HIDDEN; struct wined3d_device_no3d diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 9a698bc8082..c71bb9c54c7 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2378,8 +2378,6 @@ void __cdecl wined3d_device_resolve_sub_resource(struct wined3d_device *device, struct wined3d_resource *dst_resource, unsigned int dst_sub_resource_idx, struct wined3d_resource *src_resource, unsigned int src_sub_resource_idx, enum wined3d_format_id format_id); -void __cdecl wined3d_device_restore_fullscreen_window(struct wined3d_device *device, HWND window, - const RECT *window_rect); void __cdecl wined3d_device_set_base_vertex_index(struct wined3d_device *device, INT base_index); void __cdecl wined3d_device_set_blend_state(struct wined3d_device *device, struct wined3d_blend_state *blend_state, const struct wined3d_color *blend_factor); @@ -2479,8 +2477,6 @@ HRESULT __cdecl wined3d_device_set_vs_consts_i(struct wined3d_device *device, void __cdecl wined3d_device_set_vs_resource_view(struct wined3d_device *device, UINT idx, struct wined3d_shader_resource_view *view); void __cdecl wined3d_device_set_vs_sampler(struct wined3d_device *device, UINT idx, struct wined3d_sampler *sampler); -HRESULT __cdecl wined3d_device_setup_fullscreen_window(struct wined3d_device *device, - HWND window, unsigned int w, unsigned int h); BOOL __cdecl wined3d_device_show_cursor(struct wined3d_device *device, BOOL show); void __cdecl wined3d_device_update_sub_resource(struct wined3d_device *device, struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box, const void *data, unsigned int row_pitch,