From 7f6b35c6bc079af44b0c64b5ee7d53e2ea958015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabi=C3=A1n=20Inostroza?= Date: Tue, 8 Jan 2019 16:47:00 -0300 Subject: [PATCH] Don't start autopan if the cursor was warped The application warps the cursor when initiating some actions (dragging, selecting modules or Find and Move). This warping should not also trigger the autopan action. Fixes: lp:1810787 * https://bugs.launchpad.net/kicad/+bug/1810787 --- common/view/wx_view_controls.cpp | 23 ++++++++++++++++++----- include/view/view_controls.h | 3 +++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp index 4935f7fc9f..42487fcd70 100644 --- a/common/view/wx_view_controls.cpp +++ b/common/view/wx_view_controls.cpp @@ -101,6 +101,8 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxScrolledCanvas* aParentPanel m_zoomController = GetZoomControllerForPlatform(); + m_cursorWarped = false; + m_panTimer.SetOwner( this ); this->Connect( wxEVT_TIMER, wxTimerEventHandler( WX_VIEW_CONTROLS::onTimer ), NULL, this ); @@ -453,16 +455,23 @@ VECTOR2D WX_VIEW_CONTROLS::GetCursorPosition( bool aEnableSnapping ) const } -void WX_VIEW_CONTROLS::SetCursorPosition( const VECTOR2D& aPosition, bool aWarpView, bool aTriggeredByArrows ) +void WX_VIEW_CONTROLS::SetCursorPosition( const VECTOR2D& aPosition, bool aWarpView, + bool aTriggeredByArrows ) { m_updateCursor = false; + if( aTriggeredByArrows ) { m_settings.m_lastKeyboardCursorPositionValid = true; m_settings.m_lastKeyboardCursorPosition = aPosition; - } else { - m_settings.m_lastKeyboardCursorPositionValid = false; + m_cursorWarped = false; } + else + { + m_settings.m_lastKeyboardCursorPositionValid = false; + m_cursorWarped = true; + } + WarpCursor( aPosition, true, aWarpView ); m_cursorPos = aPosition; } @@ -532,15 +541,19 @@ bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent ) VECTOR2I p( aEvent.GetX(), aEvent.GetY() ); VECTOR2I pKey( m_view->ToScreen(m_settings.m_lastKeyboardCursorPosition ) ); - if( m_settings.m_lastKeyboardCursorPositionValid && (p == pKey) ) + if( m_cursorWarped || (m_settings.m_lastKeyboardCursorPositionValid && (p == pKey)) ) { // last cursor move event came from keyboard cursor control. If auto-panning is enabled and // the next position is inside the autopan zone, check if it really came from a mouse event, otherwise - // disable autopan temporarily. + // disable autopan temporarily. Also temporaly disable autopan if the cursor is in the autopan zone + // because the application warped the cursor. + m_cursorWarped = false; return true; } + m_cursorWarped = false; + // Compute areas where autopanning is active int borderStart = std::min( m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().x, m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().y ); diff --git a/include/view/view_controls.h b/include/view/view_controls.h index 4ac038e924..6fe840a713 100644 --- a/include/view/view_controls.h +++ b/include/view/view_controls.h @@ -377,6 +377,9 @@ protected: ///> Pointer to controlled VIEW. VIEW* m_view; + ///> Application warped the cursor, not the user (keyboard) + bool m_cursorWarped; + ///> Current VIEW_CONTROLS settings VC_SETTINGS m_settings; };