Remove copypasta and maintain our own fork
This commit is contained in:
parent
b55ba14585
commit
23004b960f
16 changed files with 685 additions and 40 deletions
36
src/platform/linux.rs
Normal file
36
src/platform/linux.rs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
use crate::ClipboardProvider;
|
||||
|
||||
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
|
||||
use std::error::Error;
|
||||
|
||||
pub use window_clipboard_wayland as wayland;
|
||||
pub use window_clipboard_x11 as x11;
|
||||
|
||||
pub fn new_clipboard<W: HasRawWindowHandle>(
|
||||
window: &W,
|
||||
) -> Result<Box<dyn ClipboardProvider>, Box<dyn Error>> {
|
||||
let clipboard = match window.raw_window_handle() {
|
||||
RawWindowHandle::Wayland(handle) => {
|
||||
assert!(!handle.display.is_null());
|
||||
|
||||
Box::new(unsafe {
|
||||
wayland::Clipboard::new(handle.display as *mut _)
|
||||
}) as _
|
||||
}
|
||||
_ => Box::new(x11::Clipboard::new()?) as _,
|
||||
};
|
||||
|
||||
Ok(clipboard)
|
||||
}
|
||||
|
||||
impl ClipboardProvider for wayland::Clipboard {
|
||||
fn read(&self) -> Result<String, Box<dyn Error>> {
|
||||
self.read()
|
||||
}
|
||||
}
|
||||
|
||||
impl ClipboardProvider for x11::Clipboard {
|
||||
fn read(&self) -> Result<String, Box<dyn Error>> {
|
||||
self.read()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue