From a172cab34f4b9fdd907a62f27a9d6c0bb0e5005a Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Thu, 26 Sep 2024 20:03:22 -0600 Subject: [PATCH] [dxgi] Delay qualifying foreground loss as occlusion --- src/wsi/win32/wsi_platform_win32.h | 3 +++ src/wsi/win32/wsi_window_win32.cpp | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/wsi/win32/wsi_platform_win32.h b/src/wsi/win32/wsi_platform_win32.h index 2a47e4f2f..3fdbba019 100644 --- a/src/wsi/win32/wsi_platform_win32.h +++ b/src/wsi/win32/wsi_platform_win32.h @@ -7,6 +7,9 @@ namespace dxvk::wsi { class Win32WsiDriver : public WsiDriver { + private: + uint64_t m_lastForegroundTimestamp = 0; + public: // Platform virtual std::vector getInstanceExtensions(); diff --git a/src/wsi/win32/wsi_window_win32.cpp b/src/wsi/win32/wsi_window_win32.cpp index 4deb039ef..b30608a2d 100644 --- a/src/wsi/win32/wsi_window_win32.cpp +++ b/src/wsi/win32/wsi_window_win32.cpp @@ -193,6 +193,7 @@ namespace dxvk::wsi { rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_FRAMECHANGED | SWP_SHOWWINDOW | SWP_NOACTIVATE); + m_lastForegroundTimestamp = 0; return true; } @@ -260,7 +261,12 @@ namespace dxvk::wsi { bool Win32WsiDriver::isOccluded(HWND hWindow) { - return ::GetForegroundWindow() != hWindow; + if (::GetForegroundWindow() == hWindow) + { + m_lastForegroundTimestamp = GetTickCount64(); + return false; + } + return m_lastForegroundTimestamp && GetTickCount64() - m_lastForegroundTimestamp > 100; }