From 89f9bf545d67b8a3f0f9cf13d598e60319a69071 Mon Sep 17 00:00:00 2001 From: John Beard Date: Wed, 8 May 2019 10:49:19 +0100 Subject: [PATCH] All: fix horizontal touchpad panning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit e10c01aaf didn't work when touchpad panning was enabled. This commit changes it to only discard horizontal wheel events when in "scroll mode" rather than "pan mode". Based on a patch by Adrian Scripcă . Follow-up to fix: lp:1828080 https://bugs.launchpad.net/kicad/+bug/1828080 (cherry picked from commit e6fe220f84b7b2047732cd41f0d8dc8f1a20537d) --- common/view/wx_view_controls.cpp | 38 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp index fc6dec6427..5cbd7ecd70 100644 --- a/common/view/wx_view_controls.cpp +++ b/common/view/wx_view_controls.cpp @@ -147,8 +147,6 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent ) void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent ) { - const double wheelPanSpeed = 0.001; - #ifdef __WXGTK3__ if( aEvent.GetTimestamp() == m_lastTimestamp ) { @@ -159,11 +157,8 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent ) m_lastTimestamp = aEvent.GetTimestamp(); #endif - // Fix issue caused by modern mice that feature horizontal scrolling by only handling - // vertical axis, otherwise horizontal scrolling events end up interpreted as vertical - // scroll events and confuse the user. - if( aEvent.GetWheelAxis() > 0 ) - return; + const double wheelPanSpeed = 0.001; + const int axis = aEvent.GetWheelAxis(); // mousewheelpan disabled: // wheel + ctrl -> horizontal scrolling; @@ -180,7 +175,6 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent ) // Scrolling VECTOR2D scrollVec = m_view->ToWorld( m_view->GetScreenPixelSize(), false ) * ( (double) aEvent.GetWheelRotation() * wheelPanSpeed ); - int axis = aEvent.GetWheelAxis(); double scrollX = 0.0; double scrollY = 0.0; @@ -206,18 +200,24 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent ) } else { - int rotation = aEvent.GetWheelRotation(); - double zoomScale = m_zoomController->GetScaleForRotation( rotation ); + // Restrict zoom handling to the vertical axis, otherwise horizontal + // scrolling events (e.g. touchpads and some mice) end up interpreted + // as vertical scroll events and confuse the user. + if( axis == wxMOUSE_WHEEL_VERTICAL ) + { + const int rotation = aEvent.GetWheelRotation(); + const double zoomScale = m_zoomController->GetScaleForRotation( rotation ); - if( IsCursorWarpingEnabled() ) - { - CenterOnCursor(); - m_view->SetScale( m_view->GetScale() * zoomScale ); - } - else - { - VECTOR2D anchor = m_view->ToWorld( VECTOR2D( aEvent.GetX(), aEvent.GetY() ) ); - m_view->SetScale( m_view->GetScale() * zoomScale, anchor ); + if( IsCursorWarpingEnabled() ) + { + CenterOnCursor(); + m_view->SetScale( m_view->GetScale() * zoomScale ); + } + else + { + const VECTOR2D anchor = m_view->ToWorld( VECTOR2D( aEvent.GetX(), aEvent.GetY() ) ); + m_view->SetScale( m_view->GetScale() * zoomScale, anchor ); + } } }