1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-15 07:29:17 +01:00

d3d9: Send necessary messages for full-screen windows during WM_ACTIVATEAPP.

This commit is contained in:
Gabriel Ivăncescu 2020-09-02 17:24:24 +03:00 committed by Joshie
parent dde28a967f
commit 83f6400a07

View File

@ -14,6 +14,7 @@ namespace dxvk {
bool unicode; bool unicode;
bool filter; bool filter;
WNDPROC proc; WNDPROC proc;
D3D9SwapChainEx* swapchain;
}; };
@ -82,7 +83,7 @@ namespace dxvk {
} }
void HookWindowProc(HWND window) { void HookWindowProc(HWND window, D3D9SwapChainEx* swapchain) {
std::lock_guard lock(g_windowProcMapMutex); std::lock_guard lock(g_windowProcMapMutex);
ResetWindowProc(window); ResetWindowProc(window);
@ -94,6 +95,7 @@ namespace dxvk {
CallCharsetFunction( CallCharsetFunction(
SetWindowLongPtrW, SetWindowLongPtrA, windowData.unicode, SetWindowLongPtrW, SetWindowLongPtrA, windowData.unicode,
window, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(D3D9WindowProc))); window, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(D3D9WindowProc)));
windowData.swapchain = swapchain;
g_windowProcMap[window] = std::move(windowData); g_windowProcMap[window] = std::move(windowData);
} }
@ -124,6 +126,27 @@ namespace dxvk {
if (message == WM_DESTROY) if (message == WM_DESTROY)
ResetWindowProc(window); ResetWindowProc(window);
else if (message == WM_ACTIVATEAPP) {
D3DDEVICE_CREATION_PARAMETERS create_parms;
windowData.swapchain->GetDevice()->GetCreationParameters(&create_parms);
if (!(create_parms.BehaviorFlags & D3DCREATE_NOWINDOWCHANGES)) {
if (wparam) {
// Heroes of Might and Magic V needs this to resume drawing after a focus loss
D3DPRESENT_PARAMETERS params;
RECT rect;
GetMonitorRect(GetDefaultMonitor(), &rect);
windowData.swapchain->GetPresentParameters(&params);
SetWindowPos(window, nullptr, rect.left, rect.top, params.BackBufferWidth, params.BackBufferHeight,
SWP_NOACTIVATE | SWP_NOZORDER);
}
else {
if (IsWindowVisible(window))
ShowWindow(window, SW_MINIMIZE);
}
}
}
return CallCharsetFunction( return CallCharsetFunction(
CallWindowProcW, CallWindowProcA, unicode, CallWindowProcW, CallWindowProcA, unicode,
@ -1398,7 +1421,7 @@ namespace dxvk {
// Some games restore window styles after we have changed it, so hooking is // Some games restore window styles after we have changed it, so hooking is
// also required. Doing it will allow us to create fullscreen windows // also required. Doing it will allow us to create fullscreen windows
// regardless of their style and it also appears to work on Windows. // regardless of their style and it also appears to work on Windows.
HookWindowProc(m_window); HookWindowProc(m_window, this);
D3D9WindowMessageFilter filter(m_window); D3D9WindowMessageFilter filter(m_window);