sc/source/ui/view/tabview.cxx |   41 +++++++++++++++++++++--------------------
 1 file changed, 21 insertions(+), 20 deletions(-)

New commits:
commit 8bec0ff56c53e80be81a9f463fd1fd21ade33151
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Fri Apr 7 10:13:29 2023 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Fri Apr 7 12:36:36 2023 +0200

    tdf#154679 unable to scroll with mouse wheel with frozen rows
    
    which is a problem since:
    
    commit f2b97ecf340e1fd714c636060ae09382518a2b46
    Date:   Tue Mar 21 14:30:38 2023 +0000
    
        unmerge default and ScrollType::Drag cases for calc scrollbars
    
    which noted that in
    
    commit 8c4e8818fe9f5ac1f6cdf908299cc109d67f1e50
    Date:   Thu Aug 4 16:38:47 2022 +0100
    
        nDelta overwritten on all branches except default
    
    the default case was different to the Drag case
    
    and speculated that the right approach might be to restore
    that distinction.
    
    but in fact ScrollBar::DoScroll(tools::Long nNewPos)
    had an unconditional 'meScrollType = ScrollType::Drag' which
    ScrollAdaptor::DoScroll doesn't so it was originally the case
    that scroll wheels used to be reported to calc as "ScrollType::Drag"
    so the default handler never arose and such scrolls were handled
    by the drag handler after all, despite the unlikely looking scroll
    type.
    
    So restore the merge of ScrollType::Drag and default as the desired
    outcome, dropping the comment about "only for warnings" which is
    out of date now.
    
    Change-Id: Ibb396f053ae518a6ad5a9b4266ee879c84883953
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150120
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 69aef742b345..59b0154a446d 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -1170,7 +1170,7 @@ void ScTabView::ScrollHdl(ScrollAdaptor* pScroll)
             if ( pScroll == aVScrollBottom.get() ) nDelta = 
aViewData.VisibleCellsY( SC_SPLIT_BOTTOM );
             if (nDelta==0) nDelta=1;
             break;
-        case ScrollType::Drag:
+        default:
             {
                 // only scroll in the correct direction, do not jitter around 
hidden ranges
                 tools::Long nScrollMin = 0;        // simulate RangeMin
@@ -1181,30 +1181,31 @@ void ScTabView::ScrollHdl(ScrollAdaptor* pScroll)
 
                 tools::Long nScrollPos = GetScrollBarPos( *pScroll ) + 
nScrollMin;
                 nDelta = nScrollPos - nViewPos;
-                if ( nScrollPos > nPrevDragPos )
-                {
-                    if (nDelta<0) nDelta=0;
-                }
-                else if ( nScrollPos < nPrevDragPos )
+
+                // tdf#152406 Disable anti-jitter code for scroll wheel events
+                // After moving thousands of columns to the right via
+                // horizontal scroll wheel or trackpad swipe events, most
+                // vertical scroll wheel or trackpad swipe events will trigger
+                // the anti-jitter code because nScrollPos and nPrevDragPos
+                // will be equal and nDelta will be overriden and set to zero.
+                // So, only use the anti-jitter code for mouse drag events.
+                if ( eType == ScrollType::Drag )
                 {
-                    if (nDelta>0) nDelta=0;
+                    if ( nScrollPos > nPrevDragPos )
+                    {
+                        if (nDelta<0) nDelta=0;
+                    }
+                    else if ( nScrollPos < nPrevDragPos )
+                    {
+                        if (nDelta>0) nDelta=0;
+                    }
+                    else
+                        nDelta = 0;
                 }
-                else
-                    nDelta = 0;
+
                 nPrevDragPos = nScrollPos;
             }
             break;
-        default:
-            // Note tdf#152406 no anti-jitter code, unlike ScrollType::Drag,
-            // for scroll wheel events.
-            // After moving thousands of columns to the right via horizontal
-            // scroll wheel or trackpad swipe events, most vertical scroll
-            // wheel or trackpad swipe events would trigger the anti-jitter
-            // code because nScrollPos and nPrevDragPos would be equal and
-            // nDelta will be overridden and set to zero. So, only use the
-            // anti-jitter code for mouse drag events.
-            nDelta = GetScrollBarPos(*pScroll) - nViewPos;
-            break;
     }
 
     if (nDelta)

Reply via email to