Skip to content

Drag events #47

Open
Open

Description

@waywardmonkeys

We'll need something for drag & drop. If it is as simple as what winit provides or not.

Activity

  1. xorgy commented on May 13, 2025

    @xorgy
    Collaborator

    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.

  2. xorgy commented on May 13, 2025

    @xorgy
    Collaborator

    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 ClipData from a DragEvent

  3. xorgy commented on May 13, 2025

    @xorgy
    Collaborator

    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.

  4. xorgy commented on May 14, 2025

    @xorgy
    Collaborator

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions