Fix scroll issue in media view on some logitech hi-res wheel mouse
This commit is contained in:
parent
3adbfb1fb5
commit
9409fb344f
|
@ -5186,27 +5186,43 @@ void OverlayWidget::handleKeyPress(not_null<QKeyEvent*> e) {
|
||||||
void OverlayWidget::handleWheelEvent(not_null<QWheelEvent*> e) {
|
void OverlayWidget::handleWheelEvent(not_null<QWheelEvent*> e) {
|
||||||
constexpr auto step = int(QWheelEvent::DefaultDeltasPerStep);
|
constexpr auto step = int(QWheelEvent::DefaultDeltasPerStep);
|
||||||
|
|
||||||
|
const auto _thisWheelDelta = e->angleDelta().y();
|
||||||
const auto acceptForJump = !_stories
|
const auto acceptForJump = !_stories
|
||||||
&& ((e->source() == Qt::MouseEventNotSynthesized)
|
&& ((e->source() == Qt::MouseEventNotSynthesized)
|
||||||
|| (e->source() == Qt::MouseEventSynthesizedBySystem));
|
|| (e->source() == Qt::MouseEventSynthesizedBySystem));
|
||||||
_verticalWheelDelta += e->angleDelta().y();
|
|
||||||
while (qAbs(_verticalWheelDelta) >= step) {
|
const bool directionChanges =
|
||||||
if (_verticalWheelDelta < 0) {
|
std::signbit(_lastWheelDelta) != std::signbit(_thisWheelDelta);
|
||||||
_verticalWheelDelta += step;
|
|
||||||
|
if ((qAbs(_thisWheelDelta) != step) && directionChanges) {
|
||||||
|
// linux: first scroll after direction changes on hi-res wheel in
|
||||||
|
// libinput is unreliable. offen lost first half of it's value,
|
||||||
|
// or even only remain one with 15 delta, so we just hardcode it
|
||||||
|
// to same as step here, other system should be fine too.
|
||||||
|
_absWheelDelta = _thisWheelDelta > 0 ? step : step * -1;
|
||||||
|
} else {
|
||||||
|
_absWheelDelta += _thisWheelDelta;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (qAbs(_absWheelDelta) >= step) {
|
||||||
|
if (_absWheelDelta < 0) {
|
||||||
|
// _absWheelDelta += step;
|
||||||
if (e->modifiers().testFlag(Qt::ControlModifier)) {
|
if (e->modifiers().testFlag(Qt::ControlModifier)) {
|
||||||
zoomOut();
|
zoomOut();
|
||||||
} else if (acceptForJump) {
|
} else if (acceptForJump) {
|
||||||
moveToNext(1);
|
moveToNext(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_verticalWheelDelta -= step;
|
// _absWheelDelta -= step;
|
||||||
if (e->modifiers().testFlag(Qt::ControlModifier)) {
|
if (e->modifiers().testFlag(Qt::ControlModifier)) {
|
||||||
zoomIn();
|
zoomIn();
|
||||||
} else if (acceptForJump) {
|
} else if (acceptForJump) {
|
||||||
moveToNext(-1);
|
moveToNext(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_absWheelDelta = 0; // reset to 0 to reduce pic move jump or skip.
|
||||||
}
|
}
|
||||||
|
_lastWheelDelta = _thisWheelDelta; // record last wheel delta
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverlayWidget::setZoomLevel(int newZoom, bool force) {
|
void OverlayWidget::setZoomLevel(int newZoom, bool force) {
|
||||||
|
|
|
@ -725,7 +725,8 @@ private:
|
||||||
rpl::event_stream<TouchBarItemType> _touchbarDisplay;
|
rpl::event_stream<TouchBarItemType> _touchbarDisplay;
|
||||||
rpl::event_stream<bool> _touchbarFullscreenToggled;
|
rpl::event_stream<bool> _touchbarFullscreenToggled;
|
||||||
|
|
||||||
int _verticalWheelDelta = 0;
|
int _absWheelDelta = 0;
|
||||||
|
int _lastWheelDelta = 0;
|
||||||
|
|
||||||
bool _themePreviewShown = false;
|
bool _themePreviewShown = false;
|
||||||
uint64 _themePreviewId = 0;
|
uint64 _themePreviewId = 0;
|
||||||
|
|
Loading…
Reference in New Issue