Struct smithay_client_toolkit::data_device::DataOffer
source · pub struct DataOffer { /* private fields */ }
Expand description
A data offer for receiving data though copy/paste or drag and drop
Implementations§
source§impl DataOffer
impl DataOffer
sourcepub fn with_mime_types<F, T>(&self, f: F) -> Twhere
F: FnOnce(&[String]) -> T,
pub fn with_mime_types<F, T>(&self, f: F) -> Twhere F: FnOnce(&[String]) -> T,
Access the list of mime types proposed by this offer
sourcepub fn get_available_actions(&self) -> DndAction
pub fn get_available_actions(&self) -> DndAction
Get the list of available actions for this offer
sourcepub fn get_current_action(&self) -> DndAction
pub fn get_current_action(&self) -> DndAction
Get the currently set final action for this offer
sourcepub fn accept(&self, mime_type: Option<String>)
pub fn accept(&self, mime_type: Option<String>)
Accept a mime type for receiving data through this offer
sourcepub fn receive(&self, mime_type: String) -> Result<ReadPipe>
pub fn receive(&self, mime_type: String) -> Result<ReadPipe>
Request to receive the data of a given mime type
You can do this several times, as a reaction to motion of the dnd cursor, or to inspect the data in order to choose your response.
Note that you should not read the contents right away in a blocking way, as you may deadlock your application doing so. At least make sure you flush your events to the server before doing so.
Fails if too many file descriptors were already open and a pipe could not be created.
sourcepub unsafe fn receive_to_fd(&self, mime_type: String, writefd: RawFd)
pub unsafe fn receive_to_fd(&self, mime_type: String, writefd: RawFd)
Receive data to the write end of a raw file descriptor. If you have the read end, you can read from it.
You can do this several times, as a reaction to motion of the dnd cursor, or to inspect the data in order to choose your response.
Note that you should not read the contents right away in a blocking way, as you may deadlock your application doing so. At least make sure you flush your events to the server before doing so.
Safety
The provided file destructor must be a valid FD for writing, and will be closed once the contents are written.
sourcepub fn set_actions(&self, supported: DndAction, preferred: DndAction)
pub fn set_actions(&self, supported: DndAction, preferred: DndAction)
Notify the send and compositor of the dnd actions you accept
You need to provide the set of supported actions, as well as a single preferred action.