Skip to content

Commit

Permalink
[dxgi] Delay qualifying foreground loss as occlusion
Browse files Browse the repository at this point in the history
  • Loading branch information
gofman authored and doitsujin committed Sep 27, 2024
1 parent 4ed50ec commit a172cab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/wsi/win32/wsi_platform_win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
namespace dxvk::wsi {

class Win32WsiDriver : public WsiDriver {
private:
uint64_t m_lastForegroundTimestamp = 0;

public:
// Platform
virtual std::vector<const char *> getInstanceExtensions();
Expand Down
8 changes: 7 additions & 1 deletion src/wsi/win32/wsi_window_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}


Expand Down

0 comments on commit a172cab

Please sign in to comment.