summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorPatrick Luby <plubius@libreoffice.org>2023-12-25 09:19:48 -0500
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-01-05 15:48:41 +0100
commit24effe0edd9ae1ea9e4dd8e0bdabd5f25e1b9a68 (patch)
tree31b16cee11b8e1ed3cda629bde19b29c86fdc6d1 /sc
parentd6606237eef8adab7906140e2269bdc86825d4aa (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> (cherry picked from commit 689ddab27bb0658e43ab0e0d4d8235e45d8904d4) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161317 Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/inc/tabview.hxx2
-rw-r--r--sc/source/ui/view/tabview.cxx46
2 files changed, 48 insertions, 0 deletions
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index 23419f463923..66bbc010eae1 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -217,6 +217,8 @@ private:
double mfLastZoomScale = 0;
double mfAccumulatedZoom = 0;
+ tools::Long mnPendingaHScrollLeftDelta = 0;
+ tools::Long mnPendingaHScrollRightDelta = 0;
void Init();
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;
}