Fixing kinetic scrolling with thinkpad 'scrollwheel'

Since it generates lots of wheel events, it was re-triggering the bouncer
animation before it was completed. The result was a 'jittering' (d)effect.

I also increased the friction factor to make it scroll slower.


svn path=/trunk/KDE/kdelibs/; revision=1026404
This commit is contained in:
Adenilson Cavalcanti Da Silva 2009-09-21 18:38:53 +00:00
parent 543f6fa81c
commit da3ece21e8

View File

@ -158,7 +158,7 @@ void KineticScrolling::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
} else if (abs(d->cposition.y()) >
abs(d->scrollingWidget->size().height() - d->widget->size().height())) {
d->direction = KineticScrollingPrivate::Down;
} else {
} else {
d->direction = KineticScrollingPrivate::None;
d->mScrollVelocity = d->kinMovement.x() + d->kinMovement.y();
startAnimationTimer(30);
@ -173,17 +173,19 @@ void KineticScrolling::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void KineticScrolling::wheelReleaseEvent(QGraphicsSceneWheelEvent *event)
{
mousePressEvent(0);
if (d->direction == KineticScrollingPrivate::None) {
mousePressEvent(0);
/* Core */
d->timeDelta = d->elapsed();
int temp = event->delta();
temp *= -0.5;
d->kinMovement.setY(kinMovement().y() + temp);
/* Core */
d->timeDelta = d->elapsed();
int temp = event->delta();
temp *= -0.5;
d->kinMovement.setY(kinMovement().y() + temp);
/* After */
d->mScrollVelocity = kinMovement().y();
startAnimationTimer(30);
/* After */
d->mScrollVelocity = kinMovement().y();
startAnimationTimer(30);
}
}
@ -201,7 +203,7 @@ void KineticScrolling::timerEvent(QTimerEvent *event)
{
Q_UNUSED(event);
if (d->direction == KineticScrollingPrivate::None) {
d->mScrollVelocity *= 0.9;
d->mScrollVelocity *= 0.8;
if (qAbs(d->mScrollVelocity) < 5.0) {
if (d->timerID)
killTimer(d->timerID);
@ -212,7 +214,7 @@ void KineticScrolling::timerEvent(QTimerEvent *event)
if ((d->timerID != 0) && (d->direction != KineticScrollingPrivate::None)) {
bounceTimer();
}
}
}
}
void KineticScrolling::setKineticScrollValue(QPoint value)
@ -306,7 +308,7 @@ void KineticScrolling::setWidgets(QGraphicsWidget *widget,
if(d->widget->size().height() <= d->scrollingWidget->size().height()) {
d->hasOvershoot = false;
d->overshoot = 0;
d->overshoot = 0;
}
d->widget->installEventFilter(this);