summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-11-16 10:16:29 +0000
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-11-23 11:35:26 +0000
commitcefb442114814cc4801cd227633853a9bf103ce2 (patch)
tree072b14666a9d9465ac7fff05d9466ced6072d492
parent37ded4ac7b1fe91bb08eaada29d3514570432073 (diff)
gtk3: problems with gdk_drag_status under wayland
under wayland, the value selected by gdk_drag_status is not immediately available via gdk_drag_context_get_selected_action, so use the value we set on it, not the value it claims to have pull common code together as getPreferredDragAction Change-Id: I4d95c4b8183505f2203ad1a8f6947df983ce8d21 (cherry picked from commit 09972f971e13ff967c9897d50ba5fbf0f862e8a4) Reviewed-on: https://gerrit.libreoffice.org/30899 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--vcl/unx/gtk3/gtk3gtkframe.cxx51
1 files changed, 28 insertions, 23 deletions
diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx
index d74f7b87d3e5..b7287825c315 100644
--- a/vcl/unx/gtk3/gtk3gtkframe.cxx
+++ b/vcl/unx/gtk3/gtk3gtkframe.cxx
@@ -3230,6 +3230,23 @@ namespace
}
}
+namespace
+{
+ static GdkDragAction getPreferredDragAction(sal_Int8 dragOperation)
+ {
+ GdkDragAction eAct(static_cast<GdkDragAction>(0));
+
+ if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_MOVE)
+ eAct = GDK_ACTION_MOVE;
+ else if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_COPY)
+ eAct = GDK_ACTION_COPY;
+ else if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_LINK)
+ eAct = GDK_ACTION_LINK;
+
+ return eAct;
+ }
+}
+
class GtkDropTargetDropContext : public cppu::WeakImplHelper<css::datatransfer::dnd::XDropTargetDropContext>
{
GdkDragContext *m_pContext;
@@ -3244,16 +3261,7 @@ public:
// XDropTargetDropContext
virtual void SAL_CALL acceptDrop(sal_Int8 dragOperation) throw(std::exception) override
{
- GdkDragAction eAct(static_cast<GdkDragAction>(0));
-
- if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_MOVE)
- eAct = GDK_ACTION_MOVE;
- else if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_COPY)
- eAct = GDK_ACTION_COPY;
- else if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_LINK)
- eAct = GDK_ACTION_LINK;
-
- gdk_drag_status(m_pContext, eAct, m_nTime);
+ gdk_drag_status(m_pContext, getPreferredDragAction(dragOperation), m_nTime);
}
virtual void SAL_CALL rejectDrop() throw(std::exception) override
@@ -3406,16 +3414,7 @@ public:
virtual void SAL_CALL acceptDrag(sal_Int8 dragOperation) throw(std::exception) override
{
- GdkDragAction eAct(static_cast<GdkDragAction>(0));
-
- if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_MOVE)
- eAct = GDK_ACTION_MOVE;
- else if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_COPY)
- eAct = GDK_ACTION_COPY;
- else if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_LINK)
- eAct = GDK_ACTION_LINK;
-
- gdk_drag_status(m_pContext, eAct, m_nTime);
+ gdk_drag_status(m_pContext, getPreferredDragAction(dragOperation), m_nTime);
}
virtual void SAL_CALL rejectDrag() throw(std::exception) override
@@ -3457,12 +3456,18 @@ gboolean GtkSalFrame::signalDragMotion(GtkWidget *pWidget, GdkDragContext *conte
//preliminary accept the Drag and select the preferred action, the fire_* will
//inform the original caller of our choice and the callsite can decide
//to overrule this choice. i.e. typically here we default to ACTION_MOVE
- pContext->acceptDrag(GdkToVcl(gdk_drag_context_get_actions(context)));
+ sal_Int8 nSourceActions = GdkToVcl(gdk_drag_context_get_actions(context));
+ GdkDragAction eAction = getPreferredDragAction(nSourceActions);
+ gdk_drag_status(context, eAction, time);
aEvent.Context = pContext;
aEvent.LocationX = x;
aEvent.LocationY = y;
- aEvent.DropAction = GdkToVcl(gdk_drag_context_get_selected_action(context));
- aEvent.SourceActions = GdkToVcl(gdk_drag_context_get_actions(context));
+ //under wayland at least, the action selected by gdk_drag_status on the
+ //context is not immediately available via gdk_drag_context_get_selected_action
+ //so here we set the DropAction from what we selected on the context, not
+ //what the context says is selected
+ aEvent.DropAction = GdkToVcl(eAction);
+ aEvent.SourceActions = nSourceActions;
if (!pThis->m_bInDrag)
{