Skip to content

[feature] expose drag image size in DragDropEvent::Enter #1669

@vdavid

Description

@vdavid

Note: I'm happy to implement this and come back with a PR if y'all think it's a good addition!

Is your feature request related to a problem? Please describe.

I'm building a file manager on macOS with Tauri 2 + wry. When the user drags files to my app, I wanna show my cool dynamic in-app overlay (icons, target folder name, etc.). But I only want to do this when the source app's drag img is tiny/blank. When the source provides a rich preview (like Finder's), I need to hide mine to avoid the two clashing.

My problem is that DragDropEvent::Enter only gives me paths and position. There's no way to know anything about the incoming drag image, so I can't make that decision.

Describe the solution you'd like

Add an optional image_size: Option<(f64, f64)> (or similar) to DragDropEvent::Enter on macOS, populated from the union of NSDraggingItem.draggingFrame rects via enumerateDraggingItems. On other platforms it could just be None until there's a way to get it.

Describe alternatives you've considered

  • NSDraggingInfo.draggedImage(): Deprecated, returns nil for cross-process drags since macOS 10.12.
  • Method swizzling on WryWebView: I could swizzle draggingEntered: to intercept the NSDraggingInfo and read the frame size myself. This works but it feels fragile/meh.
  • Always show / always hide the overlay: Well, if I show it then the two overlays overlap and look like crap. If I hide mine, that solves it but then I can't show my cool custom content.

Additional context

I'm happy to implement this and come back with a PR! Wanted to check first if this sounds reasonable, and if you have preferences on the API shape. For example, whether it should be a separate struct, just a tuple, or a broader "drag source metadata" field for future extensibility.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions