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
This commit is contained in:
Vadim Zeitlin
2008-06-15 11:31:31 +00:00
parent 4b962ba1e0
commit 609577038a
4 changed files with 40 additions and 12 deletions

View File

@@ -3832,6 +3832,10 @@ protected:
bool m_lastKeyDownConsumed; 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 ScintillaWX;
friend class Platform; friend class Platform;
#endif // !SWIG #endif // !SWIG

View File

@@ -197,6 +197,7 @@ bool wxStyledTextCtrl::Create(wxWindow *parent,
m_swx = new ScintillaWX(this); m_swx = new ScintillaWX(this);
m_stopWatch.Start(); m_stopWatch.Start();
m_lastKeyDownConsumed = false; m_lastKeyDownConsumed = false;
m_lastWheelTimestamp = 0;
m_vScrollBar = NULL; m_vScrollBar = NULL;
m_hScrollBar = NULL; m_hScrollBar = NULL;
#if wxUSE_UNICODE #if wxUSE_UNICODE
@@ -3782,12 +3783,21 @@ void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
} }
void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) { 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(), m_swx->DoMouseWheel(evt.GetWheelRotation(),
evt.GetWheelDelta(), evt.GetWheelDelta(),
evt.GetLinesPerAction(), evt.GetLinesPerAction(),
evt.ControlDown(), evt.ControlDown(),
evt.IsPageScroll()); evt.IsPageScroll());
m_lastWheelTimestamp = m_stopWatch.Time() - m_lastWheelTimestamp;
m_lastWheelTimestamp += evt.GetTimestamp();
}
} }

View File

@@ -197,6 +197,7 @@ bool wxStyledTextCtrl::Create(wxWindow *parent,
m_swx = new ScintillaWX(this); m_swx = new ScintillaWX(this);
m_stopWatch.Start(); m_stopWatch.Start();
m_lastKeyDownConsumed = false; m_lastKeyDownConsumed = false;
m_lastWheelTimestamp = 0;
m_vScrollBar = NULL; m_vScrollBar = NULL;
m_hScrollBar = NULL; m_hScrollBar = NULL;
#if wxUSE_UNICODE #if wxUSE_UNICODE
@@ -785,12 +786,21 @@ void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
} }
void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) { 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(), m_swx->DoMouseWheel(evt.GetWheelRotation(),
evt.GetWheelDelta(), evt.GetWheelDelta(),
evt.GetLinesPerAction(), evt.GetLinesPerAction(),
evt.ControlDown(), evt.ControlDown(),
evt.IsPageScroll()); evt.IsPageScroll());
m_lastWheelTimestamp = m_stopWatch.Time() - m_lastWheelTimestamp;
m_lastWheelTimestamp += evt.GetTimestamp();
}
} }

View File

@@ -465,6 +465,10 @@ protected:
bool m_lastKeyDownConsumed; 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 ScintillaWX;
friend class Platform; friend class Platform;
#endif // !SWIG #endif // !SWIG