Update smithay_clipboard and clipboard-win

This commit is contained in:
Héctor Ramón Jiménez 2020-08-06 11:04:12 +02:00
parent f5293f9b3b
commit 5f78242246
3 changed files with 13 additions and 15 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "window_clipboard"
version = "0.1.1"
version = "0.1.2"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2018"
description = "A library to obtain clipboard access from a `raw-window-handle`"
@ -15,14 +15,14 @@ categories = ["gui"]
raw-window-handle = "0.3"
[target.'cfg(windows)'.dependencies]
clipboard-win = "2.1"
clipboard-win = { version = "4.0", features = ["std"] }
[target.'cfg(target_os = "macos")'.dependencies]
clipboard_macos = { version = "0.1.0", path = "./macos" }
clipboard_macos = { version = "0.1", path = "./macos" }
[target.'cfg(all(unix, not(any(target_os="macos", target_os="android", target_os="emscripten", target_os="ios"))))'.dependencies]
clipboard_x11 = { version = "0.1.0", path = "./x11" }
clipboard_wayland = { version = "0.1.0", path = "./wayland" }
clipboard_x11 = { version = "0.1", path = "./x11" }
clipboard_wayland = { version = "0.1", path = "./wayland" }
[dev-dependencies]
winit = "0.22"

View file

@ -1,6 +1,6 @@
[package]
name = "clipboard_wayland"
version = "0.1.0"
version = "0.1.1"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2018"
description = "A library to obtain access to the clipboard of a Wayland window"
@ -10,4 +10,4 @@ documentation = "https://docs.rs/clipboard_wayland"
keywords = ["clipboard", "wayland"]
[dependencies]
smithay-clipboard = "0.3.4"
smithay-clipboard = "0.5.1"

View file

@ -16,27 +16,25 @@ use std::error::Error;
use std::ffi::c_void;
use std::sync::{Arc, Mutex};
use smithay_clipboard::WaylandClipboard;
pub struct Clipboard {
context: Arc<Mutex<WaylandClipboard>>,
context: Arc<Mutex<smithay_clipboard::Clipboard>>,
}
impl Clipboard {
pub unsafe fn new(display: *mut c_void) -> Clipboard {
let context = Arc::new(Mutex::new(
WaylandClipboard::new_from_external(display as *mut _),
));
let context = Arc::new(Mutex::new(smithay_clipboard::Clipboard::new(
display as *mut _,
)));
Clipboard { context }
}
pub fn read(&self) -> Result<String, Box<dyn Error>> {
Ok(self.context.lock().unwrap().load(None))
Ok(self.context.lock().unwrap().load()?)
}
pub fn write(&mut self, data: String) -> Result<(), Box<dyn Error>> {
self.context.lock().unwrap().store(None, data);
self.context.lock().unwrap().store(data);
Ok(())
}