pub struct WlDataSource { /* private fields */ }
Expand description
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.
See also the Request enum for this interface.
Implementations§
Source§impl WlDataSource
impl WlDataSource
Sourcepub fn target(&self, mime_type: Option<String>)
pub fn target(&self, mime_type: Option<String>)
a target accepts an offered mime type
Sent when a target accepts pointer_focus or motion events. If a target does not accept any of the offered types, type is NULL.
Used for feedback during drag-and-drop.
Sourcepub fn send(&self, mime_type: String, fd: BorrowedFd<'_>)
pub fn send(&self, mime_type: String, fd: BorrowedFd<'_>)
send the data
Request for data from the client. Send the data as the specified mime type over the passed file descriptor, then close it.
Sourcepub fn cancelled(&self)
pub fn cancelled(&self)
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.
Sourcepub fn dnd_drop_performed(&self)
pub fn dnd_drop_performed(&self)
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.
Sourcepub fn dnd_finished(&self)
pub fn dnd_finished(&self)
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.
Sourcepub fn action(&self, dnd_action: DndAction)
pub fn action(&self, dnd_action: DndAction)
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.
Trait Implementations§
Source§impl Borrow<ObjectId> for WlDataSource
impl Borrow<ObjectId> for WlDataSource
Source§impl Clone for WlDataSource
impl Clone for WlDataSource
Source§fn clone(&self) -> WlDataSource
fn clone(&self) -> WlDataSource
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for WlDataSource
impl Debug for WlDataSource
Source§impl Hash for WlDataSource
impl Hash for WlDataSource
Source§impl PartialEq<Weak<WlDataSource>> for WlDataSource
impl PartialEq<Weak<WlDataSource>> for WlDataSource
Source§impl PartialEq for WlDataSource
impl PartialEq for WlDataSource
Source§impl Resource for WlDataSource
impl Resource for WlDataSource
Source§fn object_data(&self) -> Option<&Arc<dyn Any + Send + Sync>>
fn object_data(&self) -> Option<&Arc<dyn Any + Send + Sync>>
Source§fn handle(&self) -> &WeakHandle
fn handle(&self) -> &WeakHandle
Source§fn from_id(conn: &DisplayHandle, id: ObjectId) -> Result<Self, InvalidId>
fn from_id(conn: &DisplayHandle, id: ObjectId) -> Result<Self, InvalidId>
Source§fn send_event(&self, evt: Self::Event<'_>) -> Result<(), InvalidId>
fn send_event(&self, evt: Self::Event<'_>) -> Result<(), InvalidId>
Source§fn parse_request(
conn: &DisplayHandle,
msg: Message<ObjectId, OwnedFd>,
) -> Result<(Self, Self::Request), DispatchError>
fn parse_request( conn: &DisplayHandle, msg: Message<ObjectId, OwnedFd>, ) -> Result<(Self, Self::Request), DispatchError>
Source§fn write_event<'a>(
&self,
conn: &DisplayHandle,
msg: Self::Event<'a>,
) -> Result<Message<ObjectId, BorrowedFd<'a>>, InvalidId>
fn write_event<'a>( &self, conn: &DisplayHandle, msg: Self::Event<'a>, ) -> Result<Message<ObjectId, BorrowedFd<'a>>, InvalidId>
Source§fn is_alive(&self) -> bool
fn is_alive(&self) -> bool
impl Eq for WlDataSource
Auto Trait Implementations§
impl Freeze for WlDataSource
impl !RefUnwindSafe for WlDataSource
impl Send for WlDataSource
impl Sync for WlDataSource
impl Unpin for WlDataSource
impl !UnwindSafe for WlDataSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.