Compare commits
No commits in common. "319db02e5219c557c8f03b0e33a8eb4075cabb85" and "6ca3cc3d4c221d34a4c385957bd3fd8be9ad48e5" have entirely different histories.
319db02e52
...
6ca3cc3d4c
14 changed files with 33 additions and 183 deletions
14
Cargo.toml
14
Cargo.toml
|
|
@ -11,16 +11,6 @@ readme = "README.md"
|
||||||
keywords = ["clipboard", "window", "ui", "gui", "raw-window-handle"]
|
keywords = ["clipboard", "window", "ui", "gui", "raw-window-handle"]
|
||||||
categories = ["gui"]
|
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]
|
[dependencies]
|
||||||
raw-window-handle = { version = "0.6", features = ["std"] }
|
raw-window-handle = { version = "0.6", features = ["std"] }
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
|
|
@ -34,8 +24,8 @@ clipboard-win = { version = "5.0", features = ["std"] }
|
||||||
clipboard_macos = { version = "0.1", 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", target_os="redox"))))'.dependencies]
|
[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", optional = true }
|
clipboard_x11 = { version = "0.4.2", path = "./x11" }
|
||||||
clipboard_wayland = { version = "0.2.2", path = "./wayland", optional = true }
|
clipboard_wayland = { version = "0.2.2", path = "./wayland" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@ bitflags = "2.5.0"
|
||||||
raw-window-handle = "0.6"
|
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]
|
[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 = "sctk-0.20", features = [
|
smithay-clipboard = { git = "https://github.com/pop-os/smithay-clipboard", tag = "pop-dnd-3", features = [
|
||||||
"dnd",
|
"dnd",
|
||||||
] }
|
] }
|
||||||
sctk = { package = "smithay-client-toolkit", version = "0.20", default-features = false, features = [
|
sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/client-toolkit", default-features = false, features = [
|
||||||
"calloop",
|
"calloop",
|
||||||
] }
|
], rev = "3bed072" }
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,9 @@ pub enum Icon {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct DndSurface(pub Arc<dyn HasWindowHandle + 'static + Send + Sync>);
|
pub struct DndSurface(
|
||||||
|
pub Arc<Box<dyn HasWindowHandle + 'static + Send + Sync>>,
|
||||||
|
);
|
||||||
|
|
||||||
impl Debug for DndSurface {
|
impl Debug for DndSurface {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,13 @@ impl<T: mime::AsMimeTypes> AsMimeTypes for DataWrapper<T> {
|
||||||
|
|
||||||
impl smithay_clipboard::dnd::RawSurface for DndSurface {
|
impl smithay_clipboard::dnd::RawSurface for DndSurface {
|
||||||
unsafe fn get_ptr(&mut self) -> *mut c_void {
|
unsafe fn get_ptr(&mut self) -> *mut c_void {
|
||||||
self.0.window_handle().unwrap().get_ptr()
|
// 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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,4 +6,4 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# 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]
|
[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 = "sctk-0.20" }
|
smithay-clipboard = { git = "https://github.com/pop-os/smithay-clipboard", tag = "pop-dnd-3" }
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ pub struct PlatformClipboard<C> {
|
||||||
|
|
||||||
impl PlatformClipboard<platform::Clipboard> {
|
impl PlatformClipboard<platform::Clipboard> {
|
||||||
/// Safety: the display handle must be valid for the lifetime of `Clipboard`
|
/// Safety: the display handle must be valid for the lifetime of `Clipboard`
|
||||||
pub unsafe fn connect<W: HasDisplayHandle + ?Sized>(
|
pub unsafe fn connect<W: HasDisplayHandle>(
|
||||||
window: &W,
|
window: &W,
|
||||||
) -> Result<Self, Box<dyn Error>> {
|
) -> Result<Self, Box<dyn Error>> {
|
||||||
Ok(PlatformClipboard {
|
Ok(PlatformClipboard {
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,12 @@
|
||||||
use crate::ClipboardProvider;
|
use crate::ClipboardProvider;
|
||||||
|
|
||||||
use crate::dnd::DndProvider;
|
|
||||||
use dnd::{DndAction, DndDestinationRectangle, DndSurface, Icon};
|
|
||||||
use mime::{AllowedMimeTypes, AsMimeTypes};
|
|
||||||
use raw_window_handle::HasDisplayHandle;
|
use raw_window_handle::HasDisplayHandle;
|
||||||
use std::{borrow::Cow, error::Error};
|
use std::error::Error;
|
||||||
|
|
||||||
pub fn connect<W: HasDisplayHandle>(
|
pub fn connect<W: HasDisplayHandle>(
|
||||||
_window: &W,
|
_window: &W,
|
||||||
) -> Result<Clipboard, Box<dyn Error>> {
|
) -> Result<Clipboard, Box<dyn Error>> {
|
||||||
Clipboard::new()
|
Ok(Clipboard::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Clipboard;
|
pub struct Clipboard;
|
||||||
|
|
@ -39,46 +36,7 @@ impl ClipboardProvider for Clipboard {
|
||||||
Err(Box::new(AndroidClipboardError::Unimplemented))
|
Err(Box::new(AndroidClipboardError::Unimplemented))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write(&mut self, _contents: String) -> Result<(), Box<dyn Error>> {
|
fn write(&mut self, contents: String) -> Result<(), Box<dyn Error>> {
|
||||||
Err(Box::new(AndroidClipboardError::Unimplemented))
|
Err(Box::new(AndroidClipboardError::Unimplemented))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DndProvider for Clipboard {
|
|
||||||
fn init_dnd(
|
|
||||||
&self,
|
|
||||||
_tx: Box<dyn dnd::Sender<DndSurface> + Send + Sync + 'static>,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
fn start_dnd<D: AsMimeTypes + Send + 'static>(
|
|
||||||
&self,
|
|
||||||
_internal: bool,
|
|
||||||
_source_surface: DndSurface,
|
|
||||||
_icon_surface: Option<Icon>,
|
|
||||||
_content: D,
|
|
||||||
_actions: DndAction,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
fn end_dnd(&self) {}
|
|
||||||
|
|
||||||
fn register_dnd_destination(
|
|
||||||
&self,
|
|
||||||
_surface: DndSurface,
|
|
||||||
_rectangles: Vec<DndDestinationRectangle>,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_action(&self, _action: DndAction) {}
|
|
||||||
|
|
||||||
fn peek_offer<D: AllowedMimeTypes + 'static>(
|
|
||||||
&self,
|
|
||||||
_mime_type: Option<Cow<'static, str>>,
|
|
||||||
) -> std::io::Result<D> {
|
|
||||||
Err(std::io::Error::new(
|
|
||||||
std::io::ErrorKind::Other,
|
|
||||||
"DnD not supported",
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use std::borrow::Cow;
|
||||||
|
|
||||||
pub struct Clipboard;
|
pub struct Clipboard;
|
||||||
|
|
||||||
pub fn connect<W: HasDisplayHandle + ?Sized>(
|
pub fn connect<W: HasDisplayHandle>(
|
||||||
_window: &W,
|
_window: &W,
|
||||||
) -> Result<Clipboard, Box<dyn std::error::Error>> {
|
) -> Result<Clipboard, Box<dyn std::error::Error>> {
|
||||||
Ok(Clipboard)
|
Ok(Clipboard)
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use crate::ClipboardProvider;
|
||||||
use raw_window_handle::HasDisplayHandle;
|
use raw_window_handle::HasDisplayHandle;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
|
||||||
pub fn connect<W: HasDisplayHandle + ?Sized>(
|
pub fn connect<W: HasDisplayHandle>(
|
||||||
_window: &W,
|
_window: &W,
|
||||||
) -> Result<Clipboard, Box<dyn Error>> {
|
) -> Result<Clipboard, Box<dyn Error>> {
|
||||||
Clipboard::new()
|
Clipboard::new()
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,10 @@ use std::{borrow::Cow, error::Error, sync::Arc};
|
||||||
use wayland::DndSender;
|
use wayland::DndSender;
|
||||||
|
|
||||||
pub use clipboard_wayland as wayland;
|
pub use clipboard_wayland as wayland;
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
pub use clipboard_x11 as x11;
|
pub use clipboard_x11 as x11;
|
||||||
|
|
||||||
pub enum Clipboard {
|
pub enum Clipboard {
|
||||||
Wayland(wayland::Clipboard),
|
Wayland(wayland::Clipboard),
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
X11(x11::Clipboard),
|
X11(x11::Clipboard),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -24,7 +22,6 @@ impl ClipboardProvider for Clipboard {
|
||||||
fn read(&self) -> Result<String, Box<dyn Error>> {
|
fn read(&self) -> Result<String, Box<dyn Error>> {
|
||||||
match self {
|
match self {
|
||||||
Clipboard::Wayland(c) => c.read(),
|
Clipboard::Wayland(c) => c.read(),
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
Clipboard::X11(c) => c.read().map_err(Box::from),
|
Clipboard::X11(c) => c.read().map_err(Box::from),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -32,7 +29,6 @@ impl ClipboardProvider for Clipboard {
|
||||||
fn write(&mut self, contents: String) -> Result<(), Box<dyn Error>> {
|
fn write(&mut self, contents: String) -> Result<(), Box<dyn Error>> {
|
||||||
match self {
|
match self {
|
||||||
Clipboard::Wayland(c) => c.write(contents),
|
Clipboard::Wayland(c) => c.write(contents),
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
Clipboard::X11(c) => c.write(contents).map_err(Box::from),
|
Clipboard::X11(c) => c.write(contents).map_err(Box::from),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -40,7 +36,6 @@ impl ClipboardProvider for Clipboard {
|
||||||
fn read_primary(&self) -> Option<Result<String, Box<dyn Error>>> {
|
fn read_primary(&self) -> Option<Result<String, Box<dyn Error>>> {
|
||||||
match self {
|
match self {
|
||||||
Clipboard::Wayland(c) => Some(c.read_primary()),
|
Clipboard::Wayland(c) => Some(c.read_primary()),
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
Clipboard::X11(c) => Some(c.read_primary().map_err(Box::from)),
|
Clipboard::X11(c) => Some(c.read_primary().map_err(Box::from)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -51,7 +46,6 @@ impl ClipboardProvider for Clipboard {
|
||||||
) -> Option<Result<(), Box<dyn Error>>> {
|
) -> Option<Result<(), Box<dyn Error>>> {
|
||||||
match self {
|
match self {
|
||||||
Clipboard::Wayland(c) => Some(c.write_primary(contents)),
|
Clipboard::Wayland(c) => Some(c.write_primary(contents)),
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
Clipboard::X11(c) => {
|
Clipboard::X11(c) => {
|
||||||
Some(c.write_primary(contents).map_err(Box::from))
|
Some(c.write_primary(contents).map_err(Box::from))
|
||||||
}
|
}
|
||||||
|
|
@ -67,7 +61,6 @@ impl ClipboardProvider for Clipboard {
|
||||||
let ret = c.read_data::<ClipboardLoadData<T>>();
|
let ret = c.read_data::<ClipboardLoadData<T>>();
|
||||||
Some(ret.map(|ret| ret.0))
|
Some(ret.map(|ret| ret.0))
|
||||||
}
|
}
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
Clipboard::X11(_) => None,
|
Clipboard::X11(_) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -83,7 +76,6 @@ impl ClipboardProvider for Clipboard {
|
||||||
Clipboard::Wayland(c) => {
|
Clipboard::Wayland(c) => {
|
||||||
Some(c.write_data::<ClipboardStoreData<T>>(contents))
|
Some(c.write_data::<ClipboardStoreData<T>>(contents))
|
||||||
}
|
}
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
Clipboard::X11(_) => None,
|
Clipboard::X11(_) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -97,7 +89,6 @@ impl ClipboardProvider for Clipboard {
|
||||||
let ret = c.read_primary_data::<ClipboardLoadData<T>>();
|
let ret = c.read_primary_data::<ClipboardLoadData<T>>();
|
||||||
Some(ret.map(|ret| ret.0))
|
Some(ret.map(|ret| ret.0))
|
||||||
}
|
}
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
Clipboard::X11(_) => None,
|
Clipboard::X11(_) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -108,7 +99,6 @@ impl ClipboardProvider for Clipboard {
|
||||||
) -> Option<Result<(Vec<u8>, String), Box<dyn Error>>> {
|
) -> Option<Result<(Vec<u8>, String), Box<dyn Error>>> {
|
||||||
match self {
|
match self {
|
||||||
Clipboard::Wayland(c) => Some(c.read_primary_raw(allowed)),
|
Clipboard::Wayland(c) => Some(c.read_primary_raw(allowed)),
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
Clipboard::X11(_) => None,
|
Clipboard::X11(_) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -119,7 +109,6 @@ impl ClipboardProvider for Clipboard {
|
||||||
) -> Option<Result<(Vec<u8>, String), Box<dyn Error>>> {
|
) -> Option<Result<(Vec<u8>, String), Box<dyn Error>>> {
|
||||||
match self {
|
match self {
|
||||||
Clipboard::Wayland(c) => Some(c.read_raw(allowed)),
|
Clipboard::Wayland(c) => Some(c.read_raw(allowed)),
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
Clipboard::X11(_) => None,
|
Clipboard::X11(_) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -135,7 +124,6 @@ impl ClipboardProvider for Clipboard {
|
||||||
Clipboard::Wayland(c) => {
|
Clipboard::Wayland(c) => {
|
||||||
Some(c.write_primary_data::<ClipboardStoreData<T>>(contents))
|
Some(c.write_primary_data::<ClipboardStoreData<T>>(contents))
|
||||||
}
|
}
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
Clipboard::X11(_) => None,
|
Clipboard::X11(_) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -147,8 +135,7 @@ impl DndProvider for Clipboard {
|
||||||
tx: Box<dyn dnd::Sender<DndSurface> + Send + Sync + 'static>,
|
tx: Box<dyn dnd::Sender<DndSurface> + Send + Sync + 'static>,
|
||||||
) {
|
) {
|
||||||
match self {
|
match self {
|
||||||
Clipboard::Wayland(c) => c.init_dnd(DndSender(Arc::from(tx))),
|
Clipboard::Wayland(c) => c.init_dnd(DndSender(Arc::new(tx))),
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
Clipboard::X11(_) => {}
|
Clipboard::X11(_) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -169,7 +156,6 @@ impl DndProvider for Clipboard {
|
||||||
content,
|
content,
|
||||||
actions,
|
actions,
|
||||||
),
|
),
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
Clipboard::X11(_) => {}
|
Clipboard::X11(_) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -177,7 +163,6 @@ impl DndProvider for Clipboard {
|
||||||
fn end_dnd(&self) {
|
fn end_dnd(&self) {
|
||||||
match self {
|
match self {
|
||||||
Clipboard::Wayland(c) => c.end_dnd(),
|
Clipboard::Wayland(c) => c.end_dnd(),
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
Clipboard::X11(_) => {}
|
Clipboard::X11(_) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -191,7 +176,6 @@ impl DndProvider for Clipboard {
|
||||||
Clipboard::Wayland(c) => {
|
Clipboard::Wayland(c) => {
|
||||||
c.register_dnd_destination(surface, rectangles)
|
c.register_dnd_destination(surface, rectangles)
|
||||||
}
|
}
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
Clipboard::X11(_) => {}
|
Clipboard::X11(_) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -199,7 +183,6 @@ impl DndProvider for Clipboard {
|
||||||
fn set_action(&self, action: DndAction) {
|
fn set_action(&self, action: DndAction) {
|
||||||
match self {
|
match self {
|
||||||
Clipboard::Wayland(c) => c.set_action(action),
|
Clipboard::Wayland(c) => c.set_action(action),
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
Clipboard::X11(_) => {}
|
Clipboard::X11(_) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -210,7 +193,6 @@ impl DndProvider for Clipboard {
|
||||||
) -> std::io::Result<D> {
|
) -> std::io::Result<D> {
|
||||||
match self {
|
match self {
|
||||||
Clipboard::Wayland(c) => c.peek_offer::<D>(mime_type),
|
Clipboard::Wayland(c) => c.peek_offer::<D>(mime_type),
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
Clipboard::X11(_) => Err(std::io::Error::new(
|
Clipboard::X11(_) => Err(std::io::Error::new(
|
||||||
std::io::ErrorKind::Other,
|
std::io::ErrorKind::Other,
|
||||||
"DnD not supported",
|
"DnD not supported",
|
||||||
|
|
@ -219,22 +201,14 @@ impl DndProvider for Clipboard {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn connect<W: HasDisplayHandle + ?Sized>(
|
pub unsafe fn connect<W: HasDisplayHandle>(
|
||||||
window: &W,
|
window: &W,
|
||||||
) -> Result<Clipboard, Box<dyn Error>> {
|
) -> Result<Clipboard, Box<dyn Error>> {
|
||||||
let clipboard = match window.display_handle()?.as_raw() {
|
let clipboard = match window.display_handle()?.as_raw() {
|
||||||
RawDisplayHandle::Wayland(handle) => Clipboard::Wayland(
|
RawDisplayHandle::Wayland(handle) => Clipboard::Wayland(
|
||||||
wayland::Clipboard::connect(handle.display.as_ptr()),
|
wayland::Clipboard::connect(handle.display.as_ptr()),
|
||||||
) as _,
|
) as _,
|
||||||
#[cfg(feature = "x11")]
|
|
||||||
_ => Clipboard::X11(x11::Clipboard::connect()?) as _,
|
_ => 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)
|
Ok(clipboard)
|
||||||
|
|
|
||||||
|
|
@ -1,57 +1,15 @@
|
||||||
use crate::ClipboardProvider;
|
use crate::ClipboardProvider;
|
||||||
|
|
||||||
use crate::dnd::DndProvider;
|
|
||||||
pub(crate) use clipboard_macos::Clipboard;
|
pub(crate) use clipboard_macos::Clipboard;
|
||||||
use dnd::{DndAction, DndDestinationRectangle, DndSurface, Icon};
|
|
||||||
use mime::{AllowedMimeTypes, AsMimeTypes};
|
|
||||||
use raw_window_handle::HasDisplayHandle;
|
use raw_window_handle::HasDisplayHandle;
|
||||||
use std::{borrow::Cow, error::Error};
|
use std::error::Error;
|
||||||
|
|
||||||
pub fn connect<W: HasDisplayHandle + ?Sized>(
|
pub fn connect<W: HasDisplayHandle>(
|
||||||
_window: &W,
|
_window: &W,
|
||||||
) -> Result<Clipboard, Box<dyn Error>> {
|
) -> Result<Clipboard, Box<dyn Error>> {
|
||||||
Clipboard::new()
|
Clipboard::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DndProvider for Clipboard {
|
|
||||||
fn init_dnd(
|
|
||||||
&self,
|
|
||||||
_tx: Box<dyn dnd::Sender<DndSurface> + Send + Sync + 'static>,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
fn start_dnd<D: AsMimeTypes + Send + 'static>(
|
|
||||||
&self,
|
|
||||||
_internal: bool,
|
|
||||||
_source_surface: DndSurface,
|
|
||||||
_icon_surface: Option<Icon>,
|
|
||||||
_content: D,
|
|
||||||
_actions: DndAction,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
fn end_dnd(&self) {}
|
|
||||||
|
|
||||||
fn register_dnd_destination(
|
|
||||||
&self,
|
|
||||||
_surface: DndSurface,
|
|
||||||
_rectangles: Vec<DndDestinationRectangle>,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_action(&self, _action: DndAction) {}
|
|
||||||
|
|
||||||
fn peek_offer<D: AllowedMimeTypes + 'static>(
|
|
||||||
&self,
|
|
||||||
_mime_type: Option<Cow<'static, str>>,
|
|
||||||
) -> std::io::Result<D> {
|
|
||||||
Err(std::io::Error::new(
|
|
||||||
std::io::ErrorKind::Other,
|
|
||||||
"DnD not supported",
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ClipboardProvider for Clipboard {
|
impl ClipboardProvider for Clipboard {
|
||||||
fn read(&self) -> Result<String, Box<dyn Error>> {
|
fn read(&self) -> Result<String, Box<dyn Error>> {
|
||||||
self.read()
|
self.read()
|
||||||
|
|
|
||||||
|
|
@ -1,55 +1,15 @@
|
||||||
use crate::ClipboardProvider;
|
use crate::ClipboardProvider;
|
||||||
|
|
||||||
use crate::dnd::DndProvider;
|
|
||||||
use clipboard_win::{get_clipboard_string, set_clipboard_string};
|
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 raw_window_handle::HasDisplayHandle;
|
||||||
use std::{borrow::Cow, error::Error};
|
|
||||||
|
|
||||||
pub fn connect<W: HasDisplayHandle + ?Sized>(
|
use std::error::Error;
|
||||||
|
|
||||||
|
pub fn connect<W: HasDisplayHandle>(
|
||||||
_window: &W,
|
_window: &W,
|
||||||
) -> Result<Clipboard, Box<dyn Error>> {
|
) -> Result<Clipboard, Box<dyn Error>> {
|
||||||
Ok(Clipboard)
|
Ok(Clipboard)
|
||||||
}
|
}
|
||||||
impl DndProvider for Clipboard {
|
|
||||||
fn init_dnd(
|
|
||||||
&self,
|
|
||||||
_tx: Box<dyn dnd::Sender<DndSurface> + Send + Sync + 'static>,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
fn start_dnd<D: AsMimeTypes + Send + 'static>(
|
|
||||||
&self,
|
|
||||||
_internal: bool,
|
|
||||||
_source_surface: DndSurface,
|
|
||||||
_icon_surface: Option<Icon>,
|
|
||||||
_content: D,
|
|
||||||
_actions: DndAction,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
fn end_dnd(&self) {}
|
|
||||||
|
|
||||||
fn register_dnd_destination(
|
|
||||||
&self,
|
|
||||||
_surface: DndSurface,
|
|
||||||
_rectangles: Vec<DndDestinationRectangle>,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_action(&self, _action: DndAction) {}
|
|
||||||
|
|
||||||
fn peek_offer<D: AllowedMimeTypes + 'static>(
|
|
||||||
&self,
|
|
||||||
_mime_type: Option<Cow<'static, str>>,
|
|
||||||
) -> std::io::Result<D> {
|
|
||||||
Err(std::io::Error::new(
|
|
||||||
std::io::ErrorKind::Other,
|
|
||||||
"DnD not supported",
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Clipboard;
|
pub struct Clipboard;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ keywords = ["clipboard", "wayland"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
smithay-clipboard = { git = "https://github.com/pop-os/smithay-clipboard", tag = "sctk-0.20", features = [
|
smithay-clipboard = { git = "https://github.com/pop-os/smithay-clipboard", tag = "pop-dnd-3", features = [
|
||||||
"dnd",
|
"dnd",
|
||||||
] }
|
] }
|
||||||
mime = { path = "../mime" }
|
mime = { path = "../mime" }
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,9 @@ use smithay_clipboard::dnd::{Icon, Rectangle};
|
||||||
pub use smithay_clipboard::mime::{AllowedMimeTypes, AsMimeTypes, MimeType};
|
pub use smithay_clipboard::mime::{AllowedMimeTypes, AsMimeTypes, MimeType};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct DndSender(pub Arc<dyn Sender<DndSurface> + 'static + Send + Sync>);
|
pub struct DndSender(
|
||||||
|
pub Arc<Box<dyn Sender<DndSurface> + 'static + Send + Sync>>,
|
||||||
|
);
|
||||||
|
|
||||||
impl smithay_clipboard::dnd::Sender<DndSurface> for DndSender {
|
impl smithay_clipboard::dnd::Sender<DndSurface> for DndSender {
|
||||||
fn send(
|
fn send(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue