summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2021-07-06 10:12:41 -0400
committerSzymon Kłos <szymon.klos@collabora.com>2021-10-07 11:45:05 +0200
commitbd212a4f26ae4532bf2be3d1d35a60b67ac15ef5 (patch)
tree90c48b2177d734b082424755ff214ad2eb490106
parent428f5755442c9e36f2e0cc53c5780dcad8749910 (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>
-rw-r--r--vcl/source/window/winproc.cxx57
1 files changed, 57 insertions, 0 deletions
diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx
index 625c09c818c5..6c8645dcf30a 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>
@@ -54,6 +55,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>
@@ -816,6 +818,61 @@ bool ImplLOKHandleMouseEvent(const VclPtr<vcl::Window>& xWindow, MouseNotifyEven
pFrameData->mnMouseCode = nCode;
pFrameData->mbMouseIn = false;
+ vcl::Window* pDragWin = pFrameData->mpMouseDownWin;
+ if (pDragWin && pFrameData->mbStartDragCalled &&
+ nSVEvent == 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 &&
+ nSVEvent == 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)
{