From 609577038acc7087a349d06aaf328e0b81a05f22 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 15 Jun 2008 11:31:31 +0000 Subject: [PATCH] ignore mouse wheel events which are coming too fast to be processed (#9057) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54229 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/stc/stc.h | 4 ++++ src/stc/stc.cpp | 22 ++++++++++++++++------ src/stc/stc.cpp.in | 22 ++++++++++++++++------ src/stc/stc.h.in | 4 ++++ 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index 9ff6d84e1e..9ff7bf7189 100644 --- a/include/wx/stc/stc.h +++ b/include/wx/stc/stc.h @@ -3832,6 +3832,10 @@ protected: bool m_lastKeyDownConsumed; + // the timestamp that consists of the last wheel event + // added to the time taken to process that event. + long m_lastWheelTimestamp; + friend class ScintillaWX; friend class Platform; #endif // !SWIG diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 84b9f6e36b..66f161d26f 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -197,6 +197,7 @@ bool wxStyledTextCtrl::Create(wxWindow *parent, m_swx = new ScintillaWX(this); m_stopWatch.Start(); m_lastKeyDownConsumed = false; + m_lastWheelTimestamp = 0; m_vScrollBar = NULL; m_hScrollBar = NULL; #if wxUSE_UNICODE @@ -3782,12 +3783,21 @@ void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) { } -void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) { - m_swx->DoMouseWheel(evt.GetWheelRotation(), - evt.GetWheelDelta(), - evt.GetLinesPerAction(), - evt.ControlDown(), - evt.IsPageScroll()); +void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) +{ + // prevent having an event queue with wheel events that cannot be processed + // reasonably fast (see ticket #9057) + if ( m_lastWheelTimestamp <= evt.GetTimestamp() ) + { + m_lastWheelTimestamp = m_stopWatch.Time(); + m_swx->DoMouseWheel(evt.GetWheelRotation(), + evt.GetWheelDelta(), + evt.GetLinesPerAction(), + evt.ControlDown(), + evt.IsPageScroll()); + m_lastWheelTimestamp = m_stopWatch.Time() - m_lastWheelTimestamp; + m_lastWheelTimestamp += evt.GetTimestamp(); + } } diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index 637f4c09bd..9ce33cd2a6 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -197,6 +197,7 @@ bool wxStyledTextCtrl::Create(wxWindow *parent, m_swx = new ScintillaWX(this); m_stopWatch.Start(); m_lastKeyDownConsumed = false; + m_lastWheelTimestamp = 0; m_vScrollBar = NULL; m_hScrollBar = NULL; #if wxUSE_UNICODE @@ -785,12 +786,21 @@ void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) { } -void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) { - m_swx->DoMouseWheel(evt.GetWheelRotation(), - evt.GetWheelDelta(), - evt.GetLinesPerAction(), - evt.ControlDown(), - evt.IsPageScroll()); +void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) +{ + // prevent having an event queue with wheel events that cannot be processed + // reasonably fast (see ticket #9057) + if ( m_lastWheelTimestamp <= evt.GetTimestamp() ) + { + m_lastWheelTimestamp = m_stopWatch.Time(); + m_swx->DoMouseWheel(evt.GetWheelRotation(), + evt.GetWheelDelta(), + evt.GetLinesPerAction(), + evt.ControlDown(), + evt.IsPageScroll()); + m_lastWheelTimestamp = m_stopWatch.Time() - m_lastWheelTimestamp; + m_lastWheelTimestamp += evt.GetTimestamp(); + } } diff --git a/src/stc/stc.h.in b/src/stc/stc.h.in index 003706e370..e7fe5a6d79 100644 --- a/src/stc/stc.h.in +++ b/src/stc/stc.h.in @@ -465,6 +465,10 @@ protected: bool m_lastKeyDownConsumed; + // the timestamp that consists of the last wheel event + // added to the time taken to process that event. + long m_lastWheelTimestamp; + friend class ScintillaWX; friend class Platform; #endif // !SWIG -- 2.45.2