diff --git a/rts/Game/UI/GuiHandler.cpp b/rts/Game/UI/GuiHandler.cpp index eebec1ece6..70f6dc712f 100644 --- a/rts/Game/UI/GuiHandler.cpp +++ b/rts/Game/UI/GuiHandler.cpp @@ -3452,8 +3452,8 @@ void CGuiHandler::DrawMapStuff(bool onMiniMap) glDisable(GL_ALPHA_TEST); } - float3 tracePos = camera->GetPos(); - float3 traceDir = mouse->dir; + float3 tracePos; + float3 traceDir; // setup for minimap proxying const bool minimapInput = (activeReceiver != this && !mouse->offscreen && GetReceiverAt(mouse->lastx, mouse->lasty) == minimap); @@ -3469,6 +3469,9 @@ void CGuiHandler::DrawMapStuff(bool onMiniMap) if (miniMapMarker && minimap->FullProxy() && !onMiniMap && !minimap->GetMinimized()) { DrawMiniMapMarker(tracePos); } + } else { + tracePos = camera->GetPos(); + traceDir = mouse->dir; } diff --git a/rts/Game/UI/MouseHandler.cpp b/rts/Game/UI/MouseHandler.cpp index cbbb477157..c5362405cd 100644 --- a/rts/Game/UI/MouseHandler.cpp +++ b/rts/Game/UI/MouseHandler.cpp @@ -213,6 +213,11 @@ void CMouseHandler::ReloadCursors() activeCursorIdx = defCursorIt->second; } +void CMouseHandler::WindowEnter() +{ + offscreen = false; +} + void CMouseHandler::WindowLeave() { offscreen = true; diff --git a/rts/Game/UI/MouseHandler.h b/rts/Game/UI/MouseHandler.h index 5a3f8d497d..9b046426ff 100644 --- a/rts/Game/UI/MouseHandler.h +++ b/rts/Game/UI/MouseHandler.h @@ -51,6 +51,7 @@ class CMouseHandler void MouseMove(int x, int y, int dx, int dy); void MouseWheel(float delta); void WindowLeave(); + void WindowEnter(); bool AssignMouseCursor(const std::string& cmdName, const std::string& fileName, diff --git a/rts/System/Input/MouseInput.cpp b/rts/System/Input/MouseInput.cpp index 01718dc58b..ef3f0c457e 100644 --- a/rts/System/Input/MouseInput.cpp +++ b/rts/System/Input/MouseInput.cpp @@ -96,18 +96,23 @@ bool IMouseInput::HandleSDLMouseEvent(const SDL_Event& event) } break; case SDL_WINDOWEVENT: { - if (event.window.event == SDL_WINDOWEVENT_LEAVE) { - // mouse left window; set pos internally to view center-pixel to prevent endless scrolling - mousepos = { - globalRendering->viewPosX + (globalRendering->viewSizeX >> 1), - globalRendering->viewWindowOffsetY + (globalRendering->viewSizeY >> 1) - }; - - if (mouse != nullptr) - mouse->WindowLeave(); - - } break; - } + switch (event.window.event) { + case SDL_WINDOWEVENT_ENTER: { + if (mouse != nullptr) + mouse->WindowEnter(); + } break; + case SDL_WINDOWEVENT_LEAVE: { + // mouse left window; set pos internally to view center-pixel to prevent endless scrolling + mousepos = { + globalRendering->viewPosX + (globalRendering->viewSizeX >> 1), + globalRendering->viewWindowOffsetY + (globalRendering->viewSizeY >> 1) + }; + + if (mouse != nullptr) + mouse->WindowLeave(); + } break; + } + } break; } return false;