Skip to content

macos: DnD Drag support

Arjan Molenaar requested to merge amolenaar/gtk:macos-native-dnd into main

This MR implements drag support for macOS.

Dragging is provided via NSView beginDraggingSessionWithItems:event:source:. This is the modern way to start a drag operation. However, it looks like this is starting a nested Cocoa run loop. Hence the hack in 908c28c5 to run the GLib handlers when loop level > 1. I think that this loop is the reason the zoom back animation is not working.

As a starting point I used @chergert's commits to separate the pasteboard logic.

The pasteboard uses the URL type as fallback, in case only non-serializable GType types have been provided.

I'm not sure if the right GdkDrag and GdkDrop callbacks have been implemented. GdkDrag event handling has been removed, since this is done now via GdkMacosWindow. There's still a commit where the dragging code is in a separate class, not sure what's better.

I removed the drag-seat logic. It did not seem to add any functionality. But I may be wrong.

Notes:

  • Starting a drag operation initiates a nested run loop (modal). CFRunLoopEntry is invoked twice and the GLib main loop is stuck on the poll_function until the drag operation is done.
  • GTK requires the events anyway, to keep the state of the drag source gesture up to date. This is done in the handlers called during the drag operation.

Fixes #3423 (closed).

Edited by Arjan Molenaar

Merge request reports