From e2f5428044edc7f25884deb7ba8deee088e8f624 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 16 Dec 2010 17:38:41 +0000 Subject: [PATCH] limit the rate of wheel events to 50 msecs. this makes the scroll widget not getting mad with a touchpad scroll, that spits a ton of subsequent wheel events svn path=/trunk/KDE/kdelibs/; revision=1207045 --- widgets/scrollwidget.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/widgets/scrollwidget.cpp b/widgets/scrollwidget.cpp index 555740b44..4799c22d4 100644 --- a/widgets/scrollwidget.cpp +++ b/widgets/scrollwidget.cpp @@ -133,6 +133,9 @@ public: adjustScrollbarsTimer->setSingleShot(true); QObject::connect(adjustScrollbarsTimer, SIGNAL(timeout()), q, SLOT(adjustScrollbars())); + wheelTimer = new QTimer(q); + wheelTimer->setSingleShot(true); + verticalScrollBarPolicy = Qt::ScrollBarAsNeeded; verticalScrollBar = new Plasma::ScrollBar(q); verticalScrollBar->setFocusPolicy(Qt::NoFocus); @@ -791,8 +794,10 @@ public: void handleWheelEvent(QGraphicsSceneWheelEvent *event) { - if (!widget.data()) + //only scroll when the animation is done, this avoids to receive too many events and getting mad when they arrive from a touchpad + if (!widget.data() || wheelTimer->isActive()) { return; + } QPointF start = q->scrollPosition(); QPointF end = start; @@ -835,6 +840,7 @@ public: directMoveAnimation->setEndValue(end); directMoveAnimation->setDuration(200); directMoveAnimation->start(); + wheelTimer->start(50); } qreal minXExtent() const @@ -1059,6 +1065,7 @@ public: QPointF dragHandleClicked; bool dragging; QTimer *adjustScrollbarsTimer; + QTimer *wheelTimer; QPointF pressPos; QPointF pressScrollPos;