summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorey Berla <corey@berla.me>2022-08-30 20:35:42 -0700
committerAntónio Fernandes <antoniof@gnome.org>2022-08-31 22:16:17 +0000
commit4fcfe1338998c78b6f3e2a4477975b7b8226f9ba (patch)
treee686d7f0819a98abe483c0a91e68345697451879
parentf328288dc2e8ba7f1e801a10175d090aef33f2e9 (diff)
downloadnautilus-4fcfe1338998c78b6f3e2a4477975b7b8226f9ba.tar.gz
dnd: Temporary fix for getting the preferred action on an x11 drop
In x11 the GtkDropTarget is not correctly setting the preferred action on the GdkDrop. The GdkDrag is getting set correctly, so for the meantime, until a solution is merged into Gtk, let's get the action from the GdkDrag instead of the GdkDrop. See: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4982 Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2457
-rw-r--r--src/gtk/nautilusgtkplacessidebar.c16
-rw-r--r--src/nautilus-list-base.c26
-rw-r--r--src/nautilus-window-slot-dnd.c15
3 files changed, 57 insertions, 0 deletions
diff --git a/src/gtk/nautilusgtkplacessidebar.c b/src/gtk/nautilusgtkplacessidebar.c
index 76fb98627..792afea53 100644
--- a/src/gtk/nautilusgtkplacessidebar.c
+++ b/src/gtk/nautilusgtkplacessidebar.c
@@ -40,6 +40,11 @@
#include "nautilus-global-preferences.h"
#include "nautilus-properties-window.h"
#include "nautilus-trash-monitor.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/x11/gdkx.h>
+#endif
+
#pragma GCC diagnostic ignored "-Wshadow"
/*< private >
@@ -1882,6 +1887,17 @@ drag_drop_callback (GtkDropTarget *target,
GdkDragAction actions;
actions = gdk_drop_get_actions (gtk_drop_target_get_current_drop (target));
+
+ #ifdef GDK_WINDOWING_X11
+ if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (sidebar))))
+ {
+ /* Temporary workaround until the below GTK MR (or equivalend fix)
+ * is merged. Without this fix, the preferred action isn't set correctly.
+ * https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4982 */
+ GdkDrag *drag = gdk_drop_get_drag (gtk_drop_target_get_current_drop (target));
+ actions = gdk_drag_get_selected_action (drag);
+ }
+ #endif
emit_drag_perform_drop (sidebar,
dest_file,
diff --git a/src/nautilus-list-base.c b/src/nautilus-list-base.c
index 568070d1b..ab72c6fc0 100644
--- a/src/nautilus-list-base.c
+++ b/src/nautilus-list-base.c
@@ -19,6 +19,10 @@
#include "nautilus-global-preferences.h"
#include "nautilus-thumbnails.h"
+#ifdef GDK_WINDOWING_X11
+#include <gdk/x11/gdkx.h>
+#endif
+
/**
* NautilusListBase:
*
@@ -804,6 +808,17 @@ on_item_drop (GtkDropTarget *target,
actions = gdk_drop_get_actions (gtk_drop_target_get_current_drop (target));
target_location = nautilus_file_get_location (nautilus_view_item_get_file (item));
+ #ifdef GDK_WINDOWING_X11
+ if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (self))))
+ {
+ /* Temporary workaround until the below GTK MR (or equivalend fix)
+ * is merged. Without this fix, the preferred action isn't set correctly.
+ * https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4982 */
+ GdkDrag *drag = gdk_drop_get_drag (gtk_drop_target_get_current_drop (target));
+ actions = gdk_drag_get_selected_action (drag);
+ }
+ #endif
+
real_perform_drop (self, value, actions, target_location);
return TRUE;
@@ -888,6 +903,17 @@ on_view_drop (GtkDropTarget *target,
actions = gdk_drop_get_actions (gtk_drop_target_get_current_drop (target));
target_location = nautilus_view_get_location (NAUTILUS_VIEW (self));
+ #ifdef GDK_WINDOWING_X11
+ if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (self))))
+ {
+ /* Temporary workaround until the below GTK MR (or equivalend fix)
+ * is merged. Without this fix, the preferred action isn't set correctly.
+ * https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4982 */
+ GdkDrag *drag = gdk_drop_get_drag (gtk_drop_target_get_current_drop (target));
+ actions = gdk_drag_get_selected_action (drag);
+ }
+ #endif
+
real_perform_drop (self, value, actions, target_location);
return TRUE;
diff --git a/src/nautilus-window-slot-dnd.c b/src/nautilus-window-slot-dnd.c
index 5d7267d38..b05af1acc 100644
--- a/src/nautilus-window-slot-dnd.c
+++ b/src/nautilus-window-slot-dnd.c
@@ -29,6 +29,10 @@
#include "nautilus-files-view-dnd.h"
#include "nautilus-window-slot-dnd.h"
+#ifdef GDK_WINDOWING_X11
+#include <gdk/x11/gdkx.h>
+#endif
+
typedef struct
{
NautilusFile *target_file;
@@ -279,6 +283,17 @@ slot_proxy_handle_drop (GtkDropTarget *target,
actions = gdk_drop_get_actions (gtk_drop_target_get_current_drop (target));
+ #ifdef GDK_WINDOWING_X11
+ if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (window))))
+ {
+ /* Temporary workaround until the below GTK MR (or equivalend fix)
+ * is merged. Without this fix, the preferred action isn't set correctly.
+ * https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4982 */
+ GdkDrag *drag = gdk_drop_get_drag (gtk_drop_target_get_current_drop (target));
+ actions = gdk_drag_get_selected_action (drag);
+ }
+ #endif
+
nautilus_files_view_drop_proxy_received_uris (target_view,
uri_list,
target_uri,