From 1fd4c25cd0188f96c7d1fe7b0a8b072763eed032 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 24 Nov 2024 00:40:44 +0100 Subject: [PATCH] Engine: fix imgui regression causing inputs to be stuck Holding a key while closing the panel will keep the message in the event queue, the next time one of the windows are opened, the message will be spammed. Send a null msg to clear it properly. --- src/engine/sys_mainwind.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/engine/sys_mainwind.cpp b/src/engine/sys_mainwind.cpp index 65c01f41..8163d6e2 100644 --- a/src/engine/sys_mainwind.cpp +++ b/src/engine/sys_mainwind.cpp @@ -62,7 +62,6 @@ LRESULT CGame::ImguiWindowProc(HWND hWnd, UINT& uMsg, WPARAM wParam, LPARAM lPar if (g_Console.IsActivated() || g_Browser.IsActivated()) {////////////////////////////////////////////////////////////////////////////// - g_bBlockInput = true; hr = ImguiSystem()->MessageHandler(hWnd, uMsg, wParam, lParam); switch (uMsg) @@ -79,9 +78,20 @@ LRESULT CGame::ImguiWindowProc(HWND hWnd, UINT& uMsg, WPARAM wParam, LPARAM lPar default: break; } + + g_bBlockInput = true; }////////////////////////////////////////////////////////////////////////////// else { + if (g_bBlockInput) + { + // 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); + } + g_bBlockInput = false; }