TOOL_DISPATCHER: drag activation should always use screen coordinates

Fixes https://gitlab.com/kicad/code/kicad/-/issues/9325
This commit is contained in:
Mike Williams 2021-10-06 14:50:56 -04:00 committed by Seth Hillbrand
parent a8ec3b58ed
commit 27765cd584
2 changed files with 11 additions and 1 deletions

View File

@ -69,6 +69,9 @@ struct TOOL_DISPATCHER::BUTTON_STATE
///< Point where dragging has started (in world coordinates).
VECTOR2D dragOrigin;
///< Point where dragging has started (in screen coordinates).
VECTOR2D dragOriginScreen;
///< Point where click event has occurred.
VECTOR2D downPosition;
@ -192,7 +195,10 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
st->downTimestamp = wxGetLocalTimeMillis();
if( !st->pressed ) // save the drag origin on the first click only
{
st->dragOrigin = m_lastMousePos;
st->dragOriginScreen = m_lastMousePosScreen;
}
st->downPosition = m_lastMousePos;
st->pressed = true;
@ -225,7 +231,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
if( wxGetLocalTimeMillis() - st->downTimestamp > DragTimeThreshold )
st->dragging = true;
#endif
VECTOR2D offset = getView()->ToScreen( m_lastMousePos - st->dragOrigin, false );
VECTOR2D offset = m_lastMousePosScreen - st->dragOriginScreen;
if( abs( offset.x ) > m_sysDragMinX || abs( offset.y ) > m_sysDragMinY )
st->dragging = true;
@ -481,6 +487,7 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
if( m_toolMgr->GetViewControls() )
{
pos = m_toolMgr->GetViewControls()->GetMousePosition();
m_lastMousePosScreen = m_toolMgr->GetViewControls()->GetMousePosition( false );
if( pos != m_lastMousePos )
{

View File

@ -120,6 +120,9 @@ private:
///< The last mouse cursor position (in world coordinates).
VECTOR2D m_lastMousePos;
///< The last mouse cursor position (in screen coordinates).
VECTOR2D m_lastMousePosScreen;
///< State of mouse buttons.
std::vector<BUTTON_STATE*> m_buttons;