[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - include/vcl sc/source vcl/inc vcl/source

Henry Castro (via logerrit) logerrit at kemper.freedesktop.org
Thu Oct 7 09:47:57 UTC 2021


 include/vcl/window.hxx        |    1 +
 sc/source/ui/view/select.cxx  |    3 +++
 vcl/inc/window.h              |    1 +
 vcl/source/window/mouse.cxx   |    5 +++++
 vcl/source/window/window.cxx  |    1 +
 vcl/source/window/winproc.cxx |   26 +++++++++++++++++---------
 6 files changed, 28 insertions(+), 9 deletions(-)

New commits:
commit de1e60f01f5806cc55088846aaaf3429aea754fb
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Wed Jun 30 18:45:38 2021 -0400
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Thu Oct 7 11:47:23 2021 +0200

    lok: sc: introduce LocalStartDrag method
    
    Update the mouse mode to start drag,
    otherwise it will conflict with normal cell selection.
    
    Change-Id: I6d4939b704114e7de1c9c051459fd02100a7536c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118874
    Tested-by: Szymon Kłos <szymon.klos at collabora.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 220df94e97f2..643e50a67550 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1075,6 +1075,7 @@ public:
     static VclPtr<vcl::Window>          SaveFocus();
     static void                         EndSaveFocus(const VclPtr<vcl::Window>& xFocusWin);
 
+    void                                LocalStartDrag();
     void                                CaptureMouse();
     void                                ReleaseMouse();
     bool                                IsMouseCaptured() const;
diff --git a/sc/source/ui/view/select.cxx b/sc/source/ui/view/select.cxx
index 89baed62a9f5..28d3133a0e49 100644
--- a/sc/source/ui/view/select.cxx
+++ b/sc/source/ui/view/select.cxx
@@ -204,6 +204,9 @@ void ScViewFunctionSet::BeginDrag()
     if ( pWindow->IsTracking() )
         pWindow->EndTracking( TrackingEventFlags::Cancel );    // abort selecting
 
+    if (comphelper::LibreOfficeKit::isActive())
+        pWindow->LocalStartDrag();
+
     SC_MOD()->SetDragObject( pTransferObj.get(), nullptr );      // for internal D&D
     pTransferObj->StartDrag( pWindow, nDragActions );
 
diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index e6acaa78dbbf..0b6fc72ad46b 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -180,6 +180,7 @@ struct ImplFrameData
     css::uno::Reference< css::datatransfer::clipboard::XClipboard > mxSelection;
 
     bool                mbInternalDragGestureRecognizer;
+    bool                mbDragging;
     VclPtr<VirtualDevice> mpBuffer; ///< Buffer for the double-buffering
     bool mbInBufferedPaint; ///< PaintHelper is in the process of painting into this buffer.
     tools::Rectangle maBufferedRect; ///< Rectangle in the buffer that has to be painted to the screen.
diff --git a/vcl/source/window/mouse.cxx b/vcl/source/window/mouse.cxx
index 6517ad2d90c1..9e2cd5045392 100644
--- a/vcl/source/window/mouse.cxx
+++ b/vcl/source/window/mouse.cxx
@@ -443,6 +443,11 @@ void Window::SetMouseTransparent( bool bTransparent )
     mpWindowImpl->mbMouseTransparent = bTransparent;
 }
 
+void Window::LocalStartDrag()
+{
+    ImplGetFrameData()->mbDragging = true;
+}
+
 void Window::CaptureMouse()
 {
     ImplSVData* pSVData = ImplGetSVData();
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index e2efee60dce8..da1b2005b255 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -811,6 +811,7 @@ ImplFrameData::ImplFrameData( vcl::Window *pWindow )
     maResizeIdle.SetInvokeHandler( LINK( pWindow, vcl::Window, ImplHandleResizeTimerHdl ) );
     maResizeIdle.SetDebugName( "vcl::Window maResizeIdle" );
     mbInternalDragGestureRecognizer = false;
+    mbDragging = false;
     mbInBufferedPaint = false;
     mnDPIX = 96;
     mnDPIY = 96;
diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx
index 6c8645dcf30a..48e016c47cde 100644
--- a/vcl/source/window/winproc.cxx
+++ b/vcl/source/window/winproc.cxx
@@ -819,21 +819,27 @@ bool ImplLOKHandleMouseEvent(const VclPtr<vcl::Window>& xWindow, MouseNotifyEven
     pFrameData->mbMouseIn = false;
 
     vcl::Window* pDragWin = pFrameData->mpMouseDownWin;
-    if (pDragWin && pFrameData->mbStartDragCalled &&
-        nSVEvent == MouseNotifyEvent::MOUSEMOVE)
+    if (pDragWin &&
+        nSVEvent == MouseNotifyEvent::MOUSEMOVE &&
+        pFrameData->mbDragging)
     {
         css::uno::Reference<css::datatransfer::dnd::XDropTargetDragContext> xDropTargetDragContext =
             new GenericDropTargetDragContext();
         css::uno::Reference<css::datatransfer::dnd::XDropTarget> xDropTarget(
             pDragWin->ImplGetWindowImpl()->mxDNDListenerContainer, css::uno::UNO_QUERY);
 
-        if (!xDropTargetDragContext.is() ||
-            !xDropTarget.is() ||
-            (nCode & (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE)) ==
+        if ((nCode & (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE)) !=
             (MouseSettings::GetStartDragCode() & (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE)))
+        {
+            pDragWin->ImplGetFrameData()->mbDragging = false;
+            return false;
+        }
+
+        if (!xDropTargetDragContext.is() ||
+            !xDropTarget.is())
         {
             // cancel dragdrop
-            pDragWin->ImplGetFrameData()->mbStartDragCalled = false;
+            pDragWin->ImplGetFrameData()->mbDragging = false;
             return false;
         }
 
@@ -849,8 +855,9 @@ bool ImplLOKHandleMouseEvent(const VclPtr<vcl::Window>& xWindow, MouseNotifyEven
         return true;
     }
 
-    if (pDragWin && pFrameData->mbStartDragCalled &&
-        nSVEvent == MouseNotifyEvent::MOUSEBUTTONUP)
+    if (pDragWin &&
+        nSVEvent == MouseNotifyEvent::MOUSEBUTTONUP &&
+        pFrameData->mbDragging)
     {
         css::uno::Reference<css::datatransfer::dnd::XDropTargetDropContext> xDropTargetDropContext =
             new GenericDropTargetDropContext();
@@ -870,7 +877,8 @@ bool ImplLOKHandleMouseEvent(const VclPtr<vcl::Window>& xWindow, MouseNotifyEven
                 css::uno::Reference<css::datatransfer::XTransferable>());
         }
 
-        pDragWin->ImplGetFrameData()->mbStartDragCalled = false;
+        pDragWin->ImplGetFrameData()->mbDragging = false;
+        return true;
     }
 
     vcl::Window* pDownWin = pFrameData->mpMouseDownWin;


More information about the Libreoffice-commits mailing list