WlDataSource

Struct WlDataSource 

Source
pub struct WlDataSource { /* private fields */ }
Expand description

A wl_data_source object.

See the documentation of the module for the interface description.

Implementations§

Source§

impl WlDataSource

Source

pub fn set_handler(&self, handler: impl WlDataSourceHandler)

Sets a new handler.

Source

pub fn set_boxed_handler(&self, handler: Box<dyn WlDataSourceHandler>)

Sets a new, already boxed handler.

Source§

impl WlDataSource

Source

pub const MSG__OFFER__SINCE: u32 = 1u32

Since when the offer message is available.

Source

pub const MSG__DESTROY__SINCE: u32 = 1u32

Since when the destroy message is available.

Source

pub const MSG__TARGET__SINCE: u32 = 1u32

Since when the target message is available.

Source

pub const MSG__SEND__SINCE: u32 = 1u32

Since when the send message is available.

Source

pub const MSG__CANCELLED__SINCE: u32 = 1u32

Since when the cancelled message is available.

Source

pub const MSG__SET_ACTIONS__SINCE: u32 = 3u32

Since when the set_actions message is available.

Source

pub const MSG__DND_DROP_PERFORMED__SINCE: u32 = 3u32

Since when the dnd_drop_performed message is available.

Source

pub const MSG__DND_FINISHED__SINCE: u32 = 3u32

Since when the dnd_finished message is available.

Source

pub const MSG__ACTION__SINCE: u32 = 3u32

Since when the action message is available.

Source

pub fn try_send_offer(&self, mime_type: &str) -> Result<(), ObjectError>

add an offered mime type

This request adds a mime type to the set of mime types advertised to targets. Can be called several times to offer multiple types.

§Arguments
  • mime_type: mime type offered by the data source
Source

pub fn send_offer(&self, mime_type: &str)

add an offered mime type

This request adds a mime type to the set of mime types advertised to targets. Can be called several times to offer multiple types.

§Arguments
  • mime_type: mime type offered by the data source
Source

pub fn try_send_destroy(&self) -> Result<(), ObjectError>

destroy the data source

Destroy the data source.

Source

pub fn send_destroy(&self)

destroy the data source

Destroy the data source.

Source

pub fn try_send_target( &self, mime_type: Option<&str>, ) -> Result<(), ObjectError>

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.

§Arguments
  • mime_type: mime type accepted by the target
Source

pub fn send_target(&self, mime_type: Option<&str>)

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.

§Arguments
  • mime_type: mime type accepted by the target
Source

pub fn try_send_send( &self, mime_type: &str, fd: &Rc<OwnedFd>, ) -> Result<(), ObjectError>

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.

§Arguments
  • mime_type: mime type for the data
  • fd: file descriptor for the data
Source

pub fn send_send(&self, mime_type: &str, fd: &Rc<OwnedFd>)

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.

§Arguments
  • mime_type: mime type for the data
  • fd: file descriptor for the data
Source

pub fn try_send_cancelled(&self) -> Result<(), ObjectError>

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.

Source

pub fn send_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.

Source

pub fn try_send_set_actions( &self, dnd_actions: WlDataDeviceManagerDndAction, ) -> Result<(), ObjectError>

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.

§Arguments
  • dnd_actions: actions supported by the data source
Source

pub fn send_set_actions(&self, dnd_actions: WlDataDeviceManagerDndAction)

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.

§Arguments
  • dnd_actions: actions supported by the data source
Source

pub fn try_send_dnd_drop_performed(&self) -> Result<(), ObjectError>

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.

Source

pub fn send_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.

Source

pub fn try_send_dnd_finished(&self) -> Result<(), ObjectError>

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.

Source

pub fn send_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.

Source

pub fn try_send_action( &self, dnd_action: WlDataDeviceManagerDndAction, ) -> Result<(), ObjectError>

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.

§Arguments
  • dnd_action: action selected by the compositor
Source

pub fn send_action(&self, dnd_action: WlDataDeviceManagerDndAction)

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.

§Arguments
  • dnd_action: action selected by the compositor
Source§

impl WlDataSource

Source

pub const ENM__ERROR_INVALID_ACTION_MASK__SINCE: u32 = 1u32

Since when the error.invalid_action_mask enum variant is available.

Source

pub const ENM__ERROR_INVALID_SOURCE__SINCE: u32 = 1u32

Since when the error.invalid_source enum variant is available.

Trait Implementations§

Source§

impl ConcreteObject for WlDataSource

Source§

const XML_VERSION: u32 = 3u32

The interface version from the XML file that the interface was generated from.
Source§

const INTERFACE: ObjectInterface = ObjectInterface::WlDataSource

The interface of the object.
Source§

const INTERFACE_NAME: &str = "wl_data_source"

The interface of the object as a string.
Source§

impl Debug for WlDataSource

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Object for WlDataSource

Source§

fn core(&self) -> &ObjectCore

Returns the ObjectCore of this object.
Source§

fn unset_handler(&self)

Unsets the handler of this object. Read more
Source§

fn get_handler_any_ref( &self, ) -> Result<HandlerRef<'_, dyn Any>, HandlerAccessError>

Returns a shared reference to the handler.
Source§

fn get_handler_any_mut( &self, ) -> Result<HandlerMut<'_, dyn Any>, HandlerAccessError>

Returns a mutable reference to the handler.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ObjectCoreApi for T
where T: Object + ?Sized,

Source§

fn state(&self) -> &Rc<State>

Returns the State of this object.
Source§

fn client(&self) -> Option<Rc<Client>>

Returns the Client associated with this object, if any.
Source§

fn create_child<P>(&self) -> Rc<P>
where P: Object,

Creates a child of this object. Read more
Source§

fn interface(&self) -> ObjectInterface

Returns the ObjectInterface of this object.
Source§

fn version(&self) -> u32

Returns the version of this object.
Source§

fn unique_id(&self) -> u64

Returns the unique ID of this object. Read more
Source§

fn client_id(&self) -> Option<u32>

Returns the client ID of this object, if any.
Source§

fn server_id(&self) -> Option<u32>

Returns the server ID of this object, if any.
Source§

fn delete_id(&self)

Sends a wl_display.delete_id event for this object. Read more
Source§

fn try_delete_id(&self) -> Result<(), ObjectError>

Tries to send a wl_display.delete_id event for this object. Read more
Source§

fn set_forward_to_client(&self, enabled: bool)

Enables or disables automatic forwarding of events to the client. Read more
Source§

fn set_forward_to_server(&self, enabled: bool)

Enables or disables automatic forwarding of requests to the server. Read more
Source§

impl<T> ObjectUtils for T
where T: Object + ?Sized,

Source§

fn try_get_handler_ref<T>( &self, ) -> Result<HandlerRef<'_, T>, HandlerAccessError>
where T: 'static,

Tries to get a shared reference to the handler.
Source§

fn get_handler_ref<T>(&self) -> HandlerRef<'_, T>
where T: 'static,

Gets a shared reference to the handler. Read more
Source§

fn try_get_handler_mut<T>( &self, ) -> Result<HandlerMut<'_, T>, HandlerAccessError>
where T: 'static,

Tries to get a mutable reference to the handler.
Source§

fn get_handler_mut<T>(&self) -> HandlerMut<'_, T>
where T: 'static,

Gets a mutable reference to the handler. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.