3.12. Data sharing between client (selection and drag and drop)
The Wayland 1.0 protocol provides its clients a mechanism for sharing data that allows the implementation of selection and drag and drop. The client providing the data creates a wl_data_source object and the clients obtaining the data will see it as wl_data_offer object. This interface allows the clients to agree on a mutually supported mime type and transfer the data through an fd that is passed through the protocol.
The next section explains the negotiation between data source and data offer objects.
Section 3.12.2, “Data devices” explains how these objects are created and passed to different client using the wl_data_device interface, that implements selection and drag and drop support.
A client providing data to other clients will create a wl_data_source object and advertise the mime types for the formats it supports for that data through the wl_data_source.offer request. On the receiving end, the data offer object will generate one wl_data_offer.offer event for each supported mime type.
The actual data transfer happens when the receiving client sends a wl_data_offer.receive request. This request takes a mime type and an fd as arguments. This request will generate a wl_data_source.send event on the sending client with the same arguments, and the latter client is expected to write its data to the given fd using the chosen mime type.