summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArjan Molenaar <gaphor@gmail.com>2023-01-16 23:15:46 +0100
committerArjan Molenaar <gaphor@gmail.com>2023-01-16 23:21:35 +0100
commit628aeda7ee9f6cd3221c3293b636678db4c5e5a2 (patch)
treef630211a0feba6ab6c04318e590212eaac902229
parent2669dc269b8eb7914fb93221a74907df5cada508 (diff)
downloadgtk+-628aeda7ee9f6cd3221c3293b636678db4c5e5a2.tar.gz
macos: Provide the right drag action
We should use the drag action/operation provided by the drag handlers, not rely on our internal bookkeeping.
-rw-r--r--gdk/macos/GdkMacosWindow.c1
-rw-r--r--gdk/macos/gdkmacosdrag-private.h1
-rw-r--r--gdk/macos/gdkmacosdrag.c12
3 files changed, 14 insertions, 0 deletions
diff --git a/gdk/macos/GdkMacosWindow.c b/gdk/macos/GdkMacosWindow.c
index 1005d0c837..79a25c04d3 100644
--- a/gdk/macos/GdkMacosWindow.c
+++ b/gdk/macos/GdkMacosWindow.c
@@ -715,6 +715,7 @@ typedef NSString *CALayerContentsGravity;
GdkDrag *drag = _gdk_macos_display_find_drag (GDK_MACOS_DISPLAY (display), sequence_number);
_gdk_macos_event_source_queue_event ([NSApp currentEvent]);
+ gdk_drag_set_selected_action (drag, _gdk_macos_drag_ns_operation_to_action (operation));
if (gdk_drag_get_selected_action (drag) != 0)
g_signal_emit_by_name (drag, "drop-performed");
diff --git a/gdk/macos/gdkmacosdrag-private.h b/gdk/macos/gdkmacosdrag-private.h
index ab46828d5e..64db6ba770 100644
--- a/gdk/macos/gdkmacosdrag-private.h
+++ b/gdk/macos/gdkmacosdrag-private.h
@@ -66,6 +66,7 @@ gboolean _gdk_macos_drag_begin (GdkMacosDrag *self,
GdkContentProvider *content,
GdkMacosWindow *window);
NSDragOperation _gdk_macos_drag_operation (GdkMacosDrag *self);
+GdkDragAction _gdk_macos_drag_ns_operation_to_action (NSDragOperation operation);
void _gdk_macos_drag_surface_move (GdkMacosDrag *self,
int x_root,
int y_root);
diff --git a/gdk/macos/gdkmacosdrag.c b/gdk/macos/gdkmacosdrag.c
index b7549e5b9e..c0201df067 100644
--- a/gdk/macos/gdkmacosdrag.c
+++ b/gdk/macos/gdkmacosdrag.c
@@ -410,6 +410,18 @@ _gdk_macos_drag_operation (GdkMacosDrag *self)
return operation;
}
+GdkDragAction
+_gdk_macos_drag_ns_operation_to_action (NSDragOperation operation)
+{
+ if (operation & NSDragOperationCopy)
+ return GDK_ACTION_COPY;
+ if (operation & NSDragOperationMove)
+ return GDK_ACTION_MOVE;
+ if (operation & NSDragOperationLink)
+ return GDK_ACTION_LINK;
+ return 0;
+}
+
void
_gdk_macos_drag_surface_move (GdkMacosDrag *self,
int x_root,