From: Colin Clark Date: Mon, 3 Feb 2020 14:45:17 +0000 (+0000) Subject: Ref #598: Option to set default drag-drop behaviour to local folder as 'move' not... X-Git-Tag: v1.6~91 X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=3bb1d2231c07028039ad7d2589371881e4e9ef66 Ref #598: Option to set default drag-drop behaviour to local folder as 'move' not 'copy' 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. --- diff --git a/src/view_dir.c b/src/view_dir.c index 09dee160..7c2d192c 100644 --- a/src/view_dir.c +++ b/src/view_dir.c @@ -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;