diff --git a/src/view/kateviewinternal.h b/src/view/kateviewinternal.h --- a/src/view/kateviewinternal.h +++ b/src/view/kateviewinternal.h @@ -319,6 +319,7 @@ // line scrollbar + first visible (virtual) line in the current view // KateScrollBar *m_lineScroll; + qreal m_accumulatedScroll = 0.0; QWidget *m_dummy; // These are now cursors to account for word-wrap. diff --git a/src/view/kateviewinternal.cpp b/src/view/kateviewinternal.cpp --- a/src/view/kateviewinternal.cpp +++ b/src/view/kateviewinternal.cpp @@ -3377,11 +3377,24 @@ // handle vertical scrolling via the scrollbar if (e->orientation() == Qt::Vertical) { - QWheelEvent copy = *e; - QApplication::sendEvent(m_lineScroll, ©); - if (copy.isAccepted()) { - e->accept(); + // compute distance + auto sign = m_lineScroll->invertedControls() ? -1 : 1; + auto offset = sign * qreal(e->angleDelta().y()) / 120.0; + if ( e->modifiers() & Qt::ShiftModifier ) { + const auto pageStep = m_lineScroll->pageStep(); + offset = qBound(-pageStep, int(offset * pageStep), pageStep); + } else { + offset *= QApplication::wheelScrollLines(); } + + // handle accumulation + m_accumulatedScroll += offset - int(offset); + const auto extraAccumulated = int(m_accumulatedScroll); + m_accumulatedScroll -= extraAccumulated; + + // do scroll + scrollViewLines(int(offset) + extraAccumulated); + e->accept(); } // handle horizontal scrolling via the scrollbar