From a2aa7696d4dec8848fb71dbd02961b6242dfdafb Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Mon, 22 Jun 2026 19:59:11 +0200 Subject: [PATCH] bugfix(mouse): Fix bad drag tolerances with high scroll speed factors --- Core/GameEngine/Include/GameClient/Mouse.h | 2 ++ Core/GameEngine/Source/GameClient/Input/Mouse.cpp | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Core/GameEngine/Include/GameClient/Mouse.h b/Core/GameEngine/Include/GameClient/Mouse.h index 849a933f37f..4ba50e63e17 100644 --- a/Core/GameEngine/Include/GameClient/Mouse.h +++ b/Core/GameEngine/Include/GameClient/Mouse.h @@ -323,6 +323,8 @@ class Mouse : public SubsystemInterface Bool isClick(const ICoord2D *anchor, const ICoord2D *dest, UnsignedInt previousMouseClick, UnsignedInt currentMouseClick); + Real getDragToleranceAdjustedForScrollFactor() const; + AsciiString m_tooltipFontName; ///< tooltip font Int m_tooltipFontSize; ///< tooltip font Bool m_tooltipFontIsBold; ///< tooltip font diff --git a/Core/GameEngine/Source/GameClient/Input/Mouse.cpp b/Core/GameEngine/Source/GameClient/Input/Mouse.cpp index a1c2cb97a4e..ece0698d142 100644 --- a/Core/GameEngine/Source/GameClient/Input/Mouse.cpp +++ b/Core/GameEngine/Source/GameClient/Input/Mouse.cpp @@ -390,11 +390,14 @@ Bool Mouse::isClick(const ICoord2D *anchor, const ICoord2D *dest, UnsignedInt pr delta.x = anchor->x - dest->x; delta.y = anchor->y - dest->y; + // TheSuperHackers @bugfix Use the adjusted drag tolerance to prevent too far tolerances with high scroll factors, + // because higher scroll speeds will travel further by the delta. + const Real dragTolerance = getDragToleranceAdjustedForScrollFactor(); // if the mouse hasn't moved further than the tolerance distance // or the click took less than the tolerance duration - if ( abs(delta.x) > m_dragTolerance - || abs(delta.y) > m_dragTolerance + if ( abs(delta.x) > dragTolerance + || abs(delta.y) > dragTolerance || currentMouseClick - previousMouseClick > m_dragToleranceMS) { return FALSE; @@ -403,6 +406,14 @@ Bool Mouse::isClick(const ICoord2D *anchor, const ICoord2D *dest, UnsignedInt pr } +//------------------------------------------------------------------------------------------------- +/** Get the scroll speed factor adjusted drag tolerance */ +//------------------------------------------------------------------------------------------------- +Real Mouse::getDragToleranceAdjustedForScrollFactor() const +{ + return m_dragTolerance * (TheGlobalData->m_keyboardDefaultScrollFactor / TheGlobalData->m_keyboardScrollFactor); +} + /////////////////////////////////////////////////////////////////////////////////////////////////// // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////////////////////////