summaryrefslogtreecommitdiff
path: root/alacritty_terminal
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2020-03-13 03:33:12 +0300
committerGitHub <noreply@github.com>2020-03-13 03:33:12 +0300
commit4000ec04d89b9bd77995960d2a9da8fcad55e003 (patch)
tree0e38be94eb1d75d70d5dcec7e676c699f3de29a2 /alacritty_terminal
parent6d60a49956facc63ab5e0ebac8eb15ab7347ea9a (diff)
downloadalacritty-4000ec04d89b9bd77995960d2a9da8fcad55e003.tar.gz
alacritty-4000ec04d89b9bd77995960d2a9da8fcad55e003.zip
Add option to pick Linux/BSD backends
This commit adds two cargo features `x11` and `wayland` to pick Linux/BSD backends, with both enabled by default. Fixes #3340.
Diffstat (limited to 'alacritty_terminal')
-rw-r--r--alacritty_terminal/Cargo.toml6
-rw-r--r--alacritty_terminal/src/clipboard.rs41
2 files changed, 32 insertions, 15 deletions
diff --git a/alacritty_terminal/Cargo.toml b/alacritty_terminal/Cargo.toml
index f86f9456..2fe46d0d 100644
--- a/alacritty_terminal/Cargo.toml
+++ b/alacritty_terminal/Cargo.toml
@@ -24,7 +24,7 @@ unicode-width = "0.1"
base64 = "0.11.0"
terminfo = "0.7.1"
url = "2"
-copypasta = "0.6.1"
+copypasta = { version = "0.6.3", default-features = false }
[target.'cfg(unix)'.dependencies]
nix = "0.16.1"
@@ -44,7 +44,9 @@ mio-anonymous-pipes = "0.1"
objc = "0.2.2"
[features]
-default = []
+default = ["x11", "wayland"]
+x11 = ["copypasta/x11"]
+wayland = ["copypasta/wayland"]
nightly = []
bench = []
diff --git a/alacritty_terminal/src/clipboard.rs b/alacritty_terminal/src/clipboard.rs
index 6f6a41be..1169cdc3 100644
--- a/alacritty_terminal/src/clipboard.rs
+++ b/alacritty_terminal/src/clipboard.rs
@@ -18,11 +18,13 @@ use std::ffi::c_void;
use log::{debug, warn};
use copypasta::nop_clipboard::NopClipboardContext;
-#[cfg(not(any(target_os = "macos", target_os = "windows")))]
+#[cfg(all(not(any(target_os = "macos", windows)), feature = "wayland"))]
use copypasta::wayland_clipboard;
-#[cfg(not(any(target_os = "macos", target_os = "windows")))]
+#[cfg(all(not(any(target_os = "macos", windows)), feature = "x11"))]
use copypasta::x11_clipboard::{Primary as X11SelectionClipboard, X11ClipboardContext};
-use copypasta::{ClipboardContext, ClipboardProvider};
+#[cfg(any(feature = "x11", target_os = "macos", windows))]
+use copypasta::ClipboardContext;
+use copypasta::ClipboardProvider;
pub struct Clipboard {
clipboard: Box<dyn ClipboardProvider>,
@@ -30,23 +32,33 @@ pub struct Clipboard {
}
impl Clipboard {
- #[cfg(any(target_os = "macos", target_os = "windows"))]
+ #[cfg(any(target_os = "macos", windows))]
pub fn new() -> Self {
Self::default()
}
- #[cfg(not(any(target_os = "macos", target_os = "windows")))]
- pub fn new(display: Option<*mut c_void>) -> Self {
- if let Some(display) = display {
- let (selection, clipboard) =
- unsafe { wayland_clipboard::create_clipboards_from_external(display) };
- return Self { clipboard: Box::new(clipboard), selection: Some(Box::new(selection)) };
+ #[cfg(not(any(target_os = "macos", windows)))]
+ pub fn new(_display: Option<*mut c_void>) -> Self {
+ #[cfg(feature = "wayland")]
+ {
+ if let Some(display) = _display {
+ let (selection, clipboard) =
+ unsafe { wayland_clipboard::create_clipboards_from_external(display) };
+ return Self {
+ clipboard: Box::new(clipboard),
+ selection: Some(Box::new(selection)),
+ };
+ }
}
- Self {
+ #[cfg(feature = "x11")]
+ return Self {
clipboard: Box::new(ClipboardContext::new().unwrap()),
selection: Some(Box::new(X11ClipboardContext::<X11SelectionClipboard>::new().unwrap())),
- }
+ };
+
+ #[cfg(not(feature = "x11"))]
+ return Self::new_nop();
}
// Use for tests and ref-tests
@@ -57,7 +69,10 @@ impl Clipboard {
impl Default for Clipboard {
fn default() -> Self {
- Self { clipboard: Box::new(ClipboardContext::new().unwrap()), selection: None }
+ #[cfg(any(feature = "x11", target_os = "macos", windows))]
+ return Self { clipboard: Box::new(ClipboardContext::new().unwrap()), selection: None };
+ #[cfg(not(any(feature = "x11", target_os = "macos", windows)))]
+ return Self::new_nop();
}
}