[PATCH v5 3/6] wined3d: Move fullscreen window setup/restore to new struct and functions.

Józef Kucia jkucia at codeweavers.com
Thu Jun 27 05:42:13 CDT 2019


From: Conor McCarthy <cmccarthy at codeweavers.com>

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
 dlls/wined3d/device.c          | 82 +++++++++++++++++++---------------
 dlls/wined3d/wined3d.spec      |  3 ++
 dlls/wined3d/wined3d_private.h |  5 +--
 include/wine/wined3d.h         | 12 +++++
 4 files changed, 61 insertions(+), 41 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index d35a0648c9cb..32a233f59cf2 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -927,10 +927,9 @@ static LONG fullscreen_exstyle(LONG exstyle)
     return exstyle;
 }
 
-HRESULT CDECL wined3d_device_setup_fullscreen_window(struct wined3d_device *device,
+HRESULT CDECL wined3d_window_state_setup_fullscreen(struct wined3d_window_state *state,
         HWND window, unsigned int w, unsigned int h)
 {
-    BOOL filter_messages;
     LONG style, exstyle;
 
     TRACE("Setting up window %p for fullscreen mode.\n", window);
@@ -941,42 +940,47 @@ HRESULT CDECL wined3d_device_setup_fullscreen_window(struct wined3d_device *devi
         return WINED3DERR_NOTAVAILABLE;
     }
 
-    if (device->style || device->exStyle)
+    if (state->style || state->exstyle)
     {
         ERR("Changing the window style for window %p, but another style (%08x, %08x) is already stored.\n",
-                window, device->style, device->exStyle);
+                window, state->style, state->exstyle);
     }
 
-    device->style = GetWindowLongW(window, GWL_STYLE);
-    device->exStyle = GetWindowLongW(window, GWL_EXSTYLE);
+    state->style = GetWindowLongW(window, GWL_STYLE);
+    state->exstyle = GetWindowLongW(window, GWL_EXSTYLE);
 
-    style = fullscreen_style(device->style);
-    exstyle = fullscreen_exstyle(device->exStyle);
+    style = fullscreen_style(state->style);
+    exstyle = fullscreen_exstyle(state->exstyle);
 
     TRACE("Old style was %08x, %08x, setting to %08x, %08x.\n",
-            device->style, device->exStyle, style, exstyle);
-
-    filter_messages = device->filter_messages;
-    device->filter_messages = TRUE;
+            state->style, state->exstyle, style, exstyle);
 
     SetWindowLongW(window, GWL_STYLE, style);
     SetWindowLongW(window, GWL_EXSTYLE, exstyle);
     SetWindowPos(window, HWND_TOPMOST, 0, 0, w, h, SWP_FRAMECHANGED | SWP_SHOWWINDOW | SWP_NOACTIVATE);
 
-    device->filter_messages = filter_messages;
-
     return WINED3D_OK;
 }
 
