[PATCH 7/8] wined3d: Restore the window visibility and z-order upon exiting fullscreen, if requested.

Henri Verbeet hverbeet at codeweavers.com
Tue Jul 7 14:13:15 CDT 2020


From: Gabriel Ivăncescu <gabrielopcode at gmail.com>

Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
This supersedes patch 188411.

 dlls/dxgi/tests/dxgi.c   |  2 --
 dlls/dxgi/utils.c        |  3 ++-
 dlls/wined3d/swapchain.c | 11 ++++++++++-
 include/wine/wined3d.h   |  1 +
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/dlls/dxgi/tests/dxgi.c b/dlls/dxgi/tests/dxgi.c
index 92d65c8b4af..ea896260c76 100644
--- a/dlls/dxgi/tests/dxgi.c
+++ b/dlls/dxgi/tests/dxgi.c
@@ -5888,10 +5888,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 ca87e3c1942..6c49d4539c3 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 a51b934af02..6270c363bb9 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -2112,6 +2112,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;
@@ -2119,6 +2120,14 @@ 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)
+            && !(state->desc.flags & WINED3D_SWAPCHAIN_NO_WINDOW_CHANGES))
+    {
+        window_pos_after = (state->exstyle & WS_EX_TOPMOST) ? HWND_TOPMOST : HWND_NOTOPMOST;
+        window_pos_flags |= (state->style & WS_VISIBLE) ? SWP_SHOWWINDOW : SWP_HIDEWINDOW;
+        window_pos_flags &= ~SWP_NOZORDER;
+    }
+
     style = GetWindowLongW(window, GWL_STYLE);
     exstyle = GetWindowLongW(window, GWL_EXSTYLE);
 
@@ -2150,7 +2159,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 0d40d38c565..69fcce45762 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -906,6 +906,7 @@ enum wined3d_shader_type
 #define WINED3D_SWAPCHAIN_IMPLICIT                              0x00010000u
 #define WINED3D_SWAPCHAIN_HOOK                                  0x00020000u
 #define WINED3D_SWAPCHAIN_NO_WINDOW_CHANGES                     0x00040000u
+#define WINED3D_SWAPCHAIN_RESTORE_WINDOW_STATE                  0x00080000u
 
 #define WINED3DDP_MAXTEXCOORD                                   8
 
-- 
2.20.1




More information about the wine-devel mailing list