Kaydet (Commit) ce0a9591 authored tarafından Caolán McNamara's avatar Caolán McNamara Kaydeden (comit) Andras Timar

Resolves: tdf#118302 drag n drop to same tab should cancel dnd

dropComplete is used to do this, follow the mac pattern here to
propogate this in the drag and drop from self to self case.

Maybe this also affects tdf#105320 ?

Change-Id: I2b8f8b0e0486f6ee45a65918fae2537750a75f2d
Reviewed-on: https://gerrit.libreoffice.org/57591
Tested-by: Jenkins
Reviewed-by: 's avatarXisco Faulí <xiscofauli@libreoffice.org>
(cherry picked from commit e6e9bae8)
üst 05780aea
...@@ -3373,6 +3373,9 @@ namespace ...@@ -3373,6 +3373,9 @@ namespace
} }
} }
static bool g_DropSuccessSet = false;
static bool g_DropSuccess = false;
class GtkDropTargetDropContext : public cppu::WeakImplHelper<css::datatransfer::dnd::XDropTargetDropContext> class GtkDropTargetDropContext : public cppu::WeakImplHelper<css::datatransfer::dnd::XDropTargetDropContext>
{ {
GdkDragContext *m_pContext; GdkDragContext *m_pContext;
...@@ -3398,6 +3401,11 @@ public: ...@@ -3398,6 +3401,11 @@ public:
virtual void SAL_CALL dropComplete(sal_Bool bSuccess) override virtual void SAL_CALL dropComplete(sal_Bool bSuccess) override
{ {
gtk_drag_finish(m_pContext, bSuccess, false, m_nTime); gtk_drag_finish(m_pContext, bSuccess, false, m_nTime);
if (GtkDragSource::g_ActiveDragSource)
{
g_DropSuccessSet = true;
g_DropSuccess = bSuccess;
}
} }
}; };
...@@ -4297,9 +4305,12 @@ void GtkDragSource::startDrag(const datatransfer::dnd::DragGestureEvent& rEvent, ...@@ -4297,9 +4305,12 @@ void GtkDragSource::startDrag(const datatransfer::dnd::DragGestureEvent& rEvent,
// For LibreOffice internal D&D we provide the Transferable without Gtk // For LibreOffice internal D&D we provide the Transferable without Gtk
// intermediaries as a shortcut, see tdf#100097 for how dbaccess depends on this // intermediaries as a shortcut, see tdf#100097 for how dbaccess depends on this
g_ActiveDragSource = this; g_ActiveDragSource = this;
g_DropSuccessSet = false;
g_DropSuccess = false;
m_pFrame->startDrag(nDragButton, rEvent.DragOriginX, rEvent.DragOriginY, m_pFrame->startDrag(nDragButton, rEvent.DragOriginX, rEvent.DragOriginY,
VclToGdk(sourceActions), pTargetList); VclToGdk(sourceActions), pTargetList);
gtk_target_list_unref(pTargetList); gtk_target_list_unref(pTargetList);
for (auto &a : aGtkTargets) for (auto &a : aGtkTargets)
g_free(a.target); g_free(a.target);
...@@ -4394,7 +4405,12 @@ void GtkDragSource::dragEnd(GdkDragContext* context) ...@@ -4394,7 +4405,12 @@ void GtkDragSource::dragEnd(GdkDragContext* context)
{ {
datatransfer::dnd::DragSourceDropEvent aEv; datatransfer::dnd::DragSourceDropEvent aEv;
aEv.DropAction = GdkToVcl(gdk_drag_context_get_selected_action(context)); aEv.DropAction = GdkToVcl(gdk_drag_context_get_selected_action(context));
aEv.DropSuccess = true; // an internal drop can accept the drop but fail with dropComplete( false )
// this is different than the GTK API
if (g_DropSuccessSet)
aEv.DropSuccess = g_DropSuccess;
else
aEv.DropSuccess = true;
auto xListener = m_xListener; auto xListener = m_xListener;
m_xListener.clear(); m_xListener.clear();
xListener->dragDropEnd(aEv); xListener->dragDropEnd(aEv);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment