Commit e847b082 authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

wined3d: Move device window to the correct output when changing swapchain state to full screen.

parent 094c344f
...@@ -4954,6 +4954,12 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, ...@@ -4954,6 +4954,12 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
|| swapchain_desc->backbuffer_height != current_desc->backbuffer_height; || swapchain_desc->backbuffer_height != current_desc->backbuffer_height;
windowed = current_desc->windowed; windowed = current_desc->windowed;
if (!(output = wined3d_swapchain_get_output(swapchain)))
{
ERR("Failed to get output from swapchain %p.\n", swapchain);
return E_FAIL;
}
if (!swapchain_desc->windowed != !windowed || swapchain->reapply_mode if (!swapchain_desc->windowed != !windowed || swapchain->reapply_mode
|| mode || (!swapchain_desc->windowed && backbuffer_resized)) || mode || (!swapchain_desc->windowed && backbuffer_resized))
{ {
...@@ -4971,11 +4977,6 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, ...@@ -4971,11 +4977,6 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
} }
} }
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, if (FAILED(hr = wined3d_swapchain_state_set_fullscreen(&swapchain->state,
swapchain_desc, output, mode))) swapchain_desc, output, mode)))
return hr; return hr;
...@@ -4988,13 +4989,22 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, ...@@ -4988,13 +4989,22 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
{ {
DWORD style = swapchain_state->style; DWORD style = swapchain_state->style;
DWORD exstyle = swapchain_state->exstyle; DWORD exstyle = swapchain_state->exstyle;
struct wined3d_output_desc output_desc;
/* If we're in fullscreen, and the mode wasn't changed, we have to get /* If we're in fullscreen, and the mode wasn't changed, we have to get
* the window back into the right position. Some applications * the window back into the right position. Some applications
* (Battlefield 2, Guild Wars) move it and then call Reset() to clean * (Battlefield 2, Guild Wars) move it and then call Reset() to clean
* up their mess. Guild Wars also loses the device during that. */ * up their mess. Guild Wars also loses the device during that. */
if (FAILED(hr = wined3d_output_get_desc(output, &output_desc)))
{
ERR("Failed to get output description, hr %#x.\n", hr);
return hr;
}
swapchain_state->style = 0; swapchain_state->style = 0;
swapchain_state->exstyle = 0; swapchain_state->exstyle = 0;
wined3d_swapchain_state_setup_fullscreen(swapchain_state, swapchain_state->device_window, wined3d_swapchain_state_setup_fullscreen(swapchain_state, swapchain_state->device_window,
output_desc.desktop_rect.left, output_desc.desktop_rect.top,
swapchain_desc->backbuffer_width, swapchain_desc->backbuffer_height); swapchain_desc->backbuffer_width, swapchain_desc->backbuffer_height);
swapchain_state->style = style; swapchain_state->style = style;
swapchain_state->exstyle = exstyle; swapchain_state->exstyle = exstyle;
......
...@@ -872,13 +872,14 @@ static HRESULT wined3d_swapchain_init(struct wined3d_swapchain *swapchain, struc ...@@ -872,13 +872,14 @@ static HRESULT wined3d_swapchain_init(struct wined3d_swapchain *swapchain, struc
const struct wined3d_swapchain_ops *swapchain_ops) const struct wined3d_swapchain_ops *swapchain_ops)
{ {
struct wined3d_resource_desc texture_desc; struct wined3d_resource_desc texture_desc;
struct wined3d_output_desc output_desc;
struct wined3d_output *output; struct wined3d_output *output;
BOOL displaymode_set = FALSE; BOOL displaymode_set = FALSE;
DWORD texture_flags = 0; DWORD texture_flags = 0;
HRESULT hr = E_FAIL;
RECT client_rect; RECT client_rect;
unsigned int i; unsigned int i;
HWND window; HWND window;
HRESULT hr;
wined3d_mutex_lock(); wined3d_mutex_lock();
...@@ -933,8 +934,21 @@ static HRESULT wined3d_swapchain_init(struct wined3d_swapchain *swapchain, struc ...@@ -933,8 +934,21 @@ static HRESULT wined3d_swapchain_init(struct wined3d_swapchain *swapchain, struc
} }
else else
{ {
wined3d_swapchain_state_setup_fullscreen(&swapchain->state, if (!(output = wined3d_swapchain_get_output(swapchain)))
window, desc->backbuffer_width, desc->backbuffer_height); {
ERR("Failed to get output from swapchain %p.\n", swapchain);
goto err;
}
if (FAILED(hr = wined3d_output_get_desc(output, &output_desc)))
{
ERR("Failed to get output description, hr %#x.\n", hr);
goto err;
}
wined3d_swapchain_state_setup_fullscreen(&swapchain->state, window,
output_desc.desktop_rect.left, output_desc.desktop_rect.top, desc->backbuffer_width,
desc->backbuffer_height);
} }
swapchain->state.desc = *desc; swapchain->state.desc = *desc;
wined3d_swapchain_apply_sample_count_override(swapchain, swapchain->state.desc.backbuffer_format, wined3d_swapchain_apply_sample_count_override(swapchain, swapchain->state.desc.backbuffer_format,
...@@ -1551,7 +1565,7 @@ static LONG fullscreen_exstyle(LONG exstyle) ...@@ -1551,7 +1565,7 @@ static LONG fullscreen_exstyle(LONG exstyle)
} }
HRESULT wined3d_swapchain_state_setup_fullscreen(struct wined3d_swapchain_state *state, HRESULT wined3d_swapchain_state_setup_fullscreen(struct wined3d_swapchain_state *state,
HWND window, unsigned int w, unsigned int h) HWND window, int x, int y, int width, int height)
{ {
LONG style, exstyle; LONG style, exstyle;
BOOL filter; BOOL filter;
...@@ -1583,7 +1597,8 @@ HRESULT wined3d_swapchain_state_setup_fullscreen(struct wined3d_swapchain_state ...@@ -1583,7 +1597,8 @@ HRESULT wined3d_swapchain_state_setup_fullscreen(struct wined3d_swapchain_state
SetWindowLongW(window, GWL_STYLE, style); SetWindowLongW(window, GWL_STYLE, style);
SetWindowLongW(window, GWL_EXSTYLE, exstyle); SetWindowLongW(window, GWL_EXSTYLE, exstyle);
SetWindowPos(window, HWND_TOPMOST, 0, 0, w, h, SWP_FRAMECHANGED | SWP_SHOWWINDOW | SWP_NOACTIVATE); SetWindowPos(window, HWND_TOPMOST, x, y, width, height,
SWP_FRAMECHANGED | SWP_SHOWWINDOW | SWP_NOACTIVATE);
wined3d_filter_messages(window, filter); wined3d_filter_messages(window, filter);
...@@ -1647,6 +1662,7 @@ HRESULT CDECL wined3d_swapchain_state_set_fullscreen(struct wined3d_swapchain_st ...@@ -1647,6 +1662,7 @@ HRESULT CDECL wined3d_swapchain_state_set_fullscreen(struct wined3d_swapchain_st
const struct wined3d_display_mode *mode) const struct wined3d_display_mode *mode)
{ {
struct wined3d_display_mode actual_mode; struct wined3d_display_mode actual_mode;
struct wined3d_output_desc output_desc;
HRESULT hr; HRESULT hr;
TRACE("state %p, swapchain_desc %p, output %p, mode %p.\n", TRACE("state %p, swapchain_desc %p, output %p, mode %p.\n",
...@@ -1695,10 +1711,17 @@ HRESULT CDECL wined3d_swapchain_state_set_fullscreen(struct wined3d_swapchain_st ...@@ -1695,10 +1711,17 @@ HRESULT CDECL wined3d_swapchain_state_set_fullscreen(struct wined3d_swapchain_st
unsigned int width = actual_mode.width; unsigned int width = actual_mode.width;
unsigned int height = actual_mode.height; unsigned int height = actual_mode.height;
if (FAILED(hr = wined3d_output_get_desc(output, &output_desc)))
{
ERR("Failed to get output description, hr %#x.\n", hr);
return hr;
}
if (state->desc.windowed) if (state->desc.windowed)
{ {
/* Switch from windowed to fullscreen */ /* Switch from windowed to fullscreen */
if (FAILED(hr = wined3d_swapchain_state_setup_fullscreen(state, state->device_window, width, height))) if (FAILED(hr = wined3d_swapchain_state_setup_fullscreen(state, state->device_window,
output_desc.desktop_rect.left, output_desc.desktop_rect.top, width, height)))
return hr; return hr;
} }
else else
...@@ -1708,7 +1731,8 @@ HRESULT CDECL wined3d_swapchain_state_set_fullscreen(struct wined3d_swapchain_st ...@@ -1708,7 +1731,8 @@ HRESULT CDECL wined3d_swapchain_state_set_fullscreen(struct wined3d_swapchain_st
/* Fullscreen -> fullscreen mode change */ /* Fullscreen -> fullscreen mode change */
filter = wined3d_filter_messages(window, TRUE); filter = wined3d_filter_messages(window, TRUE);
MoveWindow(window, 0, 0, width, height, TRUE); MoveWindow(window, output_desc.desktop_rect.left, output_desc.desktop_rect.top, width,
height, TRUE);
ShowWindow(window, SW_SHOW); ShowWindow(window, SW_SHOW);
wined3d_filter_messages(window, filter); wined3d_filter_messages(window, filter);
} }
......
...@@ -4720,7 +4720,7 @@ struct wined3d_swapchain_state ...@@ -4720,7 +4720,7 @@ struct wined3d_swapchain_state
void wined3d_swapchain_state_restore_from_fullscreen(struct wined3d_swapchain_state *state, void wined3d_swapchain_state_restore_from_fullscreen(struct wined3d_swapchain_state *state,
HWND window, const RECT *window_rect) DECLSPEC_HIDDEN; HWND window, const RECT *window_rect) DECLSPEC_HIDDEN;
HRESULT wined3d_swapchain_state_setup_fullscreen(struct wined3d_swapchain_state *state, HRESULT wined3d_swapchain_state_setup_fullscreen(struct wined3d_swapchain_state *state,
HWND window, unsigned int w, unsigned int h) DECLSPEC_HIDDEN; HWND window, int x, int y, int width, int height) DECLSPEC_HIDDEN;
struct wined3d_swapchain_ops struct wined3d_swapchain_ops
{ {
......
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