aboutsummaryrefslogtreecommitdiffstats
path: root/ports
diff options
context:
space:
mode:
Diffstat (limited to 'ports')
-rw-r--r--ports/servoshell/Cargo.toml2
-rw-r--r--ports/servoshell/browser.rs27
2 files changed, 13 insertions, 16 deletions
diff --git a/ports/servoshell/Cargo.toml b/ports/servoshell/Cargo.toml
index 2d532b29c6a..53774624463 100644
--- a/ports/servoshell/Cargo.toml
+++ b/ports/servoshell/Cargo.toml
@@ -44,8 +44,8 @@ webgl_backtrace = ["libservo/webgl_backtrace"]
xr-profile = ["libservo/xr-profile"]
[target.'cfg(not(target_os = "android"))'.dependencies]
+arboard = "3"
backtrace = { workspace = true }
-clipboard = "0.5"
egui = "0.22.0"
egui_glow = { version = "0.22.0", features = ["winit"] }
egui-winit = { version = "0.22.0", default-features = false, features = ["clipboard", "wayland"] }
diff --git a/ports/servoshell/browser.rs b/ports/servoshell/browser.rs
index d1ea764af9b..2dc1447297c 100644
--- a/ports/servoshell/browser.rs
+++ b/ports/servoshell/browser.rs
@@ -4,7 +4,7 @@
use crate::keyutils::{CMD_OR_ALT, CMD_OR_CONTROL};
use crate::window_trait::{WindowPortsMethods, LINE_HEIGHT};
-use clipboard::{ClipboardContext, ClipboardProvider};
+use arboard::Clipboard;
use euclid::{Point2D, Vector2D};
use keyboard_types::{Key, KeyboardEvent, Modifiers, ShortcutMatcher};
use servo::compositing::windowing::{WebRenderDebugOption, EmbedderEvent};
@@ -47,7 +47,7 @@ pub struct Browser<Window: WindowPortsMethods + ?Sized> {
window: Rc<Window>,
event_queue: Vec<EmbedderEvent>,
- clipboard_ctx: Option<ClipboardContext>,
+ clipboard: Option<Clipboard>,
shutdown_requested: bool,
}
@@ -63,7 +63,7 @@ where
browser_id: None,
browsers: Vec::new(),
window,
- clipboard_ctx: match ClipboardContext::new() {
+ clipboard: match Clipboard::new() {
Ok(c) => Some(c),
Err(e) => {
warn!("Error creating clipboard context ({})", e);
@@ -420,23 +420,20 @@ where
self.handle_key_from_servo(browser_id, key_event);
},
EmbedderMsg::GetClipboardContents(sender) => {
- let contents = match self.clipboard_ctx {
- Some(ref mut ctx) => match ctx.get_contents() {
- Ok(c) => c,
- Err(e) => {
- warn!("Error getting clipboard contents ({}), defaulting to empty string", e);
- "".to_owned()
- },
- },
- None => "".to_owned(),
- };
+ let contents = self.clipboard
+ .as_mut()
+ .and_then(|clipboard| clipboard.get_text().ok())
+ .unwrap_or_else(|| {
+ warn!("Error getting clipboard text. Returning empty string.");
+ String::new()
+ });
if let Err(e) = sender.send(contents) {
warn!("Failed to send clipboard ({})", e);
}
},
EmbedderMsg::SetClipboardContents(text) => {
- if let Some(ref mut ctx) = self.clipboard_ctx {
- if let Err(e) = ctx.set_contents(text) {
+ if let Some(ref mut clipboard) = self.clipboard {
+ if let Err(e) = clipboard.set_text(text) {
warn!("Error setting clipboard contents ({})", e);
}
}