[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/plasma/widgets
From:       Marco Martin <notmart () gmail ! com>
Date:       2010-12-16 17:38:42
Message-ID: 20101216173842.32747AC8AA () svn ! kde ! org
[Download RAW message or body]

SVN commit 1207045 by mart:

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


 M  +8 -1      scrollwidget.cpp  


--- trunk/KDE/kdelibs/plasma/widgets/scrollwidget.cpp #1207044:1207045
@@ -133,6 +133,9 @@
         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 @@
 
     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 @@
         directMoveAnimation->setEndValue(end);
         directMoveAnimation->setDuration(200);
         directMoveAnimation->start();
+        wheelTimer->start(50);
     }
 
     qreal minXExtent() const
@@ -1059,6 +1065,7 @@
     QPointF dragHandleClicked;
     bool dragging;
     QTimer *adjustScrollbarsTimer;
+    QTimer *wheelTimer;
 
     QPointF pressPos;
     QPointF pressScrollPos;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic