Compare commits

...

2 Commits

Author SHA1 Message Date
detiam 7236ecc034
Merge 9409fb344f into 2c4d8418c1 2024-04-26 10:59:32 +03:00
detiam 9409fb344f
Fix scroll issue in media view on some logitech hi-res wheel mouse 2023-12-21 13:54:13 +08:00
2 changed files with 23 additions and 6 deletions

View File

@ -5190,27 +5190,43 @@ void OverlayWidget::handleKeyPress(not_null<QKeyEvent*> e) {
void OverlayWidget::handleWheelEvent(not_null<QWheelEvent*> e) {
constexpr auto step = int(QWheelEvent::DefaultDeltasPerStep);
const auto _thisWheelDelta = e->angleDelta().y();
const auto acceptForJump = !_stories
&& ((e->source() == Qt::MouseEventNotSynthesized)
|| (e->source() == Qt::MouseEventSynthesizedBySystem));
_verticalWheelDelta += e->angleDelta().y();
while (qAbs(_verticalWheelDelta) >= step) {
if (_verticalWheelDelta < 0) {
_verticalWheelDelta += step;
const bool directionChanges =
std::signbit(_lastWheelDelta) != std::signbit(_thisWheelDelta);
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)) {
zoomOut();
} else if (acceptForJump) {
moveToNext(1);
}
} else {
_verticalWheelDelta -= step;
// _absWheelDelta -= step;
if (e->modifiers().testFlag(Qt::ControlModifier)) {
zoomIn();
} else if (acceptForJump) {
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) {

View File

@ -725,7 +725,8 @@ private:
rpl::event_stream<TouchBarItemType> _touchbarDisplay;
rpl::event_stream<bool> _touchbarFullscreenToggled;
int _verticalWheelDelta = 0;
int _absWheelDelta = 0;
int _lastWheelDelta = 0;
bool _themePreviewShown = false;
uint64 _themePreviewId = 0;