[nautilus/wip/corey/dnd-hack: 2/2] dnd: Temporary fix for getting the preferred action on an x11 drop
- From: Corey Berla <coreyberla src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/corey/dnd-hack: 2/2] dnd: Temporary fix for getting the preferred action on an x11 drop
- Date: Wed, 31 Aug 2022 03:38:09 +0000 (UTC)
commit 594333ee71dc5726e21f6001bc354b84bd4437c6
Author: Corey Berla <corey berla me>
Date: Tue Aug 30 20:35:42 2022 -0700
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
src/gtk/nautilusgtkplacessidebar.c | 16 ++++++++++++++++
src/nautilus-list-base.c | 26 ++++++++++++++++++++++++++
src/nautilus-window-slot-dnd.c | 17 +++++++++++++++++
3 files changed, 59 insertions(+)
---
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 855cbeb5d..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;
@@ -277,6 +281,19 @@ slot_proxy_handle_drop (GtkDropTarget *target,
uri_list = g_list_prepend (uri_list, g_file_get_uri (l->data));
}
+ 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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]