Skip to content

Commit

Permalink
GS/DX: Fix ALT+ENTER causing mode switch
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Mar 29, 2024
1 parent 615e30f commit 4dca6c3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
19 changes: 15 additions & 4 deletions pcsx2/GS/Renderers/DX11/GSDevice11.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2002-2023 PCSX2 Dev Team
// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team
// SPDX-License-Identifier: LGPL-3.0+

#include "GS.h"
Expand All @@ -10,6 +10,7 @@
#include "Host.h"

#include "common/BitUtils.h"
#include "common/Error.h"
#include "common/Path.h"
#include "common/StringUtil.h"

Expand Down Expand Up @@ -709,9 +710,19 @@ bool GSDevice11::CreateSwapChain()
}
}

hr = m_dxgi_factory->MakeWindowAssociation(window_hwnd, DXGI_MWA_NO_WINDOW_CHANGES);
if (FAILED(hr))
Console.Warning("MakeWindowAssociation() to disable ALT+ENTER failed");
// MWA needs to be called on the correct factory.
wil::com_ptr_nothrow<IDXGIFactory> swap_chain_factory;
hr = m_swap_chain->GetParent(IID_PPV_ARGS(swap_chain_factory.put()));
if (SUCCEEDED(hr))
{
hr = swap_chain_factory->MakeWindowAssociation(window_hwnd, DXGI_MWA_NO_WINDOW_CHANGES);
if (FAILED(hr))
Console.ErrorFmt("MakeWindowAssociation() to disable ALT+ENTER failed: {}", Error::CreateHResult(hr).GetDescription());
}
else
{
Console.ErrorFmt("GetParent() on swap chain to get factory failed: {}", Error::CreateHResult(hr).GetDescription());
}

if (!CreateSwapChainRTV())
{
Expand Down
19 changes: 15 additions & 4 deletions pcsx2/GS/Renderers/DX12/GSDevice12.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2002-2023 PCSX2 Dev Team
// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team
// SPDX-License-Identifier: LGPL-3.0+

#include "GS/GS.h"
Expand All @@ -14,6 +14,7 @@

#include "common/Console.h"
#include "common/BitUtils.h"
#include "common/Error.h"
#include "common/HostSys.h"
#include "common/ScopedGuard.h"
#include "common/SmallString.h"
Expand Down Expand Up @@ -855,9 +856,19 @@ bool GSDevice12::CreateSwapChain()
Console.Warning("Failed to create windowed swap chain.");
}

hr = m_dxgi_factory->MakeWindowAssociation(window_hwnd, DXGI_MWA_NO_WINDOW_CHANGES);
if (FAILED(hr))
Console.Warning("MakeWindowAssociation() to disable ALT+ENTER failed");
// MWA needs to be called on the correct factory.
wil::com_ptr_nothrow<IDXGIFactory> swap_chain_factory;
hr = m_swap_chain->GetParent(IID_PPV_ARGS(swap_chain_factory.put()));
if (SUCCEEDED(hr))
{
hr = swap_chain_factory->MakeWindowAssociation(window_hwnd, DXGI_MWA_NO_WINDOW_CHANGES);
if (FAILED(hr))
Console.ErrorFmt("MakeWindowAssociation() to disable ALT+ENTER failed: {}", Error::CreateHResult(hr).GetDescription());
}
else
{
Console.ErrorFmt("GetParent() on swap chain to get factory failed: {}", Error::CreateHResult(hr).GetDescription());
}

if (!CreateSwapChainRTV())
{
Expand Down

0 comments on commit 4dca6c3

Please sign in to comment.