Fix Windows64 mouse capture and static initialization crashes

This commit is contained in:
semiloker 2026-03-02 22:01:07 +02:00
parent 53443f1d55
commit ec5f9a29cd
2 changed files with 12 additions and 3 deletions

View file

@ -403,6 +403,15 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (LOWORD(wParam) == WA_INACTIVE) if (LOWORD(wParam) == WA_INACTIVE)
KMInput.SetCapture(false); KMInput.SetCapture(false);
break; 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: case WM_KILLFOCUS:
KMInput.SetCapture(false); KMInput.SetCapture(false);
KMInput.ClearAllState(); KMInput.ClearAllState();

View file

@ -161,9 +161,9 @@ Packet::Packet() : createTime( System::currentTimeMillis() )
unordered_map<int, packetCreateFn> Packet::idToCreateMap; unordered_map<int, packetCreateFn> Packet::idToCreateMap;
unordered_set<int> Packet::clientReceivedPackets = unordered_set<int>(); unordered_set<int> Packet::clientReceivedPackets;
unordered_set<int> Packet::serverReceivedPackets = unordered_set<int>(); unordered_set<int> Packet::serverReceivedPackets;
unordered_set<int> Packet::sendToAnyClientPackets = unordered_set<int>(); unordered_set<int> Packet::sendToAnyClientPackets;
// 4J Added // 4J Added
unordered_map<int, Packet::PacketStatistics *> Packet::outgoingStatistics = unordered_map<int, Packet::PacketStatistics *>(); unordered_map<int, Packet::PacketStatistics *> Packet::outgoingStatistics = unordered_map<int, Packet::PacketStatistics *>();