[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - vcl/source
Henry Castro (via logerrit)
logerrit at kemper.freedesktop.org
Thu Oct 7 09:45:41 UTC 2021
vcl/source/window/winproc.cxx | 57 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
New commits:
commit bd212a4f26ae4532bf2be3d1d35a60b67ac15ef5
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Tue Jul 6 10:12:41 2021 -0400
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Thu Oct 7 11:45:05 2021 +0200
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 at collabora.com>
Tested-by: Szymon Kłos <szymon.klos at collabora.com>
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)
{
More information about the Libreoffice-commits
mailing list