vcl/source/window/winproc.cxx | 57 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+)
New commits: commit 0bf0feb40ae5c394a14cdfe4f94fb98dd9053597 Author: Henry Castro <hcas...@collabora.com> AuthorDate: Tue Jul 6 10:12:41 2021 -0400 Commit: Henry Castro <hcas...@collabora.com> CommitDate: Fri Feb 11 21:02:04 2022 +0100 lok: add drag & drop functionality In the desktop case, the drag over and drag drop events are handled external like GTK framework. In tiled rendering case, we do not have it, so handle the drag and drop events in the cloned ImplLOKHandleMouseEvent function. Change-Id: Ib41232b3b9d5d6d859b2c965311b87af5d193ddd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118869 Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Tested-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117896 Tested-by: Jenkins Reviewed-by: Henry Castro <hcas...@collabora.com> diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx index be2e4f5ca4c5..83f45b640ea6 100644 --- a/vcl/source/window/winproc.cxx +++ b/vcl/source/window/winproc.cxx @@ -26,6 +26,7 @@ #include <unotools/localedatawrapper.hxx> +#include <dndeventdispatcher.hxx> #include <comphelper/lok.hxx> #include <vcl/QueueInfo.hxx> #include <vcl/timer.hxx> @@ -55,6 +56,7 @@ #include <brdwin.hxx> #include <dndlistenercontainer.hxx> +#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp> #include <com/sun/star/datatransfer/dnd/XDragSource.hpp> #include <com/sun/star/awt/MouseEvent.hpp> @@ -828,6 +830,61 @@ bool ImplLOKHandleMouseEvent(const VclPtr<vcl::Window>& xWindow, MouseNotifyEven pFrameData->mnMouseCode = nCode; pFrameData->mbMouseIn = false; + vcl::Window* pDragWin = pFrameData->mpMouseDownWin; + if (pDragWin && pFrameData->mbStartDragCalled && + nEvent == MouseNotifyEvent::MOUSEMOVE) + { + 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)) == + (MouseSettings::GetStartDragCode() & (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE))) + { + // cancel dragdrop + pDragWin->ImplGetFrameData()->mbStartDragCalled = false; + return false; + } + + static_cast<DNDListenerContainer *>(xDropTarget.get())->fireDragOverEvent( + xDropTargetDragContext, + 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)); + + return true; + } + + if (pDragWin && pFrameData->mbStartDragCalled && + nEvent == MouseNotifyEvent::MOUSEBUTTONUP) + { + 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()) + { + 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>()); + } + + pDragWin->ImplGetFrameData()->mbStartDragCalled = false; + } + vcl::Window* pDownWin = pFrameData->mpMouseDownWin; if (pDownWin && nEvent == MouseNotifyEvent::MOUSEMOVE) {