-void CDECL wined3d_device_restore_fullscreen_window(struct wined3d_device *device, HWND window,
-        const RECT *window_rect)
+HRESULT CDECL wined3d_device_setup_fullscreen_window(struct wined3d_device *device,
+        HWND window, unsigned int w, unsigned int h)
+{
+    BOOL filter_messages = device->filter_messages;
+    HRESULT hr;
+    device->filter_messages = TRUE;
+    hr = wined3d_window_state_setup_fullscreen(&device->window_state, window, w, h);
+    device->filter_messages = filter_messages;
+    return hr;
+}
+
+void CDECL wined3d_window_state_restore_from_fullscreen(struct wined3d_window_state *state,
+        HWND window, const RECT *window_rect)
 {
     unsigned int window_pos_flags = SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOACTIVATE;
-    BOOL filter_messages;
     LONG style, exstyle;
     RECT rect = {0};
 
-    if (!device->style && !device->exStyle)
+    if (!state->style && !state->exstyle)
         return;
 
     style = GetWindowLongW(window, GWL_STYLE);
@@ -988,23 +992,20 @@ void CDECL wined3d_device_restore_fullscreen_window(struct wined3d_device *devic
      * preserve the current status of these flags (i.e. don't restore them) to
      * more closely emulate the behavior of Direct3D, which leaves these flags
      * alone when returning to windowed mode. */
-    device->style ^= (device->style ^ style) & WS_VISIBLE;
-    device->exStyle ^= (device->exStyle ^ exstyle) & WS_EX_TOPMOST;
+    state->style ^= (state->style ^ style) & WS_VISIBLE;
+    state->exstyle ^= (state->exstyle ^ exstyle) & WS_EX_TOPMOST;
 
     TRACE("Restoring window style of window %p to %08x, %08x.\n",
-            window, device->style, device->exStyle);
-
-    filter_messages = device->filter_messages;
-    device->filter_messages = TRUE;
+            window, state->style, state->exstyle);
 
     /* Only restore the style if the application didn't modify it during the
      * fullscreen phase. Some applications change it before calling Reset()
      * when switching between windowed and fullscreen modes (HL2), some
      * depend on the original style (Eve Online). */
-    if (style == fullscreen_style(device->style) && exstyle == fullscreen_exstyle(device->exStyle))
+    if (style == fullscreen_style(state->style) && exstyle == fullscreen_exstyle(state->exstyle))
     {
-        SetWindowLongW(window, GWL_STYLE, device->style);
-        SetWindowLongW(window, GWL_EXSTYLE, device->exStyle);
+        SetWindowLongW(window, GWL_STYLE, state->style);
+        SetWindowLongW(window, GWL_EXSTYLE, state->exstyle);
     }
 
     if (window_rect)
@@ -1014,11 +1015,18 @@ void CDECL wined3d_device_restore_fullscreen_window(struct wined3d_device *devic
     SetWindowPos(window, 0, rect.left, rect.top,
             rect.right - rect.left, rect.bottom - rect.top, window_pos_flags);
 
-    device->filter_messages = filter_messages;
-
     /* Delete the old values. */
-    device->style = 0;
-    device->exStyle = 0;
+    state->style = 0;
+    state->exstyle = 0;
+}
+
+void CDECL wined3d_device_restore_fullscreen_window(struct wined3d_device *device, HWND window,
+        const RECT *window_rect)
+{
+    BOOL filter_messages = device->filter_messages;
+    device->filter_messages = TRUE;
+    wined3d_window_state_restore_from_fullscreen(&device->window_state, window, window_rect);
+    device->filter_messages = filter_messages;
 }
 
 HRESULT CDECL wined3d_device_acquire_focus_window(struct wined3d_device *device, HWND window)
@@ -5538,19 +5546,19 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
     }
     else if (!swapchain_desc->windowed)
     {
-        DWORD style = device->style;
-        DWORD exStyle = device->exStyle;
+        DWORD style = device->window_state.style;
+        DWORD exstyle = device->window_state.exstyle;
         /* 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 clear up their mess. Guild Wars also loses the device during that.
          */
-        device->style = 0;
-        device->exStyle = 0;
+        device->window_state.style = 0;
+        device->window_state.exstyle = 0;
         wined3d_device_setup_fullscreen_window(device, swapchain->device_window,
                 swapchain_desc->backbuffer_width,
                 swapchain_desc->backbuffer_height);
-        device->style = style;
-        device->exStyle = exStyle;
+        device->window_state.style = style;
+        device->window_state.exstyle = exstyle;
     }
 
     if (FAILED(hr = wined3d_swapchain_resize_buffers(swapchain, swapchain_desc->backbuffer_count,
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 904bb3461ffb..8bbb89483f74 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -313,4 +313,7 @@
 @ cdecl wined3d_vertex_declaration_get_parent(ptr)
 @ cdecl wined3d_vertex_declaration_incref(ptr)
 
+@ cdecl wined3d_window_state_restore_from_fullscreen(ptr ptr ptr)
+@ cdecl wined3d_window_state_setup_fullscreen(ptr ptr long long)
+
 @ cdecl wined3d_extract_shader_input_signature_from_dxbc(ptr ptr long)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index b6f4b670182e..6f1b9a2aca01 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3150,10 +3150,7 @@ struct wined3d_device
     struct wined3d_device_parent *device_parent;
     struct wined3d *wined3d;
     struct wined3d_adapter *adapter;
-
-    /* Window styles to restore when switching fullscreen mode */
-    LONG                    style;
-    LONG                    exStyle;
+    struct wined3d_window_state window_state;
 
     const struct wined3d_shader_backend_ops *shader_backend;
     void *shader_priv;
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index d1d3ca42e599..335d9fe04232 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2171,6 +2171,13 @@ struct wined3d_private_data
     } content;
 };
 
+struct wined3d_window_state
+{
+    /* Window styles to restore when switching fullscreen mode */
+    LONG style;
+    LONG exstyle;
+};
+
 typedef HRESULT (CDECL *wined3d_device_reset_cb)(struct wined3d_resource *resource);
 
 void __stdcall wined3d_mutex_lock(void);
@@ -2756,6 +2763,11 @@ ULONG __cdecl wined3d_vertex_declaration_incref(struct wined3d_vertex_declaratio
 HRESULT __cdecl wined3d_extract_shader_input_signature_from_dxbc(struct wined3d_shader_signature *signature,
         const void *byte_code, SIZE_T byte_code_size);
 
+void __cdecl wined3d_window_state_restore_from_fullscreen(struct wined3d_window_state *fullscreen,
+        HWND window, const RECT *window_rect);
+HRESULT __cdecl wined3d_window_state_setup_fullscreen(struct wined3d_window_state *fullscreen,
+        HWND window, unsigned int w, unsigned int h);
+
 /* Return the integer base-2 logarithm of x. Undefined for x == 0. */
 static inline unsigned int wined3d_log2i(unsigned int x)
 {
-- 
2.21.0




More information about the wine-devel mailing list