diff --git a/src/dxgi/dxgi_swapchain.cpp b/src/dxgi/dxgi_swapchain.cpp index d02c62b5..183a33aa 100644 --- a/src/dxgi/dxgi_swapchain.cpp +++ b/src/dxgi/dxgi_swapchain.cpp @@ -365,8 +365,10 @@ namespace dxvk { } // If the swap chain allows it, change the display mode - if (m_desc.Flags & DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH) + if (m_desc.Flags & DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH) { ChangeDisplayMode(output.ptr(), pNewTargetParameters); + NotifyModeChange(m_monitor, FALSE); + } // Resize and reposition the window to DXGI_OUTPUT_DESC desc; @@ -622,6 +624,7 @@ namespace dxvk { ReleaseMonitorData(); } + NotifyModeChange(m_monitor, FALSE); return S_OK; } @@ -642,6 +645,8 @@ namespace dxvk { } // Restore internal state + HMONITOR monitor = m_monitor; + m_descFs.Windowed = TRUE; m_monitor = nullptr; m_target = nullptr; @@ -667,6 +672,7 @@ namespace dxvk { rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_FRAMECHANGED | SWP_NOACTIVATE); + NotifyModeChange(monitor, TRUE); return S_OK; } @@ -775,5 +781,28 @@ namespace dxvk { if (m_monitorInfo != nullptr) m_monitorInfo->ReleaseMonitorData(); } + + + void DxgiSwapChain::NotifyModeChange( + HMONITOR hMonitor, + BOOL Windowed) { + DEVMODEW devMode = { }; + devMode.dmSize = sizeof(devMode); + devMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY; + + if (GetMonitorDisplayMode(hMonitor, ENUM_CURRENT_SETTINGS, &devMode)) { + DXGI_MODE_DESC displayMode = { }; + displayMode.Width = devMode.dmPelsWidth; + displayMode.Height = devMode.dmPelsHeight; + displayMode.RefreshRate = { devMode.dmDisplayFrequency, 1 }; + displayMode.Format = m_desc.Format; + displayMode.ScanlineOrdering = m_descFs.ScanlineOrdering; + displayMode.Scaling = m_descFs.Scaling; + m_presenter->NotifyModeChange(Windowed, &displayMode); + } else { + Logger::warn("Failed to query current display mode"); + m_presenter->NotifyModeChange(Windowed, nullptr); + } + } } diff --git a/src/dxgi/dxgi_swapchain.h b/src/dxgi/dxgi_swapchain.h index a071ae4a..b3d308c5 100644 --- a/src/dxgi/dxgi_swapchain.h +++ b/src/dxgi/dxgi_swapchain.h @@ -218,6 +218,10 @@ namespace dxvk { DXGI_VK_MONITOR_DATA** ppData); void ReleaseMonitorData(); + + void NotifyModeChange( + HMONITOR hMonitor, + BOOL Windowed); };