From 120c788ef0fbcee758cdaed52bd412c083c38696 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 20 Oct 2025 16:18:06 -0700 Subject: [PATCH] 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 --- common/view/wx_view_controls.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp index 705b01bbbd..ae282e4e3e 100644 --- a/common/view/wx_view_controls.cpp +++ b/common/view/wx_view_controls.cpp @@ -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 ) {