Ref #598: Option to set default drag-drop behaviour to local folder as 'move' not...
authorColin Clark <cclark@carbon>
Mon, 3 Feb 2020 14:45:17 +0000 (14:45 +0000)
committerColin Clark <cclark@carbon>
Mon, 3 Feb 2020 14:45:17 +0000 (14:45 +0000)
https://github.com/BestImageViewer/geeqie/issues/598

With GTK2 shift+drag moved the target, control+drag copied the target,
and no modifier key caused a pop-up menu to appear.
With GTK3 the modifier keys are not recognized correctly.
This patch reinstates the previous functionality.

src/view_dir.c

index 09dee16..7c2d192 100644 (file)
@@ -795,6 +795,8 @@ static void vd_dnd_drop_receive(GtkWidget *widget,
        ViewDir *vd = data;
        GtkTreePath *tpath;
        FileData *fd = NULL;
+       GdkDragAction action;
+       GdkModifierType mask;
 
        vd->click_fd = NULL;
 
@@ -822,13 +824,30 @@ static void vd_dnd_drop_receive(GtkWidget *widget,
 
                if (active)
                        {
-                       if (gdk_drag_context_get_actions(context) == GDK_ACTION_COPY)
+/* FIXME: With GTK2 gdk_drag_context_get_actions() shows the state of the
+ * shift and control keys during the drag operation. With GTK3 this is not
+ * so. This is a workaround.
+ */
+#if GTK_CHECK_VERSION(3,0,0)
+                       gdk_window_get_pointer(gtk_widget_get_window(widget), NULL, NULL, &mask);
+                       if (mask & GDK_CONTROL_MASK)
+                               {
+                               action = GDK_ACTION_COPY;
+                               }
+                       else if (mask & GDK_SHIFT_MASK)
+                               {
+                               action = GDK_ACTION_MOVE;
+                               }
+#else
+                       action = (gdk_drag_context_get_actions(context));
+#endif
+                       if (action == GDK_ACTION_COPY)
                                {
                                file_util_copy_simple(list, fd->path, vd->widget);
                                done = TRUE;
                                list = NULL;
                                }
-                       else if (gdk_drag_context_get_actions(context) == GDK_ACTION_MOVE)
+                       else if (action == GDK_ACTION_MOVE)
                                {
                                file_util_move_simple(list, fd->path, vd->widget);
                                done = TRUE;