diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2021-06-23 08:18:08 -0400 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2022-02-18 16:11:42 +0100 |
commit | f0117eefa7d1b35e747546fd7d7a28126ebff0b7 (patch) | |
tree | b66ba3bf5818e4e397f3f25a49b97e3cee0c4a8a /vcl/source/window/winproc.cxx | |
parent | b8d6af27156faecb831c16afdc52dd630b641a9d (diff) |
lok: reset and cancel properly Drag & Drop action
used patch from Henry as a template:
https://gerrit.libreoffice.org/c/core/+/118844/17
but without custom actions invocation
Change-Id: I8bce66deffee0de16f3c24f009cfee077eb26e82
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123243
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129469
Tested-by: Jenkins
Reviewed-by: Henry Castro <hcastro@collabora.com>
Diffstat (limited to 'vcl/source/window/winproc.cxx')
-rw-r--r-- | vcl/source/window/winproc.cxx | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx index ebd1fa43c0a5..1e6d42ddcbff 100644 --- a/vcl/source/window/winproc.cxx +++ b/vcl/source/window/winproc.cxx @@ -840,18 +840,12 @@ bool ImplLOKHandleMouseEvent(const VclPtr<vcl::Window>& xWindow, MouseNotifyEven css::uno::Reference<css::datatransfer::dnd::XDropTarget> xDropTarget( pDragWin->ImplGetWindowImpl()->mxDNDListenerContainer, css::uno::UNO_QUERY); - if ((nCode & (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE)) != + if (!xDropTarget.is() || + !xDropTargetDragContext.is() || + (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()->mbDragging = false; + pFrameData->mbStartDragCalled = pFrameData->mbDragging = false; return false; } @@ -871,28 +865,40 @@ bool ImplLOKHandleMouseEvent(const VclPtr<vcl::Window>& xWindow, MouseNotifyEven nEvent == MouseNotifyEvent::MOUSEBUTTONUP && pFrameData->mbDragging) { + css::uno::Reference<css::datatransfer::XTransferable> xTransfer; css::uno::Reference<css::datatransfer::dnd::XDropTargetDropContext> xDropTargetDropContext = new GenericDropTargetDropContext(); css::uno::Reference<css::datatransfer::dnd::XDropTarget> xDropTarget( pDragWin->ImplGetWindowImpl()->mxDNDListenerContainer, css::uno::UNO_QUERY); - if (xDropTargetDropContext.is() && xDropTarget.is()) + if (!xDropTarget.is() || !xDropTargetDropContext.is()) { - static_cast<DNDListenerContainer *>(xDropTarget.get())->fireDropEvent( - xDropTargetDropContext, - css::datatransfer::dnd::DNDConstants::ACTION_MOVE, - aWinPos.X(), - aWinPos.Y(), - (css::datatransfer::dnd::DNDConstants::ACTION_COPY | - css::datatransfer::dnd::DNDConstants::ACTION_MOVE | - css::datatransfer::dnd::DNDConstants::ACTION_LINK), - css::uno::Reference<css::datatransfer::XTransferable>()); + pFrameData->mbStartDragCalled = pFrameData->mbDragging = false; + return false; } - pDragWin->ImplGetFrameData()->mbDragging = false; + Point dragOverPos = pDragWin->ImplFrameToOutput(aMousePos); + static_cast<DNDListenerContainer *>(xDropTarget.get())->fireDropEvent( + xDropTargetDropContext, + css::datatransfer::dnd::DNDConstants::ACTION_MOVE, + dragOverPos.X(), + dragOverPos.Y(), + (css::datatransfer::dnd::DNDConstants::ACTION_COPY | + css::datatransfer::dnd::DNDConstants::ACTION_MOVE | + css::datatransfer::dnd::DNDConstants::ACTION_LINK), + xTransfer); + + pFrameData->mbStartDragCalled = pFrameData->mbDragging = false; return true; } + if (pFrameData->mbDragging) + { + // wrong status, reset + pFrameData->mbStartDragCalled = pFrameData->mbDragging = false; + return false; + } + vcl::Window* pDownWin = pFrameData->mpMouseDownWin; if (pDownWin && nEvent == MouseNotifyEvent::MOUSEMOVE) { |