From 8a816d8f218e290041bb5ef6d3b695c38e0a53b7 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Wed, 1 May 2024 11:55:55 -0400 Subject: [PATCH 01/10] chore: update smithay-clipboard --- dnd/Cargo.toml | 2 +- mime/Cargo.toml | 2 +- wayland/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dnd/Cargo.toml b/dnd/Cargo.toml index f977386..207195e 100644 --- a/dnd/Cargo.toml +++ b/dnd/Cargo.toml @@ -9,7 +9,7 @@ bitflags = "2.5.0" raw-window-handle = "0.6" [target.'cfg(all(unix, not(any(target_os="macos", target_os="android", target_os="emscripten", target_os="ios", target_os="redox"))))'.dependencies] -smithay-clipboard = { git = "https://github.com/pop-os/smithay-clipboard", tag = "pop-dnd-3", features = [ +smithay-clipboard = { git = "https://github.com/pop-os/smithay-clipboard", tag = "pop-dnd-4", features = [ "dnd", ] } sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/client-toolkit", default-features = false, features = [ diff --git a/mime/Cargo.toml b/mime/Cargo.toml index 61643a0..5628e18 100644 --- a/mime/Cargo.toml +++ b/mime/Cargo.toml @@ -6,4 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [target.'cfg(all(unix, not(any(target_os="macos", target_os="android", target_os="emscripten", target_os="ios", target_os="redox"))))'.dependencies] -smithay-clipboard = { git = "https://github.com/pop-os/smithay-clipboard", tag = "pop-dnd-3" } +smithay-clipboard = { git = "https://github.com/pop-os/smithay-clipboard", tag = "pop-dnd-4" } diff --git a/wayland/Cargo.toml b/wayland/Cargo.toml index eafd122..46d0497 100644 --- a/wayland/Cargo.toml +++ b/wayland/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["clipboard", "wayland"] [dependencies] -smithay-clipboard = { git = "https://github.com/pop-os/smithay-clipboard", tag = "pop-dnd-3", features = [ +smithay-clipboard = { git = "https://github.com/pop-os/smithay-clipboard", tag = "pop-dnd-4", features = [ "dnd", ] } mime = { path = "../mime" } From a5be70405574e98c292537fd3b01a1352550b9bf Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Tue, 11 Jun 2024 17:58:40 -0700 Subject: [PATCH 02/10] Update smithay-clipboard --- dnd/Cargo.toml | 6 +++--- mime/Cargo.toml | 2 +- wayland/Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dnd/Cargo.toml b/dnd/Cargo.toml index 207195e..85e61bb 100644 --- a/dnd/Cargo.toml +++ b/dnd/Cargo.toml @@ -9,9 +9,9 @@ bitflags = "2.5.0" raw-window-handle = "0.6" [target.'cfg(all(unix, not(any(target_os="macos", target_os="android", target_os="emscripten", target_os="ios", target_os="redox"))))'.dependencies] -smithay-clipboard = { git = "https://github.com/pop-os/smithay-clipboard", tag = "pop-dnd-4", features = [ +smithay-clipboard = { git = "https://github.com/pop-os/smithay-clipboard", tag = "pop-dnd-5", features = [ "dnd", ] } -sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/client-toolkit", default-features = false, features = [ +sctk = { package = "smithay-client-toolkit", version = "0.19.1", default-features = false, features = [ "calloop", -], rev = "3bed072" } +] } diff --git a/mime/Cargo.toml b/mime/Cargo.toml index 5628e18..176ca63 100644 --- a/mime/Cargo.toml +++ b/mime/Cargo.toml @@ -6,4 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [target.'cfg(all(unix, not(any(target_os="macos", target_os="android", target_os="emscripten", target_os="ios", target_os="redox"))))'.dependencies] -smithay-clipboard = { git = "https://github.com/pop-os/smithay-clipboard", tag = "pop-dnd-4" } +smithay-clipboard = { git = "https://github.com/pop-os/smithay-clipboard", tag = "pop-dnd-5" } diff --git a/wayland/Cargo.toml b/wayland/Cargo.toml index 46d0497..d2f8c5b 100644 --- a/wayland/Cargo.toml +++ b/wayland/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["clipboard", "wayland"] [dependencies] -smithay-clipboard = { git = "https://github.com/pop-os/smithay-clipboard", tag = "pop-dnd-4", features = [ +smithay-clipboard = { git = "https://github.com/pop-os/smithay-clipboard", tag = "pop-dnd-5", features = [ "dnd", ] } mime = { path = "../mime" } From 7c59b07b9172d8e0401f7e06609e1050575309c9 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Wed, 19 Jun 2024 12:37:26 -0400 Subject: [PATCH 03/10] fix: stubs for various platforms --- src/platform/android.rs | 48 ++++++++++++++++++++++++++++++++++++++--- src/platform/macos.rs | 44 ++++++++++++++++++++++++++++++++++++- src/platform/windows.rs | 44 +++++++++++++++++++++++++++++++++++-- 3 files changed, 130 insertions(+), 6 deletions(-) diff --git a/src/platform/android.rs b/src/platform/android.rs index c2d460a..885f80d 100644 --- a/src/platform/android.rs +++ b/src/platform/android.rs @@ -1,12 +1,15 @@ use crate::ClipboardProvider; +use crate::dnd::DndProvider; +use dnd::{DndAction, DndDestinationRectangle, DndSurface, Icon}; +use mime::{AllowedMimeTypes, AsMimeTypes}; use raw_window_handle::HasDisplayHandle; -use std::error::Error; +use std::{borrow::Cow, error::Error}; pub fn connect( _window: &W, ) -> Result> { - Ok(Clipboard::new()) + Clipboard::new() } pub struct Clipboard; @@ -36,7 +39,46 @@ impl ClipboardProvider for Clipboard { Err(Box::new(AndroidClipboardError::Unimplemented)) } - fn write(&mut self, contents: String) -> Result<(), Box> { + fn write(&mut self, _contents: String) -> Result<(), Box> { Err(Box::new(AndroidClipboardError::Unimplemented)) } } + +impl DndProvider for Clipboard { + fn init_dnd( + &self, + _tx: Box + Send + Sync + 'static>, + ) { + } + + fn start_dnd( + &self, + _internal: bool, + _source_surface: DndSurface, + _icon_surface: Option, + _content: D, + _actions: DndAction, + ) { + } + + fn end_dnd(&self) {} + + fn register_dnd_destination( + &self, + _surface: DndSurface, + _rectangles: Vec, + ) { + } + + fn set_action(&self, _action: DndAction) {} + + fn peek_offer( + &self, + _mime_type: Option>, + ) -> std::io::Result { + Err(std::io::Error::new( + std::io::ErrorKind::Other, + "DnD not supported", + )) + } +} diff --git a/src/platform/macos.rs b/src/platform/macos.rs index 084ace8..375799f 100644 --- a/src/platform/macos.rs +++ b/src/platform/macos.rs @@ -1,8 +1,11 @@ use crate::ClipboardProvider; +use crate::dnd::DndProvider; pub(crate) use clipboard_macos::Clipboard; +use dnd::{DndAction, DndDestinationRectangle, DndSurface, Icon}; +use mime::{AllowedMimeTypes, AsMimeTypes}; use raw_window_handle::HasDisplayHandle; -use std::error::Error; +use std::{borrow::Cow, error::Error}; pub fn connect( _window: &W, @@ -10,6 +13,45 @@ pub fn connect( Clipboard::new() } +impl DndProvider for Clipboard { + fn init_dnd( + &self, + _tx: Box + Send + Sync + 'static>, + ) { + } + + fn start_dnd( + &self, + _internal: bool, + _source_surface: DndSurface, + _icon_surface: Option, + _content: D, + _actions: DndAction, + ) { + } + + fn end_dnd(&self) {} + + fn register_dnd_destination( + &self, + _surface: DndSurface, + _rectangles: Vec, + ) { + } + + fn set_action(&self, _action: DndAction) {} + + fn peek_offer( + &self, + _mime_type: Option>, + ) -> std::io::Result { + Err(std::io::Error::new( + std::io::ErrorKind::Other, + "DnD not supported", + )) + } +} + impl ClipboardProvider for Clipboard { fn read(&self) -> Result> { self.read() diff --git a/src/platform/windows.rs b/src/platform/windows.rs index f317b10..de79fc6 100644 --- a/src/platform/windows.rs +++ b/src/platform/windows.rs @@ -1,15 +1,55 @@ use crate::ClipboardProvider; +use crate::dnd::DndProvider; use clipboard_win::{get_clipboard_string, set_clipboard_string}; +use dnd::{DndAction, DndDestinationRectangle, DndSurface, Icon}; +use mime::{AllowedMimeTypes, AsMimeTypes}; use raw_window_handle::HasDisplayHandle; - -use std::error::Error; +use std::{borrow::Cow, error::Error}; pub fn connect( _window: &W, ) -> Result> { Ok(Clipboard) } +impl DndProvider for Clipboard { + fn init_dnd( + &self, + _tx: Box + Send + Sync + 'static>, + ) { + } + + fn start_dnd( + &self, + _internal: bool, + _source_surface: DndSurface, + _icon_surface: Option, + _content: D, + _actions: DndAction, + ) { + } + + fn end_dnd(&self) {} + + fn register_dnd_destination( + &self, + _surface: DndSurface, + _rectangles: Vec, + ) { + } + + fn set_action(&self, _action: DndAction) {} + + fn peek_offer( + &self, + _mime_type: Option>, + ) -> std::io::Result { + Err(std::io::Error::new( + std::io::ErrorKind::Other, + "DnD not supported", + )) + } +} pub struct Clipboard; From 1832d5637b27ad9b0c781724ab30bec844366c63 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Fri, 20 Sep 2024 15:10:45 -0400 Subject: [PATCH 04/10] refactor: remove Sized bound --- dnd/src/lib.rs | 4 +--- src/lib.rs | 2 +- src/platform/ios.rs | 2 +- src/platform/linux.rs | 2 +- src/platform/macos.rs | 2 +- src/platform/windows.rs | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/dnd/src/lib.rs b/dnd/src/lib.rs index 16c99f9..66ccd8c 100644 --- a/dnd/src/lib.rs +++ b/dnd/src/lib.rs @@ -189,9 +189,7 @@ pub enum Icon { } #[derive(Clone)] -pub struct DndSurface( - pub Arc>, -); +pub struct DndSurface(pub Arc); impl Debug for DndSurface { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { diff --git a/src/lib.rs b/src/lib.rs index e671882..54d330f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -62,7 +62,7 @@ pub struct PlatformClipboard { impl PlatformClipboard { /// Safety: the display handle must be valid for the lifetime of `Clipboard` - pub unsafe fn connect( + pub unsafe fn connect( window: &W, ) -> Result> { Ok(PlatformClipboard { diff --git a/src/platform/ios.rs b/src/platform/ios.rs index 1ab6e84..fd961c7 100644 --- a/src/platform/ios.rs +++ b/src/platform/ios.rs @@ -3,7 +3,7 @@ use crate::ClipboardProvider; use raw_window_handle::HasDisplayHandle; use std::error::Error; -pub fn connect( +pub fn connect( _window: &W, ) -> Result> { Clipboard::new() diff --git a/src/platform/linux.rs b/src/platform/linux.rs index 734f8f6..409a7e4 100644 --- a/src/platform/linux.rs +++ b/src/platform/linux.rs @@ -201,7 +201,7 @@ impl DndProvider for Clipboard { } } -pub unsafe fn connect( +pub unsafe fn connect( window: &W, ) -> Result> { let clipboard = match window.display_handle()?.as_raw() { diff --git a/src/platform/macos.rs b/src/platform/macos.rs index 375799f..d89c446 100644 --- a/src/platform/macos.rs +++ b/src/platform/macos.rs @@ -7,7 +7,7 @@ use mime::{AllowedMimeTypes, AsMimeTypes}; use raw_window_handle::HasDisplayHandle; use std::{borrow::Cow, error::Error}; -pub fn connect( +pub fn connect( _window: &W, ) -> Result> { Clipboard::new() diff --git a/src/platform/windows.rs b/src/platform/windows.rs index de79fc6..81d1e73 100644 --- a/src/platform/windows.rs +++ b/src/platform/windows.rs @@ -7,7 +7,7 @@ use mime::{AllowedMimeTypes, AsMimeTypes}; use raw_window_handle::HasDisplayHandle; use std::{borrow::Cow, error::Error}; -pub fn connect( +pub fn connect( _window: &W, ) -> Result> { Ok(Clipboard) From 68f111cfd0345c047723ec5c9f401e8da9666c6c Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Mon, 21 Oct 2024 11:13:59 -0400 Subject: [PATCH 05/10] fix: dummy --- src/platform/dummy.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/dummy.rs b/src/platform/dummy.rs index 3fc3779..c86bcbf 100644 --- a/src/platform/dummy.rs +++ b/src/platform/dummy.rs @@ -7,7 +7,7 @@ use std::borrow::Cow; pub struct Clipboard; -pub fn connect( +pub fn connect( _window: &W, ) -> Result> { Ok(Clipboard) From a83bf83784276aaa882ef13555295a2ad9edd265 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Mon, 21 Oct 2024 11:14:55 -0400 Subject: [PATCH 06/10] refactor: remove Box --- src/platform/linux.rs | 2 +- wayland/src/lib.rs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/platform/linux.rs b/src/platform/linux.rs index 409a7e4..3d953f1 100644 --- a/src/platform/linux.rs +++ b/src/platform/linux.rs @@ -135,7 +135,7 @@ impl DndProvider for Clipboard { tx: Box + Send + Sync + 'static>, ) { match self { - Clipboard::Wayland(c) => c.init_dnd(DndSender(Arc::new(tx))), + Clipboard::Wayland(c) => c.init_dnd(DndSender(Arc::from(tx))), Clipboard::X11(_) => {} } } diff --git a/wayland/src/lib.rs b/wayland/src/lib.rs index deb59d9..298e87c 100644 --- a/wayland/src/lib.rs +++ b/wayland/src/lib.rs @@ -27,9 +27,7 @@ use smithay_clipboard::dnd::{Icon, Rectangle}; pub use smithay_clipboard::mime::{AllowedMimeTypes, AsMimeTypes, MimeType}; #[derive(Clone)] -pub struct DndSender( - pub Arc + 'static + Send + Sync>>, -); +pub struct DndSender(pub Arc + 'static + Send + Sync>); impl smithay_clipboard::dnd::Sender for DndSender { fn send( From 6b9faab87bea9cebec6ae036906fd67fed254f5f Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Fri, 27 Dec 2024 15:57:12 -0800 Subject: [PATCH 07/10] dnd: Don't call `Arc::get_mut` The caller of `start_dnd` may also have a reference, so this can panic. Either the public API shouldn't take an `Arc` or this should be avoided. There doesn't seem to be any reason this is needed anyway. --- dnd/src/platform/linux.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/dnd/src/platform/linux.rs b/dnd/src/platform/linux.rs index abafb4b..31a1879 100644 --- a/dnd/src/platform/linux.rs +++ b/dnd/src/platform/linux.rs @@ -45,13 +45,7 @@ impl AsMimeTypes for DataWrapper { impl smithay_clipboard::dnd::RawSurface for DndSurface { unsafe fn get_ptr(&mut self) -> *mut c_void { - // XXX won't panic because this is only called once before it could be - // cloned - Arc::get_mut(&mut self.0) - .unwrap() - .window_handle() - .unwrap() - .get_ptr() + self.0.window_handle().unwrap().get_ptr() } } From 3a7af79e54db6854d8aa9d9e2866a9288d0f95d5 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Mon, 2 Mar 2026 12:32:18 -0500 Subject: [PATCH 08/10] update smithay-clipboard and sctk --- dnd/Cargo.toml | 4 ++-- mime/Cargo.toml | 2 +- src/platform/linux.rs | 1 + wayland/Cargo.toml | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dnd/Cargo.toml b/dnd/Cargo.toml index 85e61bb..0ddb926 100644 --- a/dnd/Cargo.toml +++ b/dnd/Cargo.toml @@ -9,9 +9,9 @@ bitflags = "2.5.0" raw-window-handle = "0.6" [target.'cfg(all(unix, not(any(target_os="macos", target_os="android", target_os="emscripten", target_os="ios", target_os="redox"))))'.dependencies] -smithay-clipboard = { git = "https://github.com/pop-os/smithay-clipboard", tag = "pop-dnd-5", features = [ +smithay-clipboard = { git = "https://github.com/pop-os/smithay-clipboard", tag = "sctk-0.20", features = [ "dnd", ] } -sctk = { package = "smithay-client-toolkit", version = "0.19.1", default-features = false, features = [ +sctk = { package = "smithay-client-toolkit", version = "0.20", default-features = false, features = [ "calloop", ] } diff --git a/mime/Cargo.toml b/mime/Cargo.toml index 176ca63..adacdb5 100644 --- a/mime/Cargo.toml +++ b/mime/Cargo.toml @@ -6,4 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [target.'cfg(all(unix, not(any(target_os="macos", target_os="android", target_os="emscripten", target_os="ios", target_os="redox"))))'.dependencies] -smithay-clipboard = { git = "https://github.com/pop-os/smithay-clipboard", tag = "pop-dnd-5" } +smithay-clipboard = { git = "https://github.com/pop-os/smithay-clipboard", tag = "sctk-0.20" } diff --git a/src/platform/linux.rs b/src/platform/linux.rs index 3d953f1..379c8ce 100644 --- a/src/platform/linux.rs +++ b/src/platform/linux.rs @@ -74,6 +74,7 @@ impl ClipboardProvider for Clipboard { { match self { Clipboard::Wayland(c) => { + dbg!("linux write data..."); Some(c.write_data::>(contents)) } Clipboard::X11(_) => None, diff --git a/wayland/Cargo.toml b/wayland/Cargo.toml index d2f8c5b..fd1d4fc 100644 --- a/wayland/Cargo.toml +++ b/wayland/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["clipboard", "wayland"] [dependencies] -smithay-clipboard = { git = "https://github.com/pop-os/smithay-clipboard", tag = "pop-dnd-5", features = [ +smithay-clipboard = { git = "https://github.com/pop-os/smithay-clipboard", tag = "sctk-0.20", features = [ "dnd", ] } mime = { path = "../mime" } From f68595ee0e62fbd6589f4709b5aaa5c3c7ea5f6c Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Mon, 16 Mar 2026 16:51:48 -0400 Subject: [PATCH 09/10] cleanup: dbg --- src/platform/linux.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/platform/linux.rs b/src/platform/linux.rs index 379c8ce..3d953f1 100644 --- a/src/platform/linux.rs +++ b/src/platform/linux.rs @@ -74,7 +74,6 @@ impl ClipboardProvider for Clipboard { { match self { Clipboard::Wayland(c) => { - dbg!("linux write data..."); Some(c.write_data::>(contents)) } Clipboard::X11(_) => None, From 319db02e5219c557c8f03b0e33a8eb4075cabb85 Mon Sep 17 00:00:00 2001 From: leyoda Date: Fri, 24 Apr 2026 06:50:48 +0200 Subject: [PATCH 10/10] yoda: gate clipboard_x11 behind an opt-in feature Upstream pulled clipboard_x11 unconditionally on unix, which drags x11rb + x11rb-protocol and ~500 symbols of X11 clipboard code into every Wayland-only iced build. Add an x11 feature (default-on for compat) that gates: - the clipboard_x11 workspace dep (now optional) - `pub use clipboard_x11 as x11` re-export - the Clipboard::X11 enum variant - every match arm that handles it - the fallback branch in `unsafe fn connect` (returns a helpful error when called with a non-Wayland display handle) Wayland-only builds set `window_clipboard = { ..., default-features = false, features = ["wayland"] }` and skip the x11 backend entirely. --- Cargo.toml | 14 ++++++++++++-- src/platform/linux.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2aacaa0..4d13334 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,16 @@ readme = "README.md" keywords = ["clipboard", "window", "ui", "gui", "raw-window-handle"] categories = ["gui"] +[features] +# Yoda: put the unix clipboard backends behind opt-in features. Upstream +# pulled both X11 + Wayland unconditionally on unix — pure bloat for +# Wayland-only builds (clipboard_x11 pulls x11rb + its protocol machinery). +# Default keeps both enabled to preserve upstream behaviour; yoda consumers +# pass default-features=false + "wayland" at the dep declaration. +default = ["x11", "wayland"] +x11 = ["dep:clipboard_x11"] +wayland = ["dep:clipboard_wayland"] + [dependencies] raw-window-handle = { version = "0.6", features = ["std"] } thiserror = "1.0" @@ -24,8 +34,8 @@ clipboard-win = { version = "5.0", features = ["std"] } 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", target_os="redox"))))'.dependencies] -clipboard_x11 = { version = "0.4.2", path = "./x11" } -clipboard_wayland = { version = "0.2.2", path = "./wayland" } +clipboard_x11 = { version = "0.4.2", path = "./x11", optional = true } +clipboard_wayland = { version = "0.2.2", path = "./wayland", optional = true } [dev-dependencies] rand = "0.8" diff --git a/src/platform/linux.rs b/src/platform/linux.rs index 3d953f1..755dfb9 100644 --- a/src/platform/linux.rs +++ b/src/platform/linux.rs @@ -11,10 +11,12 @@ use std::{borrow::Cow, error::Error, sync::Arc}; use wayland::DndSender; pub use clipboard_wayland as wayland; +#[cfg(feature = "x11")] pub use clipboard_x11 as x11; pub enum Clipboard { Wayland(wayland::Clipboard), + #[cfg(feature = "x11")] X11(x11::Clipboard), } @@ -22,6 +24,7 @@ impl ClipboardProvider for Clipboard { fn read(&self) -> Result> { match self { Clipboard::Wayland(c) => c.read(), + #[cfg(feature = "x11")] Clipboard::X11(c) => c.read().map_err(Box::from), } } @@ -29,6 +32,7 @@ impl ClipboardProvider for Clipboard { fn write(&mut self, contents: String) -> Result<(), Box> { match self { Clipboard::Wayland(c) => c.write(contents), + #[cfg(feature = "x11")] Clipboard::X11(c) => c.write(contents).map_err(Box::from), } } @@ -36,6 +40,7 @@ impl ClipboardProvider for Clipboard { fn read_primary(&self) -> Option>> { match self { Clipboard::Wayland(c) => Some(c.read_primary()), + #[cfg(feature = "x11")] Clipboard::X11(c) => Some(c.read_primary().map_err(Box::from)), } } @@ -46,6 +51,7 @@ impl ClipboardProvider for Clipboard { ) -> Option>> { match self { Clipboard::Wayland(c) => Some(c.write_primary(contents)), + #[cfg(feature = "x11")] Clipboard::X11(c) => { Some(c.write_primary(contents).map_err(Box::from)) } @@ -61,6 +67,7 @@ impl ClipboardProvider for Clipboard { let ret = c.read_data::>(); Some(ret.map(|ret| ret.0)) } + #[cfg(feature = "x11")] Clipboard::X11(_) => None, } } @@ -76,6 +83,7 @@ impl ClipboardProvider for Clipboard { Clipboard::Wayland(c) => { Some(c.write_data::>(contents)) } + #[cfg(feature = "x11")] Clipboard::X11(_) => None, } } @@ -89,6 +97,7 @@ impl ClipboardProvider for Clipboard { let ret = c.read_primary_data::>(); Some(ret.map(|ret| ret.0)) } + #[cfg(feature = "x11")] Clipboard::X11(_) => None, } } @@ -99,6 +108,7 @@ impl ClipboardProvider for Clipboard { ) -> Option, String), Box>> { match self { Clipboard::Wayland(c) => Some(c.read_primary_raw(allowed)), + #[cfg(feature = "x11")] Clipboard::X11(_) => None, } } @@ -109,6 +119,7 @@ impl ClipboardProvider for Clipboard { ) -> Option, String), Box>> { match self { Clipboard::Wayland(c) => Some(c.read_raw(allowed)), + #[cfg(feature = "x11")] Clipboard::X11(_) => None, } } @@ -124,6 +135,7 @@ impl ClipboardProvider for Clipboard { Clipboard::Wayland(c) => { Some(c.write_primary_data::>(contents)) } + #[cfg(feature = "x11")] Clipboard::X11(_) => None, } } @@ -136,6 +148,7 @@ impl DndProvider for Clipboard { ) { match self { Clipboard::Wayland(c) => c.init_dnd(DndSender(Arc::from(tx))), + #[cfg(feature = "x11")] Clipboard::X11(_) => {} } } @@ -156,6 +169,7 @@ impl DndProvider for Clipboard { content, actions, ), + #[cfg(feature = "x11")] Clipboard::X11(_) => {} } } @@ -163,6 +177,7 @@ impl DndProvider for Clipboard { fn end_dnd(&self) { match self { Clipboard::Wayland(c) => c.end_dnd(), + #[cfg(feature = "x11")] Clipboard::X11(_) => {} } } @@ -176,6 +191,7 @@ impl DndProvider for Clipboard { Clipboard::Wayland(c) => { c.register_dnd_destination(surface, rectangles) } + #[cfg(feature = "x11")] Clipboard::X11(_) => {} } } @@ -183,6 +199,7 @@ impl DndProvider for Clipboard { fn set_action(&self, action: DndAction) { match self { Clipboard::Wayland(c) => c.set_action(action), + #[cfg(feature = "x11")] Clipboard::X11(_) => {} } } @@ -193,6 +210,7 @@ impl DndProvider for Clipboard { ) -> std::io::Result { match self { Clipboard::Wayland(c) => c.peek_offer::(mime_type), + #[cfg(feature = "x11")] Clipboard::X11(_) => Err(std::io::Error::new( std::io::ErrorKind::Other, "DnD not supported", @@ -208,7 +226,15 @@ pub unsafe fn connect( RawDisplayHandle::Wayland(handle) => Clipboard::Wayland( wayland::Clipboard::connect(handle.display.as_ptr()), ) as _, + #[cfg(feature = "x11")] _ => Clipboard::X11(x11::Clipboard::connect()?) as _, + #[cfg(not(feature = "x11"))] + _ => { + return Err(Box::from( + "Yoda window_clipboard: X11 feature disabled; \ + non-Wayland display handles are not supported", + )) + } }; Ok(clipboard)