feat: add wayland impl for custom mime types
This commit is contained in:
parent
8e7827ebbe
commit
6c41143f5c
5 changed files with 225 additions and 1 deletions
|
|
@ -18,6 +18,8 @@ use std::{
|
|||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
pub use smithay_clipboard::mime::{AllowedMimeTypes, AsMimeTypes, MimeType};
|
||||
|
||||
pub struct Clipboard {
|
||||
context: Arc<Mutex<smithay_clipboard::Clipboard>>,
|
||||
}
|
||||
|
|
@ -53,4 +55,34 @@ impl Clipboard {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn write<T: AsMimeTypes + Send + Sync + 'static>(
|
||||
&mut self,
|
||||
data: T,
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
self.context.lock().unwrap().store(data);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn write_primary<T: AsMimeTypes + Send + Sync + 'static>(
|
||||
&mut self,
|
||||
data: T,
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
self.context.lock().unwrap().store_primary(data);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn read<T: AllowedMimeTypes + 'static>(
|
||||
&self,
|
||||
) -> Result<T, Box<dyn Error>> {
|
||||
Ok(self.context.lock().unwrap().load()?)
|
||||
}
|
||||
|
||||
pub fn read_primary<T: AllowedMimeTypes + 'static>(
|
||||
&self,
|
||||
) -> Result<T, Box<dyn Error>> {
|
||||
Ok(self.context.lock().unwrap().load_primary()?)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue