From 6a264415679050eedf3ebd4a9d916aaf610fc68e Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Wed, 16 Apr 2025 20:58:22 +0300 Subject: [PATCH] Ensure mouse position is up-to-date during button down events --- Source/Engine/Platform/SDL/SDLInput.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/Engine/Platform/SDL/SDLInput.cpp b/Source/Engine/Platform/SDL/SDLInput.cpp index 0ef8c2211..788c70c1e 100644 --- a/Source/Engine/Platform/SDL/SDLInput.cpp +++ b/Source/Engine/Platform/SDL/SDLInput.cpp @@ -541,6 +541,11 @@ bool SDLInput::HandleEvent(SDLWindow* window, SDL_Event& event) case SDL_EVENT_MOUSE_BUTTON_UP: { Float2 mousePos = window->ClientToScreen({ event.button.x, event.button.y }); + + // In case of activating the window from non-focused state, we might not have received the motion event yet + if (!Input::Mouse->IsRelative() && event.button.down) + Input::Mouse->OnMouseMove(mousePos, window); + MouseButton button = MouseButton::None; if (event.button.button == SDL_BUTTON_LEFT) button = MouseButton::Left;