macos: Provide the right drag action

We should use the drag action/operation provided by the
drag handlers, not rely on our internal bookkeeping.
This commit is contained in:
Arjan Molenaar
2023-01-16 23:15:46 +01:00
parent 2669dc269b
commit 628aeda7ee
3 changed files with 14 additions and 0 deletions

View File

@@ -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");

View File

@@ -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);

View File

@@ -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,