Fix Windows64 mouse capture and static initialization crashes (#177)

This commit is contained in:
Andrew authored and GitHub committed 2026-03-03 03:17:10 +07:00
1 parent bbef5445f9
commit f917335b13
2 files changed
+12 -3

No files matched your search

@@ -403,6 +403,15 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (LOWORD(wParam) == WA_INACTIVE)
KMInput.SetCapture(false);
break;
case WM_SETFOCUS:
{
// Re-capture when window receives focus (e.g., after clicking on it)
Minecraft *pMinecraft = Minecraft::GetInstance();
bool shouldCapture = pMinecraft && app.GetGameStarted() && !ui.GetMenuDisplayed(0) && pMinecraft->screen == NULL;
if (shouldCapture)
KMInput.SetCapture(true);
}
break;
case WM_KILLFOCUS:
KMInput.SetCapture(false);
KMInput.ClearAllState();