desktop: Use egui-winit clipboard
The `egui-winit` clipboard implementation provides a nice interface to `smithay-clipboard` which correctly implements the core wayland selection protocol. It uses `arboard` as a fallback for other platforms.
This commit is contained in:
parent
8d193f8944
commit
f472bbc701
|
@ -211,16 +211,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a2041f1943049c7978768d84e6d0fd95de98b76d6c4727b09e78ec253d29fa58"
|
checksum = "a2041f1943049c7978768d84e6d0fd95de98b76d6c4727b09e78ec253d29fa58"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clipboard-win",
|
"clipboard-win",
|
||||||
"core-graphics",
|
|
||||||
"image",
|
|
||||||
"log",
|
"log",
|
||||||
"objc",
|
"objc",
|
||||||
"objc-foundation",
|
"objc-foundation",
|
||||||
"objc_id",
|
"objc_id",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"windows-sys 0.48.0",
|
|
||||||
"wl-clipboard-rs",
|
|
||||||
"x11rb",
|
"x11rb",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -633,12 +629,6 @@ version = "3.15.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8ea184aa71bb362a1157c896979544cc23974e08fd265f29ea96b59f0b4a555b"
|
checksum = "8ea184aa71bb362a1157c896979544cc23974e08fd265f29ea96b59f0b4a555b"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bytecount"
|
|
||||||
version = "0.6.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e1e5f035d16fc623ae5f74981db80a439803888314e3a555fd6f04acd51a3205"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytemuck"
|
name = "bytemuck"
|
||||||
version = "1.14.3"
|
version = "1.14.3"
|
||||||
|
@ -1388,17 +1378,6 @@ dependencies = [
|
||||||
"syn 1.0.109",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "derive-new"
|
|
||||||
version = "0.5.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3418329ca0ad70234b9735dc4ceed10af4df60eff9c8e7b06cb5e520d92c3535"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 1.0.109",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "diff"
|
name = "diff"
|
||||||
version = "0.1.13"
|
version = "0.1.13"
|
||||||
|
@ -1848,12 +1827,6 @@ dependencies = [
|
||||||
"simd-adler32",
|
"simd-adler32",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fixedbitset"
|
|
||||||
version = "0.4.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flash-lso"
|
name = "flash-lso"
|
||||||
version = "0.6.0"
|
version = "0.6.0"
|
||||||
|
@ -2277,7 +2250,7 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"libudev-sys",
|
"libudev-sys",
|
||||||
"log",
|
"log",
|
||||||
"nix 0.28.0",
|
"nix",
|
||||||
"uuid",
|
"uuid",
|
||||||
"vec_map",
|
"vec_map",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
|
@ -3176,15 +3149,6 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "memoffset"
|
|
||||||
version = "0.7.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memoffset"
|
name = "memoffset"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
|
@ -3379,19 +3343,6 @@ dependencies = [
|
||||||
"nihav_core",
|
"nihav_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "nix"
|
|
||||||
version = "0.26.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 1.3.2",
|
|
||||||
"cfg-if",
|
|
||||||
"libc",
|
|
||||||
"memoffset 0.7.1",
|
|
||||||
"pin-utils",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nix"
|
name = "nix"
|
||||||
version = "0.28.0"
|
version = "0.28.0"
|
||||||
|
@ -3402,7 +3353,7 @@ dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"cfg_aliases",
|
"cfg_aliases",
|
||||||
"libc",
|
"libc",
|
||||||
"memoffset 0.9.0",
|
"memoffset",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3685,16 +3636,6 @@ dependencies = [
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "os_pipe"
|
|
||||||
version = "1.1.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "57119c3b893986491ec9aa85056780d3a0f3cf4da7cc09dd3650dbd6c6738fb9"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"windows-sys 0.52.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "overload"
|
name = "overload"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
|
@ -3757,16 +3698,6 @@ version = "2.3.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
|
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "petgraph"
|
|
||||||
version = "0.6.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9"
|
|
||||||
dependencies = [
|
|
||||||
"fixedbitset",
|
|
||||||
"indexmap",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pin-project"
|
name = "pin-project"
|
||||||
version = "1.1.4"
|
version = "1.1.4"
|
||||||
|
@ -4286,7 +4217,6 @@ name = "ruffle_desktop"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"arboard",
|
|
||||||
"async-channel 2.2.0",
|
"async-channel 2.2.0",
|
||||||
"async-io",
|
"async-io",
|
||||||
"async-net",
|
"async-net",
|
||||||
|
@ -5522,20 +5452,6 @@ dependencies = [
|
||||||
"strength_reduce",
|
"strength_reduce",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tree_magic_mini"
|
|
||||||
version = "3.0.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "91adfd0607cacf6e4babdb870e9bec4037c1c4b151cfd279ccefc5e0c7feaa6d"
|
|
||||||
dependencies = [
|
|
||||||
"bytecount",
|
|
||||||
"fnv",
|
|
||||||
"lazy_static",
|
|
||||||
"nom",
|
|
||||||
"once_cell",
|
|
||||||
"petgraph",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ttf-parser"
|
name = "ttf-parser"
|
||||||
version = "0.20.0"
|
version = "0.20.0"
|
||||||
|
@ -5572,7 +5488,7 @@ version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "89daebc3e6fd160ac4aa9fc8b3bf71e1f74fbf92367ae71fb83a037e8bf164b9"
|
checksum = "89daebc3e6fd160ac4aa9fc8b3bf71e1f74fbf92367ae71fb83a037e8bf164b9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memoffset 0.9.0",
|
"memoffset",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
@ -6581,26 +6497,6 @@ dependencies = [
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wl-clipboard-rs"
|
|
||||||
version = "0.8.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "57af79e973eadf08627115c73847392e6b766856ab8e3844a59245354b23d2fa"
|
|
||||||
dependencies = [
|
|
||||||
"derive-new",
|
|
||||||
"libc",
|
|
||||||
"log",
|
|
||||||
"nix 0.26.4",
|
|
||||||
"os_pipe",
|
|
||||||
"tempfile",
|
|
||||||
"thiserror",
|
|
||||||
"tree_magic_mini",
|
|
||||||
"wayland-backend",
|
|
||||||
"wayland-client",
|
|
||||||
"wayland-protocols",
|
|
||||||
"wayland-protocols-wlr",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "x11-dl"
|
name = "x11-dl"
|
||||||
version = "2.21.0"
|
version = "2.21.0"
|
||||||
|
@ -6712,7 +6608,7 @@ dependencies = [
|
||||||
"futures-sink",
|
"futures-sink",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"hex",
|
"hex",
|
||||||
"nix 0.28.0",
|
"nix",
|
||||||
"ordered-stream",
|
"ordered-stream",
|
||||||
"rand",
|
"rand",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
|
@ -30,7 +30,6 @@ slotmap = { workspace = true }
|
||||||
winit = "0.29.15"
|
winit = "0.29.15"
|
||||||
webbrowser = "0.8.13"
|
webbrowser = "0.8.13"
|
||||||
url = "2.5.0"
|
url = "2.5.0"
|
||||||
arboard = { version = "3.3.2", features = ["wayland-data-control"] }
|
|
||||||
dirs = "5.0"
|
dirs = "5.0"
|
||||||
isahc = { version = "1.7.2", features = ["cookies"] }
|
isahc = { version = "1.7.2", features = ["cookies"] }
|
||||||
rfd = "0.14.0"
|
rfd = "0.14.0"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::preferences::GlobalPreferences;
|
use crate::preferences::GlobalPreferences;
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
use arboard::Clipboard;
|
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
|
use egui_winit::clipboard::Clipboard;
|
||||||
use fontdb::Family;
|
use fontdb::Family;
|
||||||
use rfd::{
|
use rfd::{
|
||||||
AsyncFileDialog, FileHandle, MessageButtons, MessageDialog, MessageDialogResult, MessageLevel,
|
AsyncFileDialog, FileHandle, MessageButtons, MessageDialog, MessageDialogResult, MessageLevel,
|
||||||
|
@ -14,6 +14,7 @@ use ruffle_core::backend::ui::{
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
use winit::raw_window_handle::HasDisplayHandle;
|
||||||
use winit::window::{Fullscreen, Window};
|
use winit::window::{Fullscreen, Window};
|
||||||
|
|
||||||
pub struct DesktopFileDialogResult {
|
pub struct DesktopFileDialogResult {
|
||||||
|
@ -117,7 +118,7 @@ impl FileDialogResult for DesktopFileDialogResult {
|
||||||
pub struct DesktopUiBackend {
|
pub struct DesktopUiBackend {
|
||||||
window: Rc<Window>,
|
window: Rc<Window>,
|
||||||
cursor_visible: bool,
|
cursor_visible: bool,
|
||||||
clipboard: Option<Clipboard>,
|
clipboard: Clipboard,
|
||||||
preferences: GlobalPreferences,
|
preferences: GlobalPreferences,
|
||||||
preferred_cursor: MouseCursor,
|
preferred_cursor: MouseCursor,
|
||||||
open_url_mode: OpenURLMode,
|
open_url_mode: OpenURLMode,
|
||||||
|
@ -133,12 +134,19 @@ impl DesktopUiBackend {
|
||||||
font_database: Rc<fontdb::Database>,
|
font_database: Rc<fontdb::Database>,
|
||||||
preferences: GlobalPreferences,
|
preferences: GlobalPreferences,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
|
// The window handle is only relevant to linux/wayland
|
||||||
|
// If it fails it'll fallback to x11 or wlr-data-control
|
||||||
|
let clipboard = Clipboard::new(
|
||||||
|
window
|
||||||
|
.clone()
|
||||||
|
.display_handle()
|
||||||
|
.ok()
|
||||||
|
.map(|handle| handle.as_raw()),
|
||||||
|
);
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
window,
|
window,
|
||||||
cursor_visible: true,
|
cursor_visible: true,
|
||||||
clipboard: Clipboard::new()
|
clipboard,
|
||||||
.inspect_err(|err| tracing::error!("Failed to initialize clipboard: {err}"))
|
|
||||||
.ok(),
|
|
||||||
preferences,
|
preferences,
|
||||||
preferred_cursor: MouseCursor::Arrow,
|
preferred_cursor: MouseCursor::Arrow,
|
||||||
open_url_mode,
|
open_url_mode,
|
||||||
|
@ -177,19 +185,11 @@ impl UiBackend for DesktopUiBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clipboard_content(&mut self) -> String {
|
fn clipboard_content(&mut self) -> String {
|
||||||
if let Some(ref mut clipboard) = self.clipboard {
|
self.clipboard.get().unwrap_or_default()
|
||||||
clipboard.get_text().unwrap_or_default()
|
|
||||||
} else {
|
|
||||||
"".to_string()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_clipboard_content(&mut self, content: String) {
|
fn set_clipboard_content(&mut self, content: String) {
|
||||||
if let Some(ref mut clipboard) = self.clipboard {
|
self.clipboard.set(content);
|
||||||
if let Err(e) = clipboard.set_text(content) {
|
|
||||||
error!("Couldn't set clipboard contents: {:?}", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_fullscreen(&mut self, is_full: bool) -> Result<(), FullscreenError> {
|
fn set_fullscreen(&mut self, is_full: bool) -> Result<(), FullscreenError> {
|
||||||
|
|
Loading…
Reference in New Issue