diff --git a/src/engine/sys_mainwind.cpp b/src/engine/sys_mainwind.cpp index eb06e9ee..64d49239 100644 --- a/src/engine/sys_mainwind.cpp +++ b/src/engine/sys_mainwind.cpp @@ -83,16 +83,14 @@ LRESULT CGame::ImguiWindowProc(HWND hWnd, UINT& uMsg, WPARAM wParam, LPARAM lPar }////////////////////////////////////////////////////////////////////////////// else { - if (g_bBlockInput) + if (g_bBlockInput.exchange(false)) { - // Dry run with null msg to clear the event queue, we have to do this as - // the menu's can be closed while still holding down a key. That key will - // remain in the event queue so the next time a window is opened, that - // key will be spammed until that particular key msg is sent here again. - hr = ImguiSystem()->MessageHandler(hWnd, WM_NULL, wParam, lParam); + // Dry run with kill focus msg to clear the keydown state, we have to do + // this as the menu's can be closed while still holding down a key. That + // key will remain pressed down so the next time a window is opened that + // key will be spammed, until that particular key msg is sent here again. + hr = ImguiSystem()->MessageHandler(hWnd, WM_KILLFOCUS, wParam, lParam); } - - g_bBlockInput = false; } return hr; diff --git a/src/windows/input.cpp b/src/windows/input.cpp index ab497380..4a16fc58 100644 --- a/src/windows/input.cpp +++ b/src/windows/input.cpp @@ -19,7 +19,7 @@ static IShowCursor g_oShowCursor = nullptr; /////////////////////////////////////////////////////////////////////////////// static POINT g_pLastCursorPos { 0 }; -extern BOOL g_bBlockInput = false; +extern std::atomic_bool g_bBlockInput = false; //############################################################################# // INITIALIZATION diff --git a/src/windows/input.h b/src/windows/input.h index 4c050f86..65592817 100644 --- a/src/windows/input.h +++ b/src/windows/input.h @@ -7,6 +7,6 @@ void Input_Shutdown(); ///////////////////////////////////////////////////////////////////////////// // Globals -extern BOOL g_bBlockInput; +extern std::atomic_bool g_bBlockInput; /////////////////////////////////////////////////////////////////////////////