diff --git a/examples/clipboard.rs b/examples/clipboard.rs index d916e4f..62ca53e 100644 --- a/examples/clipboard.rs +++ b/examples/clipboard.rs @@ -88,9 +88,9 @@ fn main() { smithay_clipboard::dnd::DndEvent::Offer(id, OfferEvent::Motion { x, y }) => { if id != state.offer_hover_id { state.offer_hover_id = id; - if let Ok(data) = state.clipboard.peek_offer::( - MimeType::Text(smithay_clipboard::mime::Text::TextPlain), - ) { + if let Ok(data) = + state.clipboard.peek_offer::(None) + { println!("Peeked the data: {}", data.0); } } @@ -117,8 +117,9 @@ fn main() { println!("Received DnD Enter for {id:?}"); state.offer_hover_id = id; if let Some(mime) = mime_types.get(0) { - if let Ok(data) = - state.clipboard.peek_offer::(mime.clone()) + if let Ok(data) = state + .clipboard + .peek_offer::(Some(mime.clone())) { println!("Peeked the data: {}", data.0); } diff --git a/src/dnd/mod.rs b/src/dnd/mod.rs index 06706e4..2862284 100644 --- a/src/dnd/mod.rs +++ b/src/dnd/mod.rs @@ -203,7 +203,7 @@ impl Clipboard { /// Register a surface for receiving DnD offers /// Rectangles should be provided in order of decreasing priority. - /// This method can be called multiple time for a single surface if the + /// This method c~an be called multiple time for a single surface if the /// rectangles change. pub fn register_dnd_destination(&self, surface: T, rectangles: Vec) { let s = DndSurface::new(surface, &self.connection).unwrap(); @@ -223,8 +223,12 @@ impl Clipboard { /// Peek at the contents of a DnD offer pub fn peek_offer( &self, - mime_type: MimeType, + mime_type: Option, ) -> std::io::Result { + let Some(mime_type) = mime_type.or_else(|| D::allowed().first().cloned()) else { + return Err(std::io::Error::new(std::io::ErrorKind::Other, "No mime type provided.")); + }; + self.request_sender .send(crate::worker::Command::DndRequest(DndRequest::Peek(mime_type))) .map_err(|_| {