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())
return CGame__WindowProc(hWnd, uMsg, wParam, lParam);
ImguiSystem()->MessageHandler(hWnd, uMsg, wParam, lParam);
if (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN)
{
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())
{//////////////////////////////////////////////////////////////////////////////
g_bBlockInput = true;
ImguiSystem()->MessageHandler(hWnd, uMsg, wParam, lParam);
switch (uMsg)
{
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_LBUTTONDBLCLK:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
case WM_RBUTTONDBLCLK:
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:
// This is required as the game calls CInputStackSystem::SetCursorPosition(),
// which hides the cursor. It keeps calling it as the game window is the top
// most window, even when the ImGui window is enabled. We could in the future
// create a new input context for the imgui system, then push it to the stack
// after the game's context and call CInputStackSystem::EnableInputContext()
// on the new imgui context.
case WM_SETCURSOR:
uMsg = WM_NULL;
break;