feat(config): create config option for alternative x11 xclip backend

This commit is contained in:
Federico Terzi 2021-11-21 19:39:35 +01:00
parent 41b72acdf1
commit 42cbb6e3de
5 changed files with 22 additions and 0 deletions

View File

@ -150,6 +150,10 @@ pub trait Config: Send + Sync {
// If false, avoid showing the SecureInput notification on macOS // If false, avoid showing the SecureInput notification on macOS
fn secure_input_notification(&self) -> bool; fn secure_input_notification(&self) -> bool;
// If true, use the `xclip` command to implement the clipboard instead of
// the built-in native module on X11.
fn x11_use_xclip_backend(&self) -> bool;
// If true, filter out keyboard events without an explicit HID device source on Windows. // If true, filter out keyboard events without an explicit HID device source on Windows.
// This is needed to filter out the software-generated events, including // This is needed to filter out the software-generated events, including
// those from espanso, but might need to be disabled when using some software-level keyboards. // those from espanso, but might need to be disabled when using some software-level keyboards.
@ -193,6 +197,7 @@ pub trait Config: Send + Sync {
show_notifications: {:?} show_notifications: {:?}
secure_input_notification: {:?} secure_input_notification: {:?}
x11_use_xclip_backend: {:?}
win32_exclude_orphan_events: {:?} win32_exclude_orphan_events: {:?}
win32_keyboard_layout_cache_interval: {:?} win32_keyboard_layout_cache_interval: {:?}
@ -224,6 +229,7 @@ pub trait Config: Send + Sync {
self.show_notifications(), self.show_notifications(),
self.secure_input_notification(), self.secure_input_notification(),
self.x11_use_xclip_backend(),
self.win32_exclude_orphan_events(), self.win32_exclude_orphan_events(),
self.win32_keyboard_layout_cache_interval(), self.win32_keyboard_layout_cache_interval(),

View File

@ -46,6 +46,7 @@ pub(crate) struct ParsedConfig {
pub secure_input_notification: Option<bool>, pub secure_input_notification: Option<bool>,
pub win32_exclude_orphan_events: Option<bool>, pub win32_exclude_orphan_events: Option<bool>,
pub win32_keyboard_layout_cache_interval: Option<i64>, pub win32_keyboard_layout_cache_interval: Option<i64>,
pub x11_use_xclip_backend: Option<bool>,
pub pre_paste_delay: Option<usize>, pub pre_paste_delay: Option<usize>,
pub restore_clipboard_delay: Option<usize>, pub restore_clipboard_delay: Option<usize>,

View File

@ -112,6 +112,9 @@ pub(crate) struct YAMLConfig {
#[serde(default)] #[serde(default)]
pub win32_keyboard_layout_cache_interval: Option<i64>, pub win32_keyboard_layout_cache_interval: Option<i64>,
#[serde(default)]
pub x11_use_xclip_backend: Option<bool>,
// Include/Exclude // Include/Exclude
#[serde(default)] #[serde(default)]
pub includes: Option<Vec<String>>, pub includes: Option<Vec<String>>,
@ -201,6 +204,7 @@ impl TryFrom<YAMLConfig> for ParsedConfig {
win32_exclude_orphan_events: yaml_config.win32_exclude_orphan_events, win32_exclude_orphan_events: yaml_config.win32_exclude_orphan_events,
win32_keyboard_layout_cache_interval: yaml_config.win32_keyboard_layout_cache_interval, win32_keyboard_layout_cache_interval: yaml_config.win32_keyboard_layout_cache_interval,
x11_use_xclip_backend: yaml_config.x11_use_xclip_backend,
use_standard_includes: yaml_config.use_standard_includes, use_standard_includes: yaml_config.use_standard_includes,
includes: yaml_config.includes, includes: yaml_config.includes,
@ -258,6 +262,7 @@ mod tests {
secure_input_notification: false secure_input_notification: false
win32_exclude_orphan_events: false win32_exclude_orphan_events: false
win32_keyboard_layout_cache_interval: 300 win32_keyboard_layout_cache_interval: 300
x11_use_xclip_backend: true
use_standard_includes: true use_standard_includes: true
includes: ["test1"] includes: ["test1"]
@ -311,6 +316,7 @@ mod tests {
secure_input_notification: Some(false), secure_input_notification: Some(false),
win32_exclude_orphan_events: Some(false), win32_exclude_orphan_events: Some(false),
win32_keyboard_layout_cache_interval: Some(300), win32_keyboard_layout_cache_interval: Some(300),
x11_use_xclip_backend: Some(true),
pre_paste_delay: Some(300), pre_paste_delay: Some(300),
evdev_modifier_delay: Some(40), evdev_modifier_delay: Some(40),

View File

@ -330,6 +330,10 @@ impl Config for ResolvedConfig {
.win32_keyboard_layout_cache_interval .win32_keyboard_layout_cache_interval
.unwrap_or(2000) .unwrap_or(2000)
} }
fn x11_use_xclip_backend(&self) -> bool {
self.parsed.x11_use_xclip_backend.unwrap_or(false)
}
} }
impl ResolvedConfig { impl ResolvedConfig {
@ -413,6 +417,7 @@ impl ResolvedConfig {
secure_input_notification, secure_input_notification,
win32_exclude_orphan_events, win32_exclude_orphan_events,
win32_keyboard_layout_cache_interval, win32_keyboard_layout_cache_interval,
x11_use_xclip_backend,
includes, includes,
excludes, excludes,
extra_includes, extra_includes,

View File

@ -398,6 +398,10 @@ impl Config for LegacyInteropConfig {
fn win32_keyboard_layout_cache_interval(&self) -> i64 { fn win32_keyboard_layout_cache_interval(&self) -> i64 {
2000 2000
} }
fn x11_use_xclip_backend(&self) -> bool {
false
}
} }
struct LegacyMatchGroup { struct LegacyMatchGroup {