sc/source/ui/view/gridwin.cxx |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit 7eb8a1d6c5697fd89ff75d3b116bbbf6c2de6950
Author:     Dennis Francis <dennis.fran...@collabora.com>
AuthorDate: Wed Aug 11 16:40:34 2021 +0530
Commit:     Dennis Francis <dennis.fran...@collabora.com>
CommitDate: Fri Aug 13 10:34:58 2021 +0200

    sc: lok: avoid selection jumps with multiple users
    
    In LOK case, avoid spurious "leavingwindow" mouse move events which has
    negative coordinates. We later use these coordinates to compute the cell
    address corresponding to the event to extend the selection which will be
    wrong in this case. Such spurious events occur for some reason when a
    user is selecting a range, (even when not leaving the view area) with
    one or more other viewers in that sheet. The root cause of these bad
    coordinates seems to be in vcl
    
    in winproc.cxx, ImplHandleMouseEvent() in the code block starting
    ```
    // test for mouseleave and mouseenter
    VclPtr<vcl::Window> pMouseMoveWin = pWinFrameData->mpMouseMoveWin;
    if ( pChild != pMouseMoveWin )
    {
        if ( pMouseMoveWin )
        {
            Point aLeaveMousePos = pMouseMoveWin->ImplFrameToOutput( aMousePos 
);
    ```
    
    This needs more investigation. Meanwhile this interim patch fixes the
    issue of selection jump by avoiding those unhelpful mouse events.
    
    Change-Id: I01fb3ae6a3903ada2a44a8b3d2b4a46b0122326b
    Signed-off-by: Dennis Francis <dennis.fran...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120317
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Mert Tumer <mert.tu...@collabora.com>

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 650ab56cf520..c2d20951a217 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -2612,8 +2612,14 @@ void ScGridWindow::MouseMove( const MouseEvent& rMEvt )
         }
     }
 
-    if ( pViewData->GetView()->GetSelEngine()->SelMouseMove( rMEvt ) )
-        return;
+    // In LOK case, avoid spurious "leavingwindow" mouse move events which has 
negative coordinates.
+    // Such events occur for some reason when a user is selecting a range, 
(even when not leaving the view area)
+    // with one or more other viewers in that sheet.
+    bool bSkipSelectionUpdate = comphelper::LibreOfficeKit::isActive() &&
+        rMEvt.IsLeaveWindow() && (aCurMousePos.X() < 0 || aCurMousePos.Y() < 
0);
+
+    if (!bSkipSelectionUpdate)
+        pViewData->GetView()->GetSelEngine()->SelMouseMove( rMEvt );
 }
 
 static void lcl_InitMouseEvent(css::awt::MouseEvent& rEvent, const MouseEvent& 
rEvt)

Reply via email to