summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/source/ui/inc/tabview.hxx2
-rw-r--r--sc/source/ui/view/tabview.cxx46
-rw-r--r--vcl/osx/salframeview.mm8
3 files changed, 52 insertions, 4 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;
}
diff --git a/vcl/osx/salframeview.mm b/vcl/osx/salframeview.mm
index c0b23f80a7d6..995eeb574999 100644
--- a/vcl/osx/salframeview.mm
+++ b/vcl/osx/salframeview.mm
@@ -1095,7 +1095,7 @@ static void updateWinDataInLiveResize(bool bInLiveResize)
if( dX != 0.0 )
{
- aEvent.mnDelta = static_cast<tools::Long>(floor(dX));
+ aEvent.mnDelta = static_cast<tools::Long>(dX < 0 ? floor(dX) : ceil(dX));
aEvent.mnNotchDelta = (dX < 0) ? -1 : +1;
if( aEvent.mnDelta == 0 )
aEvent.mnDelta = aEvent.mnNotchDelta;
@@ -1105,7 +1105,7 @@ static void updateWinDataInLiveResize(bool bInLiveResize)
}
if( dY != 0.0 && AquaSalFrame::isAlive( mpFrame ))
{
- aEvent.mnDelta = static_cast<tools::Long>(floor(dY));
+ aEvent.mnDelta = static_cast<tools::Long>(dY < 0 ? floor(dY) : ceil(dY));
aEvent.mnNotchDelta = (dY < 0) ? -1 : +1;
if( aEvent.mnDelta == 0 )
aEvent.mnDelta = aEvent.mnNotchDelta;
@@ -1154,7 +1154,7 @@ static void updateWinDataInLiveResize(bool bInLiveResize)
if( dX != 0.0 )
{
- aEvent.mnDelta = static_cast<tools::Long>(floor(dX));
+ aEvent.mnDelta = static_cast<tools::Long>(dX < 0 ? floor(dX) : ceil(dX));
aEvent.mnNotchDelta = (dX < 0) ? -1 : +1;
if( aEvent.mnDelta == 0 )
aEvent.mnDelta = aEvent.mnNotchDelta;
@@ -1168,7 +1168,7 @@ static void updateWinDataInLiveResize(bool bInLiveResize)
}
if( dY != 0.0 && AquaSalFrame::isAlive( mpFrame ) )
{
- aEvent.mnDelta = static_cast<tools::Long>(floor(dY));
+ aEvent.mnDelta = static_cast<tools::Long>(dY < 0 ? floor(dY) : ceil(dY));
aEvent.mnNotchDelta = (dY < 0) ? -1 : +1;
if( aEvent.mnDelta == 0 )
aEvent.mnDelta = aEvent.mnNotchDelta;