Skip to content

Commit

Permalink
Merge pull request #600 from xrelkd/feat/wayland
Browse files Browse the repository at this point in the history
Remove `Wayland` Support
  • Loading branch information
xrelkd authored Oct 26, 2024
2 parents a907396 + 6eadb86 commit d9cf057
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 292 deletions.
53 changes: 4 additions & 49 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
- [x] Persistent contents of clipboard
- [x] Support snippets
- [x] Support `X11`
- [x] Support `Wayland` (experimentally)
- [ ] ~~Support `Wayland` (experimentally)~~
- [x] Support `macOS`
- [x] Support `gRPC`
- [x] gRPC over `HTTP`
Expand Down Expand Up @@ -87,9 +87,9 @@ Currently, `clipcat` supports the following [windowing systems](https://en.wikip
- `X11`, the following `crate`s are leveraged:
- [x11rb](https://github.com/psychon/x11rb)
- [arboard](https://github.com/1Password/arboard)
- `Wayland` (experimentally), the following `crate`s are leveraged:
- [wl-clipboard-rs](https://github.com/YaLTeR/wl-clipboard-rs)
- [arboard](https://github.com/1Password/arboard)
- ~~`Wayland` (experimentally), the following `crate`s are leveraged:~~
- ~~[wl-clipboard-rs](https://github.com/YaLTeR/wl-clipboard-rs)~~
- ~~[arboard](https://github.com/1Password/arboard)~~

### Clipcat Client

Expand Down Expand Up @@ -200,9 +200,9 @@ emit_stderr = false
level = "INFO"

[watcher]
# Enable watching X11/Wayland clipboard selection.
# Enable watching X11 clipboard selection.
enable_clipboard = true
# Enable watching X11/Wayland primary selection.
# Enable watching X11 primary selection.
enable_primary = true
# Ignore clips which match with one of the X11 `TARGETS`.
sensitive_x11_atoms = ["x-kde-passwordManagerHint"]
Expand Down
9 changes: 4 additions & 5 deletions crates/clipboard/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,24 @@ snafu = { workspace = true }
clipcat-base = { path = "../base/" }

[target.'cfg(all(unix, not(any(target_os="macos", target_os="android", target_os="emscripten"))))'.dependencies]
x11rb = { version = "0.13", features = ["xfixes"] }
wl-clipboard-rs = "0.9"
x11rb = { version = "0.13", features = ["xfixes"] }

[target.'cfg(target_os = "macos")'.dependencies]
objc = "0.2"
objc_id = "0.1"
objc-foundation = "0.1"

[dev-dependencies]
tracing-subscriber = "0.3"
tracing-subscriber = { workspace = true }

tokio = { version = "1", features = [
tokio = { workspace = true, features = [
"macros",
"rt-multi-thread",
"signal",
"sync",
] }

sigfinn = "0.2"
sigfinn = { workspace = true }

[[example]]
name = "load"
Expand Down
39 changes: 15 additions & 24 deletions crates/clipboard/src/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::listener::MacOsListener;
target_os = "emscripten"
))
))]
use crate::listener::{WaylandListener, X11Listener};
use crate::listener::X11Listener;
use crate::{
traits::EventObserver, ClipboardKind, ClipboardLoad, ClipboardStore, ClipboardSubscribe, Error,
Subscriber,
Expand Down Expand Up @@ -98,33 +98,24 @@ impl Clipboard {
clip_filter: Arc<ClipFilter>,
event_observers: Vec<Arc<dyn EventObserver>>,
) -> Result<Self, Error> {
let listener: Arc<dyn ClipboardSubscribe<Subscriber = Subscriber>> =
if let Ok(display_name) = std::env::var("WAYLAND_DISPLAY") {
tracing::info!(
"Build Wayland listener ({clipboard_kind}) with display `{display_name}`"
);
Arc::new(WaylandListener::new(clipboard_kind)?)
} else {
match std::env::var("DISPLAY") {
Ok(display_name) => {
tracing::info!(
"Build X11 listener ({clipboard_kind}) with display `{display_name}`"
);
Arc::new(X11Listener::new(
Some(display_name),
clipboard_kind,
clip_filter,
event_observers,
)?)
}
Err(_) => Arc::new(X11Listener::new(
None,
let listener: Arc<dyn ClipboardSubscribe<Subscriber = Subscriber>> = {
match std::env::var("DISPLAY") {
Ok(display_name) => {
tracing::info!(
"Build X11 listener ({clipboard_kind}) with display `{display_name}`"
);
Arc::new(X11Listener::new(
Some(display_name),
clipboard_kind,
clip_filter,
event_observers,
)?),
)?)
}
Err(_) => {
Arc::new(X11Listener::new(None, clipboard_kind, clip_filter, event_observers)?)
}
};
}
};

let clear_on_drop = Arc::new(AtomicBool::from(false));

Expand Down
25 changes: 0 additions & 25 deletions crates/clipboard/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,6 @@ pub enum Error {
#[snafu(display("{error}"))]
X11Listener { error: crate::listener::x11::Error },

#[cfg(all(
unix,
not(any(
target_os = "macos",
target_os = "ios",
target_os = "android",
target_os = "emscripten"
))
))]
#[snafu(display("{error}"))]
WaylandListener { error: crate::listener::wayland::Error },

#[cfg(target_os = "macos")]
#[snafu(display("{error}"))]
MacOsListener { error: crate::listener::macos::Error },
Expand Down Expand Up @@ -61,19 +49,6 @@ impl From<crate::listener::x11::Error> for Error {
fn from(error: crate::listener::x11::Error) -> Self { Self::X11Listener { error } }
}

#[cfg(all(
unix,
not(any(
target_os = "macos",
target_os = "ios",
target_os = "android",
target_os = "emscripten"
))
))]
impl From<crate::listener::wayland::Error> for Error {
fn from(error: crate::listener::wayland::Error) -> Self { Self::WaylandListener { error } }
}

#[cfg(target_os = "macos")]
impl From<crate::listener::macos::Error> for Error {
fn from(error: crate::listener::macos::Error) -> Self { Self::MacOsListener { error } }
Expand Down
3 changes: 1 addition & 2 deletions crates/clipboard/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub use clipcat_base::ClipboardKind;
target_os = "emscripten"
))
))]
pub use self::listener::{WaylandListenerError, X11ListenerError};
pub use self::listener::X11ListenerError;
pub use self::{
default::Clipboard,
error::Error,
Expand All @@ -32,5 +32,4 @@ pub use self::{
#[derive(Clone, Copy, Debug)]
pub enum ListenerKind {
X11,
Wayland,
}
16 changes: 2 additions & 14 deletions crates/clipboard/src/listener/mod.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
#[cfg(target_os = "macos")]
pub mod macos;
#[cfg(all(
unix,
not(any(
target_os = "macos",
target_os = "ios",
target_os = "android",
target_os = "emscripten"
))
))]
pub mod wayland;

#[cfg(all(
unix,
not(any(
Expand All @@ -32,7 +23,4 @@ pub use self::macos::Listener as MacOsListener;
target_os = "emscripten"
))
))]
pub use self::{
wayland::{Error as WaylandListenerError, Listener as WaylandListener},
x11::{Error as X11ListenerError, Listener as X11Listener},
};
pub use self::x11::{Error as X11ListenerError, Listener as X11Listener};
9 changes: 0 additions & 9 deletions crates/clipboard/src/listener/wayland/error.rs

This file was deleted.

Loading

0 comments on commit d9cf057

Please sign in to comment.