Zhiyi Zhang : wined3d: Move device window to the correct output when changing swapchain state to full screen.
Alexandre Julliard
julliard at winehq.org
Fri May 8 15:20:32 CDT 2020
Module: wine
Branch: master
Commit: e847b082296547376309f25d9947f2367f98a9ec
URL: https://source.winehq.org/git/wine.git/?a=commit;h=e847b082296547376309f25d9947f2367f98a9ec
Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date: Thu May 7 15:52:12 2020 +0800
wined3d: Move device window to the correct output when changing swapchain state to full screen.
Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/wined3d/device.c | 20 +++++++++++++++-----
dlls/wined3d/swapchain.c | 38 +++++++++++++++++++++++++++++++-------
dlls/wined3d/wined3d_private.h | 2 +-
3 files changed, 47 insertions(+), 13 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index e16bd84164..1711014c8d 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4954,6 +4954,12 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
|| swapchain_desc->backbuffer_height != current_desc->backbuffer_height;
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
|| mode || (!swapchain_desc->windowed && backbuffer_resized))
{
@@ -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,
swapchain_desc, output, mode)))
return hr;
@@ -4988,13 +4989,22 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
{
DWORD style = swapchain_state->style;
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
* the window back into the right position. Some applications
* (Battlefield 2, Guild Wars) move it and then call Reset() to clean
* 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->exstyle = 0;
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_state->style = style;
swapchain_state->exstyle = exstyle;
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index 3071afb8ae..466bcd95ca 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -872,13 +872,14 @@ static HRESULT wined3d_swapchain_init(struct wined3d_swapchain *swapchain, struc
const struct wined3d_swapchain_ops *swapchain_ops)
{
struct wined3d_resource_desc texture_desc;
+ struct wined3d_output_desc output_desc;
struct wined3d_output *output;
BOOL displaymode_set = FALSE;
DWORD texture_flags = 0;
+ HRESULT hr = E_FAIL;
RECT client_rect;
unsigned int i;
HWND window;
- HRESULT hr;
wined3d_mutex_lock();
@@ -933,8 +934,21 @@ static HRESULT wined3d_swapchain_init(struct wined3d_swapchain *swapchain, struc
}
else
{
- wined3d_swapchain_state_setup_fullscreen(&swapchain->state,
- window, desc->backbuffer_width, desc->backbuffer_height);
+ if (!(output = wined3d_swapchain_get_output(swapchain)))
+ {
+ 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;
wined3d_swapchain_apply_sample_count_override(swapchain, swapchain->state.desc.backbuffer_format,
@@ -1551,7 +1565,7 @@ static LONG fullscreen_exstyle(LONG exstyle)
}
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;
BOOL filter;
@@ -1583,7 +1597,8 @@ HRESULT wined3d_swapchain_state_setup_fullscreen(struct wined3d_swapchain_state
SetWindowLongW(window, GWL_STYLE, style);
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);
@@ -1647,6 +1662,7 @@ HRESULT CDECL wined3d_swapchain_state_set_fullscreen(struct wined3d_swapchain_st
const struct wined3d_display_mode *mode)
{
struct wined3d_display_mode actual_mode;
+ struct wined3d_output_desc output_desc;
HRESULT hr;
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
unsigned int width = actual_mode.width;
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)
{
/* 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;
}
else
@@ -1708,7 +1731,8 @@ HRESULT CDECL wined3d_swapchain_state_set_fullscreen(struct wined3d_swapchain_st
/* Fullscreen -> fullscreen mode change */
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);
wined3d_filter_messages(window, filter);
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 7a412d7a8e..0e20d1fc9b 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -4720,7 +4720,7 @@ struct wined3d_swapchain_state
void wined3d_swapchain_state_restore_from_fullscreen(struct wined3d_swapchain_state *state,
HWND window, const RECT *window_rect) DECLSPEC_HIDDEN;
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
{
More information about the wine-cvs
mailing list