wl_data_source¤
wayland.wl_data_source ¤
Offer to transfer data
The wl_data_source object is the source side of a wl_data_offer. It is created by the source client in a data transfer and provides a way to describe the offered data and a way to respond to requests to transfer the data.
Methods:
-
offer
–Add an offered mime type
-
destroy
–Destroy the data source
-
set_actions
–Set the available drag-and-drop actions
-
on_target
–A target accepts an offered mime type.
-
on_send
–Send the data.
-
on_cancelled
–Selection was cancelled.
-
on_dnd_drop_performed
–The drag-and-drop operation physically finished.
-
on_dnd_finished
–The drag-and-drop operation concluded.
-
on_action
–Notify the selected action.
error ¤
-
invalid_action_mask
–Action mask contains invalid values -
invalid_source
–Source doesn't accept this request
events
target ¤
send ¤
cancelled ¤
cancelled() -> None
Selection was cancelled
This data source is no longer valid. There are several reasons why this could happen:
- The data source has been replaced by another data source.
- The drag-and-drop operation was performed, but the drop destination did not accept any of the mime types offered through wl_data_source.target.
- The drag-and-drop operation was performed, but the drop destination did not select any of the actions present in the mask offered through wl_data_source.action.
- The drag-and-drop operation was performed but didn't happen over a surface.
- The compositor cancelled the drag-and-drop operation (e.g. compositor dependent timeouts to avoid stale drag-and-drop transfers).
The client should clean up and destroy this data source.
For objects of version 2 or older, wl_data_source.cancelled will only be emitted if the data source was replaced by another data source.
dnd_drop_performed ¤
dnd_drop_performed() -> None
The drag-and-drop operation physically finished
The user performed the drop action. This event does not indicate acceptance, wl_data_source.cancelled may still be emitted afterwards if the drop destination does not accept any mime type.
However, this event might however not be received if the compositor cancelled the drag-and-drop operation before this event could happen.
Note that the data_source may still be used in the future and should not be destroyed here.
dnd_finished ¤
dnd_finished() -> None
The drag-and-drop operation concluded
The drop destination finished interoperating with this data source, so the client is now free to destroy this data source and free all associated data.
If the action used to perform the operation was "move", the source can now delete the transferred data.
action ¤
action(dnd_action: dnd_action) -> None
Notify the selected action
This event indicates the action selected by the compositor after matching the source/destination side actions. Only one action (or none) will be offered here.
This event can be emitted multiple times during the drag-and-drop operation, mainly in response to destination side changes through wl_data_offer.set_actions, and as the data device enters/leaves surfaces.
It is only possible to receive this event after wl_data_source.dnd_drop_performed if the drag-and-drop operation ended in an "ask" action, in which case the final wl_data_source.action event will happen immediately before wl_data_source.dnd_finished.
Compositors may also change the selected action on the fly, mainly in response to keyboard modifier changes during the drag-and-drop operation.
The most recent action received is always the valid one. The chosen action may change alongside negotiation (e.g. an "ask" action can turn into a "move" operation), so the effects of the final action must always be applied in wl_data_offer.dnd_finished.
Clients can trigger cursor surface changes from this point, so they reflect the current action.
Parameters:
-
dnd_action
¤dnd_action
) –Action selected by the compositor
offer ¤
set_actions ¤
set_actions(dnd_actions: dnd_action) -> None
Set the available drag-and-drop actions
Sets the actions that the source side client supports for this operation. This request may trigger wl_data_source.action and wl_data_offer.action events if the compositor needs to change the selected action.
The dnd_actions argument must contain only values expressed in the wl_data_device_manager.dnd_actions enum, otherwise it will result in a protocol error.
This request must be made once only, and can only be made on sources used in drag-and-drop, so it must be performed before wl_data_device.start_drag. Attempting to use the source other than for drag-and-drop will raise a protocol error.
Parameters:
-
dnd_actions
¤dnd_action
) –Actions supported by the data source
on_target ¤
on_target(mime_type: str) -> None
A target accepts an offered mime type.
Override to handle wayland.wl_data_source.events.target
.
on_send ¤
on_send(mime_type: str, fd: fd) -> None
Send the data.
Override to handle wayland.wl_data_source.events.send
.
on_cancelled ¤
on_cancelled() -> None
Selection was cancelled.
Override to handle wayland.wl_data_source.events.cancelled
.
on_dnd_drop_performed ¤
on_dnd_drop_performed() -> None
The drag-and-drop operation physically finished.
Override to handle wayland.wl_data_source.events.dnd_drop_performed
.
on_dnd_finished ¤
on_dnd_finished() -> None
The drag-and-drop operation concluded.
Override to handle wayland.wl_data_source.events.dnd_finished
.
on_action ¤
on_action(dnd_action: dnd_action) -> None
Notify the selected action.
Override to handle wayland.wl_data_source.events.action
.