gtk3: prevent double scroll events

GTK3 smooth scrolling is enabled by wxWidgets but not to the exclusion
of normal scroll up/down events.  wxWidgets maps these both to the same
scroll handler and will fire them both if they are not handled before
being queued.  Testing timestamps allows us to mark and ignore the
dupes.

This is set to GTK3 only for now as it isn't listed as a problem for
other platforms.  But it shouldn't cause issues if it is enabled
elsewhere in the future.
This commit is contained in:
Seth Hillbrand 2018-12-05 19:23:32 -07:00
parent ed506dd05e
commit 1f62a2d784
2 changed files with 14 additions and 1 deletions

View File

@ -52,7 +52,7 @@ static std::unique_ptr<ZOOM_CONTROLLER> GetZoomControllerForPlatform()
WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxScrolledCanvas* aParentPanel ) :
VIEW_CONTROLS( aView ), m_state( IDLE ), m_parentPanel( aParentPanel ),
m_scrollScale( 1.0, 1.0 ), m_cursorPos( 0, 0 ), m_updateCursor( true )
m_scrollScale( 1.0, 1.0 ), m_lastTimestamp( 0 ), m_cursorPos( 0, 0 ), m_updateCursor( true )
{
m_parentPanel->Connect( wxEVT_MOTION,
wxMouseEventHandler( WX_VIEW_CONTROLS::onMotion ), NULL, this );
@ -133,6 +133,16 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent )
{
const double wheelPanSpeed = 0.001;
#ifdef __WXGTK3__
if( aEvent.GetTimestamp() == m_lastTimestamp )
{
aEvent.Skip( false );
return;
}
m_lastTimestamp = aEvent.GetTimestamp();
#endif
// mousewheelpan disabled:
// wheel + ctrl -> horizontal scrolling;
// wheel + shift -> vertical scrolling;

View File

@ -159,6 +159,9 @@ private:
/// Current scrollbar position
VECTOR2I m_scrollPos;
/// Last event timestamp to remove duplicates
long int m_lastTimestamp;
/// Current cursor position (world coordinates)
VECTOR2D m_cursorPos;