Add primary clipboard support for X11 and wayland

The X11 code already had the functionality. Just didn't expose it.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
This commit is contained in:
Mohammad AlSaleh 2024-01-18 07:12:22 +03:00
parent 40447db331
commit cb8471828a
4 changed files with 70 additions and 6 deletions

View file

@ -24,9 +24,17 @@ impl ClipboardProvider for wayland::Clipboard {
self.read()
}
fn read_primary(&self) -> Option<Result<String, Box<dyn Error>>> {
Some(self.read_primary())
}
fn write(&mut self, contents: String) -> Result<(), Box<dyn Error>> {
self.write(contents)
}
fn write_primary(&mut self, contents: String) -> Option<Result<(), Box<dyn Error>>> {
Some(self.write_primary(contents))
}
}
impl ClipboardProvider for x11::Clipboard {
@ -34,7 +42,15 @@ impl ClipboardProvider for x11::Clipboard {
self.read().map_err(Box::from)
}
fn read_primary(&self) -> Option<Result<String, Box<dyn Error>>> {
Some(self.read_primary().map_err(Box::from))
}
fn write(&mut self, contents: String) -> Result<(), Box<dyn Error>> {
self.write(contents).map_err(Box::from)
}
fn write_primary(&mut self, contents: String) -> Option<Result<(), Box<dyn Error>>> {
Some(self.write_primary(contents).map_err(Box::from))
}
}