Bug 91950

Summary: Consider whether wl_data_offer::accept should really require a MIME type
Product: Wayland Reporter: Michael Catanzaro <mcatanzaro>
Component: waylandAssignee: Wayland bug list <wayland-bugs>
Status: RESOLVED MOVED QA Contact:
Severity: minor    
Priority: medium CC: mcatanzaro
Version: 1.5.0   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Bug Depends on:    
Bug Blocks: 91948    

Description Michael Catanzaro 2015-09-09 21:10:25 UTC
I have a Wayland client that would like to send wl_data_offer::accept requests when acting as the drag destination, to indicate if drag data would be accepted for the current location of the pointer. However, my client is unable to guarantee which MIME type it will eventually choose to receive data for. It therefore picks the first MIME type it could ever possibly use, and passes that MIME type to wl_data_offer::accept, even if it will eventually decide not to use that MIME type. This enhances the user experience during a DnD session by encouraging the drag source to display a cursor image that indicates the drag will be accepted, but some clients might choose a non-ideal drag image based on the potentially-misleading MIME type my client has accepted.

It would be nice if there was a way to indicate that some MIME type would be accepted for the current pointer location, without committing to any particular MIME type. Passing NULL for the mime_type parameter would be ideal for this, except that is a reject message.
Comment 1 Pekka Paalanen 2015-09-10 06:49:21 UTC
Could you explain more on how your client does not know what mime type it is going to select when it has already decided that it can accept the drop?

What changes the preferred mime type between hover and drop?
Comment 2 Michael Catanzaro 2015-09-10 15:11:07 UTC
(In reply to Pekka Paalanen from comment #1)
> Could you explain more on how your client does not know what mime type it is
> going to select when it has already decided that it can accept the drop?
> 
> What changes the preferred mime type between hover and drop?

The client is Chromium. The interface between the Wayland backend code and Chromium's cross-platform DnD abstraction is DragDropDelegate [1] which contains one function that looks like this:

virtual int OnDragUpdated(const ui::DropTargetEvent& event) = 0;

The DropTargetEvent passes all of the drag data (already received from the drag source) to Chromium, and the return value indicates to the platform backend whether Chromium has chosen to accept the drag. But it doesn't indicate what type of data that Chromium will choose to use, only that it will some of the data (and also which DnD action it will pick, bug #91949).

We could change this, but it would not be easy, and would reduce the chances of upstreaming the code. It's more desirable to simply guess which MIME type to use when calling wl_data_offer::accept, which will be right more often than not, and almost always harmless (I've yet to discover a client that changes the drag image based on the MIME type indicated in the accept messages). That's non-ideal, though.

[1] https://code.google.com/p/chromium/codesearch#chromium/src/ui/wm/public/drag_drop_delegate.h
Comment 3 GitLab Migration User 2018-06-08 23:50:12 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/wayland/wayland/issues/42.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.