Commit e971c67c authored by Kezi Olio's avatar Kezi Olio Committed by Nate Graham

Make selection scrolling go at 60 fps

When you select a square with the right mouse button, and you go past the margin of the window (but where there is still space to go), okular scrolls the document so you can select more.
With this patch this automatic scrolling goes at 60 fps instead of 10, I made it so that the speed of the scroll is the same

Reviewers: #okular, aacid, sander, ngraham

Reviewed By: sander, ngraham

Subscribers: sander, ngraham, aacid, ahmedbilal, okular-devel, kezik

Tags: #okular

Differential Revision:
parent 59a86c3f
......@@ -3754,17 +3754,20 @@ void PageView::selectionStart( const QPoint & pos, const QColor & color, bool /*
void PageView::scrollPosIntoView( const QPoint & pos )
if (pos.x() < horizontalScrollBar()->value()) d->dragScrollVector.setX(pos.x() - horizontalScrollBar()->value());
else if (horizontalScrollBar()->value() + viewport()->width() < pos.x()) d->dragScrollVector.setX(pos.x() - horizontalScrollBar()->value() - viewport()->width());
// this number slows the speed of the page by its value, chosen not to be too fast or too slow, the actual speed is determined from the mouse position, not critical
const int damping=6;
if (pos.x() < horizontalScrollBar()->value()) d->dragScrollVector.setX((pos.x() - horizontalScrollBar()->value())/damping);
else if (horizontalScrollBar()->value() + viewport()->width() < pos.x()) d->dragScrollVector.setX((pos.x() - horizontalScrollBar()->value() - viewport()->width())/damping);
else d->dragScrollVector.setX(0);
if (pos.y() < verticalScrollBar()->value()) d->dragScrollVector.setY(pos.y() - verticalScrollBar()->value());
else if (verticalScrollBar()->value() + viewport()->height() < pos.y()) d->dragScrollVector.setY(pos.y() - verticalScrollBar()->value() - viewport()->height());
if (pos.y() < verticalScrollBar()->value()) d->dragScrollVector.setY((pos.y() - verticalScrollBar()->value())/damping);
else if (verticalScrollBar()->value() + viewport()->height() < pos.y()) d->dragScrollVector.setY((pos.y() - verticalScrollBar()->value() - viewport()->height())/damping);
else d->dragScrollVector.setY(0);
if (d->dragScrollVector != QPoint(0, 0))
if (!d->dragScrollTimer.isActive()) d->dragScrollTimer.start(100);
if (!d->dragScrollTimer.isActive()) d->dragScrollTimer.start(1000/60); //60 fps
else d->dragScrollTimer.stop();
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment