From 5158a13e19fbcf516b9816fdf75240106d43bf99 Mon Sep 17 00:00:00 2001 From: Bettehem Date: Tue, 26 Jul 2022 00:05:13 +0300 Subject: [PATCH] Enable wayland clipboard support by default on supported platforms (#869) * Added possibility to Follow/Unfollow artists via the context menu * Formatted code properly. * Wayland support is now automatically built on supported platforms. * Revert "Formatted code properly." This reverts commit ec057f9716574d0a7912ba8b5308c73bb0342f84. * Revert "Added possibility to Follow/Unfollow artists via the context menu" This reverts commit 9ac20514a640b9150fcfa38630d338ad6f097689. * Removed need for separate wayland_clipboard feature. Possibly fixed windows build. * Added more cfg conditions to sharing.rs. This possibly fixes the windows build. * Changed to only build wayland clipboard feature on linux by default. --- Cargo.toml | 6 +++--- src/sharing.rs | 15 +++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9e0d4f8..31e84a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,6 +45,7 @@ tokio-stream = "0.1.9" toml = "0.5" unicode-width = "0.1.9" url = "2.2" +[target.'cfg(target_os = "linux")'.dependencies] wl-clipboard-rs = {version = "0.6", optional = true} [dependencies.rspotify] @@ -73,10 +74,9 @@ pancurses_backend = ["cursive/pancurses-backend", "pancurses/win32"] portaudio_backend = ["librespot-playback/portaudio-backend"] pulseaudio_backend = ["librespot-playback/pulseaudio-backend"] rodio_backend = ["librespot-playback/rodio-backend"] -share_clipboard = ["clipboard"] # Share a link to the system clipboard -share_selection = ["clipboard", "wl-clipboard-rs"] # Use the primary selection for sharing - linux only +share_clipboard = ["clipboard", "wl-clipboard-rs"] # Share a link to the system clipboard +share_selection = ["clipboard", "wl-clipboard-rs"] # Use the primary selection for sharing - linux and bsd only termion_backend = ["cursive/termion-backend"] -wayland_clipboard = ["wl-clipboard-rs"] # Support wayland clipboard - linux only [package.metadata.deb] assets = [ diff --git a/src/sharing.rs b/src/sharing.rs index 3779a1a..69cecec 100644 --- a/src/sharing.rs +++ b/src/sharing.rs @@ -1,7 +1,7 @@ #![cfg(feature = "share_clipboard")] use std::env; -#[cfg(feature = "wayland_clipboard")] +#[cfg(all(feature = "wl-clipboard-rs", target_os = "linux"))] use { std::io::Read, wl_clipboard_rs::{ @@ -14,7 +14,10 @@ use { #[cfg(feature = "share_selection")] use clipboard::{x11_clipboard, x11_clipboard::X11ClipboardContext}; -#[cfg(all(feature = "share_selection", feature = "wayland_clipboard"))] +#[cfg(all( + feature = "share_selection", + all(feature = "wl-clipboard-rs", target_os = "linux") +))] use wl_clipboard_rs::utils::{is_primary_selection_supported, PrimarySelectionCheckError}; #[cfg(not(feature = "share_selection"))] @@ -39,7 +42,7 @@ pub fn read_share() -> Option { if is_wayland() { #[allow(unused_mut, unused_assignments)] let mut string = None; - #[cfg(feature = "wayland_clipboard")] + #[cfg(all(feature = "wl-clipboard-rs", target_os = "linux"))] { //use wayland clipboard let result = get_contents( @@ -77,7 +80,7 @@ pub fn read_share() -> Option { if is_wayland() { #[allow(unused_mut, unused_assignments)] let mut string = None; - #[cfg(feature = "wayland_clipboard")] + #[cfg(all(feature = "wl-clipboard-rs", target_os = "linux"))] { //use wayland clipboard string = match is_primary_selection_supported() { @@ -138,7 +141,7 @@ pub fn write_share(url: String) -> Option<()> { if is_wayland() { #[allow(unused_mut, unused_assignments)] let mut option = None; - #[cfg(feature = "wayland_clipboard")] + #[cfg(all(feature = "wl-clipboard-rs", target_os = "linux"))] { //use wayland clipboard let opts = Options::new(); @@ -167,7 +170,7 @@ pub fn write_share(url: String) -> Option<()> { if is_wayland() { #[allow(unused_mut, unused_assignments)] let mut option = None; - #[cfg(feature = "wayland_clipboard")] + #[cfg(all(feature = "wl-clipboard-rs", target_os = "linux"))] { //use wayland clipboard let mut opts = Options::new();