Skip to content

Incorrect drag & drop logic causes dropping to fail on the cosmic desktop #1953

@ideasman42

Description

@ideasman42

Dropping a JPEG onto Blender 5.0 fails with the cosmic desktop.
This looks to be caused by Blender calling wl_data_offer_accept on all mime types, even those which aren't supported by the offer.

Even though this can be resolved on Blender's side, there is nothing in the spec which requires accept only be called with supported mime types,
so as far as I can tell this is a bug in Smithay.


I think the accept logic should be changed so any acceptable mime type causes accept to be true, instead of the last mime type setting the "accepted" value.

e.g.

‎src/wayland/selection/data_device/mod.rs

        Request::Accept { mime_type, .. } => {
            if let Some(source) = source.as_ref() {
                if let Some(mtype) = mime_type {
                    // Only set accepted when the mime type matches what the
                    // source offers. Non-matching types are ignored so they
                    // do not override a previous valid match.
                    if !data.accepted
                        && source
                            .metadata()
                            .is_some_and(|meta| meta.mime_types.contains(&mtype))
                    {
                        data.accepted = true;
                    }
                } else {
                    data.accepted = false;
                }
            } else if data.finished {
                offer.post_error(
                    wl_data_offer::Error::InvalidFinish,
                    "Accept request after Finish.",
                );
            }
        }

With accepted: false, as the default in the enter handler.

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