diff options
author | Henry Castro <hcastro@collabora.com> | 2021-07-06 10:12:41 -0400 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2022-02-11 21:02:04 +0100 |
commit | 0bf0feb40ae5c394a14cdfe4f94fb98dd9053597 (patch) | |
tree | 66cbeeb9ec529f9e7bd12295d8cd2de3edc2e65f /vcl | |
parent | 2483cd198b51bd5d0819cbebf40f211b2ef1236d (diff) |
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.klos@collabora.com>
Tested-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117896
Tested-by: Jenkins
Reviewed-by: Henry Castro <hcastro@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/window/winproc.cxx | 57 |
1 files changed, 57 insertions, 0 deletions
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) { |