[PATCH v2 02/10] wined3d: Add WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT flag.

Józef Kucia jkucia at codeweavers.com
Wed Aug 3 02:41:39 CDT 2016


Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---

Version 2:
  * Rename WINED3DSWAPCHAIN_RESTORE_WINDOW_RECT to
    WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT.
  * Also restore window rect while destroying fullscreen swapchain.

---
 dlls/ddraw/ddraw.c             |  2 +-
 dlls/dxgi/utils.c              |  4 +++-
 dlls/wined3d/device.c          | 15 ++++++++++++---
 dlls/wined3d/swapchain.c       | 13 ++++++++++++-
 dlls/wined3d/wined3d.spec      |  2 +-
 dlls/wined3d/wined3d_private.h |  1 +
 include/wine/wined3d.h         |  4 +++-
 7 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index aa4ac5c..c9efba6 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -890,7 +890,7 @@ static HRESULT ddraw_set_cooperative_level(struct ddraw *ddraw, HWND window,
     if ((cooplevel & DDSCL_FULLSCREEN) != (ddraw->cooperative_level & DDSCL_FULLSCREEN) || window != ddraw->dest_window)
     {
         if (ddraw->cooperative_level & DDSCL_FULLSCREEN)
-            wined3d_device_restore_fullscreen_window(ddraw->wined3d_device, ddraw->dest_window);
+            wined3d_device_restore_fullscreen_window(ddraw->wined3d_device, ddraw->dest_window, NULL);
 
         if (cooplevel & DDSCL_FULLSCREEN)
         {
diff --git a/dlls/dxgi/utils.c b/dlls/dxgi/utils.c
index f671e30..5c6c5bd 100644
--- a/dlls/dxgi/utils.c
+++ b/dlls/dxgi/utils.c
@@ -405,6 +405,8 @@ unsigned int dxgi_swapchain_flags_from_wined3d(unsigned int wined3d_flags)
 {
     unsigned int flags = 0;
 
+    wined3d_flags &= ~WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT;
+
     if (wined3d_flags & WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH)
     {
         wined3d_flags &= ~WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH;
@@ -419,7 +421,7 @@ unsigned int dxgi_swapchain_flags_from_wined3d(unsigned int wined3d_flags)
 
 unsigned int wined3d_swapchain_flags_from_dxgi(unsigned int flags)
 {
-    unsigned int wined3d_flags = 0; /* WINED3D_SWAPCHAIN_DISCARD_DEPTHSTENCIL? */
+    unsigned int wined3d_flags = WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT; /* WINED3D_SWAPCHAIN_DISCARD_DEPTHSTENCIL? */
 
     if (flags & DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH)
     {
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 34ce224..9a4f0d3 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -911,12 +911,16 @@ void CDECL wined3d_device_setup_fullscreen_window(struct wined3d_device *device,
     device->filter_messages = filter_messages;
 }
 
-void CDECL wined3d_device_restore_fullscreen_window(struct wined3d_device *device, HWND window)
+void CDECL wined3d_device_restore_fullscreen_window(struct wined3d_device *device, 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) return;
+    if (!device->style && !device->exStyle)
+        return;
 
     style = GetWindowLongW(window, GWL_STYLE);
     exstyle = GetWindowLongW(window, GWL_EXSTYLE);
@@ -945,7 +949,12 @@ void CDECL wined3d_device_restore_fullscreen_window(struct wined3d_device *devic
         SetWindowLongW(window, GWL_STYLE, device->style);
         SetWindowLongW(window, GWL_EXSTYLE, device->exStyle);
     }
-    SetWindowPos(window, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
+
+    if (window_rect)
+        rect = *window_rect;
+    else
+        window_pos_flags |= (SWP_NOMOVE | SWP_NOSIZE);
+    SetWindowPos(window, 0, rect.left, rect.top, rect.right, rect.bottom, window_pos_flags);
 
     device->filter_messages = filter_messages;
 
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index 1adf8eb..e3d6259 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -77,6 +77,13 @@ static void swapchain_cleanup(struct wined3d_swapchain *swapchain)
         if (FAILED(hr = wined3d_set_adapter_display_mode(swapchain->device->wined3d,
                 swapchain->device->adapter->ordinal, &swapchain->original_mode)))
             ERR("Failed to restore display mode, hr %#x.\n", hr);
+
+        if (swapchain->desc.flags & WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT)
+        {
+            wined3d_device_restore_fullscreen_window(swapchain->device, swapchain->device_window,
+                    &swapchain->original_window_rect);
+            wined3d_device_release_focus_window(swapchain->device);
+        }
     }
 
     if (swapchain->backup_dc)
@@ -839,6 +846,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
         ERR("Failed to get current display mode, hr %#x.\n", hr);
         goto err;
     }
+    GetWindowRect(window, &swapchain->original_window_rect);
 
     GetClientRect(window, &client_rect);
     if (desc->windowed)
@@ -1472,8 +1480,11 @@ HRESULT CDECL wined3d_swapchain_set_fullscreen(struct wined3d_swapchain *swapcha
     }
     else if (!swapchain->desc.windowed)
     {
+        RECT *window_rect = NULL;
         /* Fullscreen -> windowed switch */
-        wined3d_device_restore_fullscreen_window(device, swapchain->device_window);
+        if (swapchain->desc.flags & WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT)
+            window_rect = &swapchain->original_window_rect;
+        wined3d_device_restore_fullscreen_window(device, swapchain->device_window, window_rect);
         wined3d_device_release_focus_window(device);
     }
 
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index bdf3916..e0cc501 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -107,7 +107,7 @@
 @ cdecl wined3d_device_process_vertices(ptr long long long ptr ptr long long)
 @ cdecl wined3d_device_release_focus_window(ptr)
 @ cdecl wined3d_device_reset(ptr ptr ptr ptr long)
-@ cdecl wined3d_device_restore_fullscreen_window(ptr ptr)
+@ cdecl wined3d_device_restore_fullscreen_window(ptr ptr ptr)
 @ cdecl wined3d_device_set_base_vertex_index(ptr long)
 @ cdecl wined3d_device_set_clip_plane(ptr long ptr)
 @ cdecl wined3d_device_set_clip_status(ptr ptr)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index abb950c..f300e4b 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3228,6 +3228,7 @@ struct wined3d_swapchain
     struct wined3d_texture *front_buffer;
     struct wined3d_swapchain_desc desc;
     struct wined3d_display_mode original_mode, d3d_mode;
+    RECT original_window_rect;
     struct wined3d_gamma_ramp orig_gamma;
     BOOL render_to_fbo, reapply_mode;
     const struct wined3d_format *ds_format;
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 4f26f2e..661191d 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -825,6 +825,7 @@ enum wined3d_display_rotation
 #define WINED3D_SWAPCHAIN_NOAUTOROTATE                          0x00000020u
 #define WINED3D_SWAPCHAIN_UNPRUNEDMODE                          0x00000040u
 #define WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH                     0x00001000u
+#define WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT                   0x00002000u
 
 #define WINED3DDP_MAXTEXCOORD                                   8
 
@@ -2252,7 +2253,8 @@ void __cdecl wined3d_device_release_focus_window(struct wined3d_device *device);
 HRESULT __cdecl wined3d_device_reset(struct wined3d_device *device,
         const struct wined3d_swapchain_desc *swapchain_desc, const struct wined3d_display_mode *mode,
         wined3d_device_reset_cb callback, BOOL reset_state);
-void __cdecl wined3d_device_restore_fullscreen_window(struct wined3d_device *device, HWND window);
+void __cdecl wined3d_device_restore_fullscreen_window(struct wined3d_device *device, HWND window,
+        const RECT *window_rect);
 void __cdecl wined3d_device_set_base_vertex_index(struct wined3d_device *device, INT base_index);
 HRESULT __cdecl wined3d_device_set_clip_plane(struct wined3d_device *device,
         UINT plane_idx, const struct wined3d_vec4 *plane);
-- 
2.7.3




More information about the wine-patches mailing list