mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-20 10:54:16 +01:00
[d3d9] Ignore multiple app activation window messages.
This commit is contained in:
parent
b0ed9e30ce
commit
957a305ca8
@ -10,6 +10,7 @@ namespace dxvk {
|
||||
struct D3D9WindowData {
|
||||
bool unicode;
|
||||
bool filter;
|
||||
bool activateProcessed;
|
||||
WNDPROC proc;
|
||||
D3D9SwapChainEx* swapchain;
|
||||
};
|
||||
@ -18,6 +19,13 @@ namespace dxvk {
|
||||
static dxvk::recursive_mutex g_windowProcMapMutex;
|
||||
static std::unordered_map<HWND, D3D9WindowData> g_windowProcMap;
|
||||
|
||||
static void SetActivateProcessed(HWND window, bool processed)
|
||||
{
|
||||
std::lock_guard lock(g_windowProcMapMutex);
|
||||
auto it = g_windowProcMap.find(window);
|
||||
if (it != g_windowProcMap.end())
|
||||
it->second.activateProcessed = processed;
|
||||
}
|
||||
|
||||
template <typename T, typename J, typename ... Args>
|
||||
auto CallCharsetFunction(T unicode, J ascii, bool isUnicode, Args... args) {
|
||||
@ -88,6 +96,7 @@ namespace dxvk {
|
||||
D3D9WindowData windowData;
|
||||
windowData.unicode = IsWindowUnicode(window);
|
||||
windowData.filter = false;
|
||||
windowData.activateProcessed = false;
|
||||
windowData.proc = reinterpret_cast<WNDPROC>(
|
||||
CallCharsetFunction(
|
||||
SetWindowLongPtrW, SetWindowLongPtrA, windowData.unicode,
|
||||
@ -129,7 +138,7 @@ namespace dxvk {
|
||||
|
||||
if (!(create_parms.BehaviorFlags & D3DCREATE_NOWINDOWCHANGES)) {
|
||||
D3D9WindowMessageFilter filter(window);
|
||||
if (wparam) {
|
||||
if (wparam && !windowData.activateProcessed) {
|
||||
// Heroes of Might and Magic V needs this to resume drawing after a focus loss
|
||||
D3DPRESENT_PARAMETERS params;
|
||||
RECT rect;
|
||||
@ -138,10 +147,12 @@ namespace dxvk {
|
||||
windowData.swapchain->GetPresentParameters(¶ms);
|
||||
SetWindowPos(window, nullptr, rect.left, rect.top, params.BackBufferWidth, params.BackBufferHeight,
|
||||
SWP_NOACTIVATE | SWP_NOZORDER);
|
||||
SetActivateProcessed(window, true);
|
||||
}
|
||||
else {
|
||||
else if (!wparam) {
|
||||
if (IsWindowVisible(window))
|
||||
ShowWindow(window, SW_MINIMIZE);
|
||||
SetActivateProcessed(window, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user