You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's probably worth surveying different platforms and how they implement this. Winit only supports file drag and drop, and only into the window (not out of it), and only supports this by file paths. My understanding is that some platforms provide file handles, some provide MIME types or similar, etc.
It seems to me that MIME is a decent implementation/interface tool which should be helpful even on platforms which do not directly use well-formed MIME types.
On X11 it's through XDnD, which uses MIME types advertised on the window, and generally communicates files as URIs or lists of URIs (typed text/uri-list), and XDnD like Android communicates the position of the drag separately from the primary pointer position.
On Wayland, it is possibly similar, where the wl_data_device has a motion event which is similar to pointer motion events, and the device has a MIME negotiation protocol similar to XDnD, and the dragging target is per-surface.
On macOS it is NSDraggingDestination, and types are communicated with UTI (Uniform Type Identifier) or sometimes malformed and need to be implied from extensions, common types should be mappable with MIME and some will include direct mappings to MIME types via UTTagClass but we would probably have to provide an extension point to introduce more types. It's not clear to me how one gets position information during a drag on macOS, may simply be a matter of primary pointer position (which is masked out during file drag in winit stable).
On iPadOS it is done through the UIDragInteraction/UIDragInteractionDelegate the content types are similar to those on macOS (UTI, sometimes malformed), and drag-specific position information is given during the drag (with didMoveToLocation).
On Windows it is IDropTarget and RegisterDragDrop, and sometimes , I believe the platform continues to deliver primary pointer positions during a drag, but similarly winit (stable) masks these out during a drag. Windows offers a MIME types during a drag, but these may not be well formed or present in all cases.
Some of these interfaces include ‘marker tags’ on types that indicate that the content is meant to be obscured from display/confidential (such as passwords), it is unclear to me whether there is a standard for this with MIME, and what sorts of compatibility issues may arise from use of any given choice of MIME translation for these.
I believe the plan with winit main is to provide position information, but I'm not sure how complete the implementation is on the various platforms so far.
Activity
xorgy commentedon May 13, 2025
It's probably worth surveying different platforms and how they implement this. Winit only supports file drag and drop, and only into the window (not out of it), and only supports this by file paths. My understanding is that some platforms provide file handles, some provide MIME types or similar, etc.
xorgy commentedon May 13, 2025
Here's a quick summary of how this works on Android, from Grok:
https://grok.com/share/bGVnYWN5_8e51cf8f-e25b-4b58-a874-92d849865a95
Which basically comes down to accessing
ClipDatafrom aDragEventxorgy commentedon May 13, 2025
It seems to me that MIME is a decent implementation/interface tool which should be helpful even on platforms which do not directly use well-formed MIME types.
xorgy commentedon May 14, 2025
On X11 it's through XDnD, which uses MIME types advertised on the window, and generally communicates files as URIs or lists of URIs (typed
text/uri-list), and XDnD like Android communicates the position of the drag separately from the primary pointer position.On Wayland, it is possibly similar, where the
wl_data_devicehas amotionevent which is similar to pointer motion events, and the device has a MIME negotiation protocol similar to XDnD, and the dragging target is per-surface.On macOS it is
NSDraggingDestination, and types are communicated with UTI (Uniform Type Identifier) or sometimes malformed and need to be implied from extensions, common types should be mappable with MIME and some will include direct mappings to MIME types viaUTTagClassbut we would probably have to provide an extension point to introduce more types. It's not clear to me how one gets position information during a drag on macOS, may simply be a matter of primary pointer position (which is masked out during file drag in winit stable).On iPadOS it is done through the
UIDragInteraction/UIDragInteractionDelegatethe content types are similar to those on macOS (UTI, sometimes malformed), and drag-specific position information is given during the drag (withdidMoveToLocation).On Windows it is
IDropTargetandRegisterDragDrop, and sometimes , I believe the platform continues to deliver primary pointer positions during a drag, but similarly winit (stable) masks these out during a drag. Windows offers a MIME types during a drag, but these may not be well formed or present in all cases.Some of these interfaces include ‘marker tags’ on types that indicate that the content is meant to be obscured from display/confidential (such as passwords), it is unclear to me whether there is a standard for this with MIME, and what sorts of compatibility issues may arise from use of any given choice of MIME translation for these.
I believe the plan with winit main is to provide position information, but I'm not sure how complete the implementation is on the various platforms so far.