[PATCH 2/3] dxgi: Exit fullscreen state during Present if the window is no longer topmost.

Gabriel Ivăncescu gabrielopcode at gmail.com
Thu Jan 28 07:51:08 CST 2021


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

diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c
index 82e5fbf..6e586cd 100644
--- a/dlls/dxgi/swapchain.c
+++ b/dlls/dxgi/swapchain.c
@@ -328,13 +328,27 @@ static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetDevice(IDXGISwapChain1 *ifac
 static HRESULT d3d11_swapchain_present(struct d3d11_swapchain *swapchain,
         unsigned int sync_interval, unsigned int flags)
 {
+    HWND hwnd = d3d11_swapchain_get_hwnd(swapchain);
+    BOOL fullscreen;
+    HRESULT hr;
+
     if (sync_interval > 4)
     {
         WARN("Invalid sync interval %u.\n", sync_interval);
         return DXGI_ERROR_INVALID_CALL;
     }
 
-    if (IsIconic(d3d11_swapchain_get_hwnd(swapchain)))
+    hr = IDXGISwapChain1_GetFullscreenState(&swapchain->IDXGISwapChain1_iface, &fullscreen, NULL);
+    if (FAILED(hr))
+        return hr;
+
+    if (fullscreen && !(GetWindowLongW(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST))
+    {
+        IDXGISwapChain1_SetFullscreenState(&swapchain->IDXGISwapChain1_iface, FALSE, NULL);
+        return DXGI_STATUS_OCCLUDED;
+    }
+
+    if (IsIconic(hwnd))
         return DXGI_STATUS_OCCLUDED;
 
     if (flags & ~DXGI_PRESENT_TEST)
diff --git a/dlls/dxgi/tests/dxgi.c b/dlls/dxgi/tests/dxgi.c
index 14cb555..e859edc 100644
--- a/dlls/dxgi/tests/dxgi.c
+++ b/dlls/dxgi/tests/dxgi.c
@@ -2849,12 +2849,12 @@ static void test_set_fullscreen(IUnknown *device, BOOL is_d3d12)
     ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
     ok(!!fullscreen, "Got unexpected fullscreen %#x.\n", fullscreen);
     hr = IDXGISwapChain_Present(swapchain, 0, 0);
-    todo_wine ok(hr == DXGI_STATUS_OCCLUDED || broken(hr == DXGI_ERROR_INVALID_CALL) /* Win10 1809 */, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DXGI_STATUS_OCCLUDED || broken(hr == DXGI_ERROR_INVALID_CALL) /* Win10 1809 */, "Got unexpected hr %#x.\n", hr);
     if (hr != DXGI_ERROR_INVALID_CALL)
     {
         hr = IDXGISwapChain_GetFullscreenState(swapchain, &fullscreen, NULL);
         ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
-        todo_wine ok(!fullscreen, "Got unexpected fullscreen %#x.\n", fullscreen);
+        ok(!fullscreen, "Got unexpected fullscreen %#x.\n", fullscreen);
         hr = IDXGISwapChain_Present(swapchain, 0, 0);
         ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
     }
-- 
2.29.2




More information about the wine-devel mailing list