]> git.saurik.com Git - wxWidgets.git/commitdiff
ignore mouse wheel events which are coming too fast to be processed (#9057)
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 15 Jun 2008 11:31:31 +0000 (11:31 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 15 Jun 2008 11:31:31 +0000 (11:31 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54229 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/stc/stc.h
src/stc/stc.cpp
src/stc/stc.cpp.in
src/stc/stc.h.in

index 9ff6d84e1e5a3d37c6b369dca847073316b520be..9ff7bf718970fb03ccc329d02b3337f35ad71793 100644 (file)
@@ -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
index 84b9f6e36ba4412346c2b84d38348ade8d39a3ab..66f161d26fd42b1b581b12307d85543959d32dc7 100644 (file)
@@ -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();
+    }
 }
 
 
index 637f4c09bdbcd0e8fb7866e140a641ae4c30c50d..9ce33cd2a6ce0c52988f7e050758ed323e98d4eb 100644 (file)
@@ -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();
+    }
 }
 
 
index 003706e370d431958aa002b0c1c8c6e7ffba351b..e7fe5a6d79677e171dc9457857adec3bbefa5194 100644 (file)
@@ -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