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

Conor McCarthy cmccarthy at codeweavers.com
Wed Jun 26 07:07:19 CDT 2019


Signed-off-by: Conor McCarthy <cmccarthy at codeweavers.com>
---
 dlls/wined3d/device.c          | 81 +++++++++++++++++++---------------
 dlls/wined3d/wined3d.spec      |  3 ++
 dlls/wined3d/wined3d_private.h |  5 +--
 include/wine/wined3d.h         | 12 +++++
 4 files changed, 61 insertions(+), 40 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index d35a064..7acf70a 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_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,48 @@ 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,
+HRESULT CDECL wined3d_device_setup_fullscreen_window(struct wined3d_device *device,
+        HWND window, unsigned int w, unsigned int h)
+{
+    BOOL filter_messages;
+    HRESULT hr;
+    filter_messages = device->filter_messages;
+    device->filter_messages = TRUE;
+    hr = wined3d_window_setup_fullscreen(&device->window_state, window, w, h);
+    device->filter_messages = filter_messages;
+    return hr;
+}
+
+void CDECL wined3d_window_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 +993,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 +1016,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_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 +5547,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 904bb34..b51e1d0 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_setup_fullscreen(ptr ptr long long)
+@ cdecl wined3d_window_restore_from_fullscreen(ptr ptr ptr)
+
 @ 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 b6f4b67..6f1b9a2 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 d1d3ca4..e12c9d3 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_restore_from_fullscreen(struct wined3d_window_state *fullscreen, HWND window,
+        const RECT *window_rect);
+HRESULT __cdecl wined3d_window_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