[PATCH v2 6/9] wined3d: Restore the window visibility and Z-order upon exiting fullscreen, if requested.

Gabriel Ivăncescu gabrielopcode at gmail.com
Mon Jul 6 09:57:17 CDT 2020


Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
 dlls/dxgi/tests/dxgi.c   |  2 --
 dlls/dxgi/utils.c        |  3 ++-
 dlls/wined3d/swapchain.c | 15 ++++++++++++++-
 include/wine/wined3d.h   |  1 +
 4 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/dlls/dxgi/tests/dxgi.c b/dlls/dxgi/tests/dxgi.c
index 6ff9dbe..81b80dc 100644
--- a/dlls/dxgi/tests/dxgi.c
+++ b/dlls/dxgi/tests/dxgi.c
@@ -5884,10 +5884,8 @@ static void test_swapchain_window_styles(void)
 
         style = GetWindowLongA(swapchain_desc.OutputWindow, GWL_STYLE);
         exstyle = GetWindowLongA(swapchain_desc.OutputWindow, GWL_EXSTYLE);
-        todo_wine_if(!(tests[i].expected_style & WS_VISIBLE))
         ok(style == tests[i].expected_style, "Test %u: Got style %#x, expected %#x.\n",
                 i, style, tests[i].expected_style);
-        todo_wine_if(!(tests[i].expected_exstyle & WS_EX_TOPMOST))
         ok(exstyle == tests[i].expected_exstyle, "Test %u: Got exstyle %#x, expected %#x.\n",
                 i, exstyle, tests[i].expected_exstyle);
 
diff --git a/dlls/dxgi/utils.c b/dlls/dxgi/utils.c
index ca87e3c..9544117 100644
--- a/dlls/dxgi/utils.c
+++ b/dlls/dxgi/utils.c
@@ -513,7 +513,8 @@ unsigned int wined3d_bind_flags_from_dxgi_usage(DXGI_USAGE dxgi_usage)
 }
 
 #define DXGI_WINED3D_SWAPCHAIN_FLAGS \
-        (WINED3D_SWAPCHAIN_USE_CLOSEST_MATCHING_MODE | WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT | WINED3D_SWAPCHAIN_HOOK)
+        (WINED3D_SWAPCHAIN_USE_CLOSEST_MATCHING_MODE | WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT | WINED3D_SWAPCHAIN_HOOK | \
+         WINED3D_SWAPCHAIN_RESTORE_WINDOW_STATE)
 
 unsigned int dxgi_swapchain_flags_from_wined3d(unsigned int wined3d_flags)
 {
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index 8ded2cb..81de3b4 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -2116,6 +2116,7 @@ void wined3d_swapchain_state_restore_from_fullscreen(struct wined3d_swapchain_st
         HWND window, const RECT *window_rect)
 {
     unsigned int window_pos_flags = SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOACTIVATE;
+    HWND window_pos_after = NULL;
     LONG style, exstyle;
     RECT rect = {0};
     BOOL filter;
@@ -2123,6 +2124,18 @@ void wined3d_swapchain_state_restore_from_fullscreen(struct wined3d_swapchain_st
     if (!state->style && !state->exstyle)
         return;
 
+    if (state->desc.flags & WINED3D_SWAPCHAIN_RESTORE_WINDOW_STATE)
+    {
+        if (!(state->desc.flags & WINED3D_SWAPCHAIN_NO_VISIBILITY_CHANGES))
+            window_pos_flags |= (state->style & WS_VISIBLE) ? SWP_SHOWWINDOW : SWP_HIDEWINDOW;
+
+        if (!(state->desc.flags & WINED3D_SWAPCHAIN_NO_ZORDER_CHANGES))
+        {
+            window_pos_after = (state->exstyle & WS_EX_TOPMOST) ? HWND_TOPMOST : HWND_NOTOPMOST;
+            window_pos_flags &= ~SWP_NOZORDER;
+        }
+    }
+
     style = GetWindowLongW(window, GWL_STYLE);
     exstyle = GetWindowLongW(window, GWL_EXSTYLE);
 
@@ -2154,7 +2167,7 @@ void wined3d_swapchain_state_restore_from_fullscreen(struct wined3d_swapchain_st
         rect = *window_rect;
     else
         window_pos_flags |= (SWP_NOMOVE | SWP_NOSIZE);
-    SetWindowPos(window, 0, rect.left, rect.top,
+    SetWindowPos(window, window_pos_after, rect.left, rect.top,
             rect.right - rect.left, rect.bottom - rect.top, window_pos_flags);
 
     wined3d_filter_messages(window, filter);
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 726c715..25a1c5f 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -907,6 +907,7 @@ enum wined3d_shader_type
 #define WINED3D_SWAPCHAIN_HOOK                                  0x00020000u
 #define WINED3D_SWAPCHAIN_NO_ZORDER_CHANGES                     0x00040000u
 #define WINED3D_SWAPCHAIN_NO_VISIBILITY_CHANGES                 0x00080000u
+#define WINED3D_SWAPCHAIN_RESTORE_WINDOW_STATE                  0x00100000u
 
 #define WINED3DDP_MAXTEXCOORD                                   8
 
-- 
2.21.0




More information about the wine-devel mailing list