summaryrefslogtreecommitdiff
path: root/sc/source/ui/view/tabview.cxx
diff options
context:
space:
mode:
authorPatrick Luby <plubius@libreoffice.org>2023-12-25 09:19:48 -0500
committerPatrick Luby <plubius@libreoffice.org>2023-12-26 20:02:42 +0100
commit7af5df1d9fc472dc3a770fbff736eafa99d46bde (patch)
tree545bb7a7c6cd77ce0c59c7901eab107b42a0ff7f /sc/source/ui/view/tabview.cxx
parent0b194702002af52d1e0034d41e497052675eb84a (diff)
tdf#135478 Reduce sensitivity of horizontal scrollwheel
Problem: at least on macOS, swipe events are very precise. So, when swiping at a slight angle off of vertical, swipe events will include a small amount of horizontal movement. Since horizontal swipe units are measured in cell widths, these small amounts of horizontal movement results in shifting many columns to the right or left while swiping almost vertically. So my hacky fix is to reduce the amount of horizontal swipe events to roughly match the "visual distance" of vertical swipe events. The reduction factor is arbitrary but is set to roughly the ratio of default cell width divided by default cell height. This hacky fix isn't a perfect fix, but hopefully it reduces the amount of unexpected horizontal shifting while swiping vertically to a tolerable amount for most users. Note: the potential downside of doing this is that some users might find horizontal swiping to be slower than they are used to. If that becomes an issue for enough users, the reduction factor may need to be lowered to find a good balance point. Lastly, fix the unbalanced rounding of delta X and Y values due to using floor() for macOS native swipe and scroll wheel events. Change-Id: I8c0c9a3aa688e411c47ebb5e7500f3a50f6f673b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161278 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Patrick Luby <plubius@libreoffice.org>
Diffstat (limited to 'sc/source/ui/view/tabview.cxx')
-rw-r--r--sc/source/ui/view/tabview.cxx46
1 files changed, 46 insertions, 0 deletions
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index fd9e88d18f31..9eff50195e84 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -1217,6 +1217,52 @@ void ScTabView::ScrollHdl(ScrollAdaptor* pScroll)
else
nDelta = 0;
}
+ else if ( bHoriz )
+ {
+ // tdf#135478 Reduce sensitivity of horizontal scrollwheel
+ // Problem: at least on macOS, swipe events are very
+ // precise. So, when swiping at a slight angle off of
+ // vertical, swipe events will include a small amount
+ // of horizontal movement. Since horizontal swipe units
+ // are measured in cell widths, these small amounts of
+ // horizontal movement results in shifting many columns
+ // to the right or left while swiping almost vertically.
+ // So my hacky fix is to reduce the amount of horizontal
+ // swipe events to roughly match the "visual distance"
+ // of vertical swipe events.
+ // The reduction factor is arbitrary but is set to
+ // roughly the ratio of default cell width divided by
+ // default cell height. This hacky fix isn't a perfect
+ // fix, but hopefully it reduces the amount of
+ // unexpected horizontal shifting while swiping
+ // vertically to a tolerable amount for most users.
+ // Note: the potential downside of doing this is that
+ // some users might find horizontal swiping to be
+ // slower than they are used to. If that becomes an
+ // issue for enough users, the reduction factor may
+ // need to be lowered to find a good balance point.
+ static const sal_uInt16 nHScrollReductionFactor = 8;
+ if ( pScroll == aHScrollLeft.get() )
+ {
+ mnPendingaHScrollLeftDelta += nDelta;
+ nDelta = 0;
+ if ( abs(mnPendingaHScrollLeftDelta) > nHScrollReductionFactor )
+ {
+ nDelta = mnPendingaHScrollLeftDelta / nHScrollReductionFactor;
+ mnPendingaHScrollLeftDelta = mnPendingaHScrollLeftDelta % nHScrollReductionFactor;
+ }
+ }
+ else if ( pScroll == aHScrollRight.get() )
+ {
+ mnPendingaHScrollRightDelta += nDelta;
+ nDelta = 0;
+ if ( abs(mnPendingaHScrollRightDelta) > nHScrollReductionFactor )
+ {
+ nDelta = mnPendingaHScrollRightDelta / nHScrollReductionFactor;
+ mnPendingaHScrollRightDelta = mnPendingaHScrollRightDelta % nHScrollReductionFactor;
+ }
+ }
+ }
nPrevDragPos = nScrollPos;
}