Engine: only call ImguiSystem message handler when imgui surface is active

Save even more performance by not calling the ImguiSystem message handler at all when the imgui surface isn't active; we don't need to track input movement at all when this isn't active. Also dropped the blockage of all window messages except 'WM_SETCURSOR', added a detailed comment as to why this is blocked.
This commit is contained in:
Kawe Mazidjatari 2024-11-15 13:40:39 +01:00
parent 36bee21784
commit f0fcb821a8

View File

@ -33,8 +33,6 @@ LRESULT CGame::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (!ImguiSystem()->IsInitialized()) if (!ImguiSystem()->IsInitialized())
return CGame__WindowProc(hWnd, uMsg, wParam, lParam); return CGame__WindowProc(hWnd, uMsg, wParam, lParam);
ImguiSystem()->MessageHandler(hWnd, uMsg, wParam, lParam);
if (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN) if (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN)
{ {
if (wParam == g_ImGuiConfig.m_ConsoleConfig.m_nBind0 || if (wParam == g_ImGuiConfig.m_ConsoleConfig.m_nBind0 ||
@ -55,26 +53,16 @@ LRESULT CGame::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (g_Console.IsActivated() || g_Browser.IsActivated()) if (g_Console.IsActivated() || g_Browser.IsActivated())
{////////////////////////////////////////////////////////////////////////////// {//////////////////////////////////////////////////////////////////////////////
g_bBlockInput = true; g_bBlockInput = true;
ImguiSystem()->MessageHandler(hWnd, uMsg, wParam, lParam);
switch (uMsg) switch (uMsg)
{ {
case WM_LBUTTONDOWN: // This is required as the game calls CInputStackSystem::SetCursorPosition(),
case WM_LBUTTONUP: // which hides the cursor. It keeps calling it as the game window is the top
case WM_LBUTTONDBLCLK: // most window, even when the ImGui window is enabled. We could in the future
case WM_RBUTTONDOWN: // create a new input context for the imgui system, then push it to the stack
case WM_RBUTTONUP: // after the game's context and call CInputStackSystem::EnableInputContext()
case WM_RBUTTONDBLCLK: // on the new imgui context.
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_MBUTTONDBLCLK:
case WM_KEYDOWN:
case WM_KEYUP:
case WM_MOUSEACTIVATE:
case WM_MOUSEHOVER:
case WM_MOUSEHWHEEL:
case WM_MOUSELEAVE:
case WM_MOUSEMOVE:
case WM_MOUSEWHEEL:
case WM_SETCURSOR: case WM_SETCURSOR:
uMsg = WM_NULL; uMsg = WM_NULL;
break; break;