Clear the keyboard movement flag on mouse move

We detect mouse movement by checking if the screen position is not the
keyboard position and if not, we clear the
m_lastKeyboardCursorPositionValid that is used for detemining keyboard
movement in snaps

Fixes https://gitlab.com/kicad/code/kicad/-/issues/21981
This commit is contained in:
Seth Hillbrand
2025-10-20 16:33:39 -07:00
parent acdf53dc36
commit 120c788ef0
+16
View File
@@ -222,6 +222,22 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent )
int y = mouseRel.y;
VECTOR2D mousePos( x, y );
// Clear keyboard cursor position flag when actual mouse motion is detected
// (i.e., not from cursor warping and position has changed)
if( !m_cursorWarped && m_settings.m_lastKeyboardCursorPositionValid )
{
VECTOR2I screenPos( x, y );
VECTOR2I keyboardScreenPos = m_view->ToScreen( m_settings.m_lastKeyboardCursorPosition );
// If mouse has moved to a different position than the keyboard cursor position,
// clear the keyboard position flag to allow mouse control
if( screenPos != keyboardScreenPos )
{
m_settings.m_lastKeyboardCursorPositionValid = false;
m_settings.m_lastKeyboardCursorPosition = { 0.0, 0.0 };
}
}
// Automatic focus switching between SCH and PCB windows on canvas mouse motion
if( m_settings.m_focusFollowSchPcb )
{