wined3d: Setup/restore fullscreen window state inside wined3d.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2019-07-29 16:00:52 +04:30 committed by Alexandre Julliard
parent f49b27ce22
commit 5f96c5e264
8 changed files with 28 additions and 52 deletions

View File

@ -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)

View File

@ -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)))

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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)

View File

@ -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

View File

@ -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,