1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-22 21:01:36 +03:00

switch macos clipboard crate

This cleans up the `cargo audit` output on linux because the `clipboard`
crate (which hasn't been updated in 3 years) depends on xcb=0.8.2
which is flagged by cargo audit.

We don't use `clipboard` on any platform except macos

This commit switches to the `clipboard_macos` crate; that appears to
use a copy and paste of the macos specific code from the `clipboard`
crate, so this shouldn't have any change in functionality.

refs: https://github.com/wez/wezterm/issues/1952
This commit is contained in:
Wez Furlong 2022-05-08 21:11:39 -07:00
parent e9e590c64e
commit 6484b3adc0
3 changed files with 21 additions and 43 deletions

51
Cargo.lock generated
View File

@ -525,19 +525,6 @@ dependencies = [
"vec_map",
]
[[package]]
name = "clipboard"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25a904646c0340239dcf7c51677b33928bf24fdf424b79a57909c0109075b2e7"
dependencies = [
"clipboard-win",
"objc",
"objc-foundation",
"objc_id",
"x11-clipboard",
]
[[package]]
name = "clipboard-win"
version = "2.2.0"
@ -547,6 +534,17 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "clipboard_macos"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "145a7f9e9b89453bc0a5e32d166456405d389cea5b578f57f1274b1397588a95"
dependencies = [
"objc",
"objc-foundation",
"objc_id",
]
[[package]]
name = "cloudabi"
version = "0.0.3"
@ -4992,8 +4990,8 @@ dependencies = [
"bitflags",
"bytes",
"cgl",
"clipboard",
"clipboard-win",
"clipboard_macos",
"cocoa",
"config",
"core-foundation 0.7.0",
@ -5032,7 +5030,7 @@ dependencies = [
"windows",
"winreg",
"x11",
"xcb 1.1.1",
"xcb",
"xcb-imdkit",
"xkbcommon",
]
@ -5161,25 +5159,6 @@ dependencies = [
"pkg-config",
]
[[package]]
name = "x11-clipboard"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89bd49c06c9eb5d98e6ba6536cf64ac9f7ee3a009b2f53996d405b3944f6bcea"
dependencies = [
"xcb 0.8.2",
]
[[package]]
name = "xcb"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e917a3f24142e9ff8be2414e36c649d47d6cc2ba81f16201cdef96e533e02de"
dependencies = [
"libc",
"log",
]
[[package]]
name = "xcb"
version = "1.1.1"
@ -5200,7 +5179,7 @@ dependencies = [
"cc",
"lazy_static",
"pkg-config",
"xcb 1.1.1",
"xcb",
]
[[package]]
@ -5219,7 +5198,7 @@ source = "git+https://github.com/wez/xkbcommon-rs.git?rev=69a29877e99369b4ec7470
dependencies = [
"libc",
"memmap",
"xcb 1.1.1",
"xcb",
]
[[package]]

View File

@ -81,7 +81,7 @@ xcb-imdkit = { version="0.2", git="https://github.com/wez/xcb-imdkit-rs.git", re
[target.'cfg(target_os="macos")'.dependencies]
cocoa = "0.20"
objc = "0.2"
clipboard = "0.5"
clipboard_macos = "0.1"
core-foundation = "0.7"
core-graphics = "0.19"
cgl = "0.3"

View File

@ -13,6 +13,7 @@ use crate::{
};
use anyhow::{anyhow, bail, ensure};
use async_trait::async_trait;
use clipboard_macos::Clipboard as ClipboardContext;
use cocoa::appkit::{
self, CGFloat, NSApplication, NSApplicationActivateIgnoringOtherApps,
NSApplicationPresentationOptions, NSBackingStoreBuffered, NSEvent, NSEventModifierFlags,
@ -654,18 +655,16 @@ impl WindowOps for Window {
}
fn get_clipboard(&self, _clipboard: Clipboard) -> Future<String> {
use clipboard::ClipboardProvider;
Future::result(
clipboard::ClipboardContext::new()
.and_then(|mut ctx| ctx.get_contents())
ClipboardContext::new()
.and_then(|ctx| ctx.read())
.map_err(|e| anyhow!("Failed to get clipboard:{}", e)),
)
}
fn set_clipboard(&self, _clipboard: Clipboard, text: String) {
use clipboard::ClipboardProvider;
clipboard::ClipboardContext::new()
.and_then(|mut ctx| ctx.set_contents(text))
ClipboardContext::new()
.and_then(|mut ctx| ctx.write(text))
.ok();
}