From e7e7d83885931586c0901d36d9898eceace4dfd6 Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Tue, 12 Apr 2022 21:38:16 +0200 Subject: [PATCH] feat(config): add options for alternative xdotool backend --- espanso-config/src/config/mod.rs | 6 ++++++ espanso-config/src/config/parse/mod.rs | 1 + espanso-config/src/config/parse/yaml.rs | 6 ++++++ espanso-config/src/config/resolve.rs | 5 +++++ espanso-config/src/legacy/mod.rs | 4 ++++ 5 files changed, 22 insertions(+) diff --git a/espanso-config/src/config/mod.rs b/espanso-config/src/config/mod.rs index 945841e..bab51d9 100644 --- a/espanso-config/src/config/mod.rs +++ b/espanso-config/src/config/mod.rs @@ -166,6 +166,10 @@ pub trait Config: Send + Sync { // the built-in native module on X11. fn x11_use_xclip_backend(&self) -> bool; + // If true, use an alternative injection backend based on the `xdotool` library. + // This might improve the situation for certain locales/layouts on X11. + fn x11_use_xdotool_backend(&self) -> bool; + // 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 // those from espanso, but might need to be disabled when using some software-level keyboards. @@ -212,6 +216,7 @@ pub trait Config: Send + Sync { secure_input_notification: {:?} x11_use_xclip_backend: {:?} + x11_use_xdotool_backend: {:?} win32_exclude_orphan_events: {:?} win32_keyboard_layout_cache_interval: {:?} @@ -246,6 +251,7 @@ pub trait Config: Send + Sync { self.secure_input_notification(), self.x11_use_xclip_backend(), + self.x11_use_xdotool_backend(), self.win32_exclude_orphan_events(), self.win32_keyboard_layout_cache_interval(), diff --git a/espanso-config/src/config/parse/mod.rs b/espanso-config/src/config/parse/mod.rs index 644b068..6f1d0c4 100644 --- a/espanso-config/src/config/parse/mod.rs +++ b/espanso-config/src/config/parse/mod.rs @@ -49,6 +49,7 @@ pub(crate) struct ParsedConfig { pub win32_exclude_orphan_events: Option, pub win32_keyboard_layout_cache_interval: Option, pub x11_use_xclip_backend: Option, + pub x11_use_xdotool_backend: Option, pub pre_paste_delay: Option, pub restore_clipboard_delay: Option, diff --git a/espanso-config/src/config/parse/yaml.rs b/espanso-config/src/config/parse/yaml.rs index 64558db..66605ad 100644 --- a/espanso-config/src/config/parse/yaml.rs +++ b/espanso-config/src/config/parse/yaml.rs @@ -121,6 +121,9 @@ pub(crate) struct YAMLConfig { #[serde(default)] pub x11_use_xclip_backend: Option, + #[serde(default)] + pub x11_use_xdotool_backend: Option, + // Include/Exclude #[serde(default)] pub includes: Option>, @@ -213,6 +216,7 @@ impl TryFrom for ParsedConfig { win32_exclude_orphan_events: yaml_config.win32_exclude_orphan_events, win32_keyboard_layout_cache_interval: yaml_config.win32_keyboard_layout_cache_interval, x11_use_xclip_backend: yaml_config.x11_use_xclip_backend, + x11_use_xdotool_backend: yaml_config.x11_use_xdotool_backend, use_standard_includes: yaml_config.use_standard_includes, includes: yaml_config.includes, @@ -273,6 +277,7 @@ mod tests { win32_exclude_orphan_events: false win32_keyboard_layout_cache_interval: 300 x11_use_xclip_backend: true + x11_use_xdotool_backend: true use_standard_includes: true includes: ["test1"] @@ -329,6 +334,7 @@ mod tests { win32_exclude_orphan_events: Some(false), win32_keyboard_layout_cache_interval: Some(300), x11_use_xclip_backend: Some(true), + x11_use_xdotool_backend: Some(true), pre_paste_delay: Some(300), evdev_modifier_delay: Some(40), diff --git a/espanso-config/src/config/resolve.rs b/espanso-config/src/config/resolve.rs index 7b7dcc3..352500c 100644 --- a/espanso-config/src/config/resolve.rs +++ b/espanso-config/src/config/resolve.rs @@ -331,6 +331,10 @@ impl Config for ResolvedConfig { fn x11_use_xclip_backend(&self) -> bool { self.parsed.x11_use_xclip_backend.unwrap_or(false) } + + fn x11_use_xdotool_backend(&self) -> bool { + self.parsed.x11_use_xdotool_backend.unwrap_or(false) + } } impl ResolvedConfig { @@ -417,6 +421,7 @@ impl ResolvedConfig { win32_exclude_orphan_events, win32_keyboard_layout_cache_interval, x11_use_xclip_backend, + x11_use_xdotool_backend, includes, excludes, extra_includes, diff --git a/espanso-config/src/legacy/mod.rs b/espanso-config/src/legacy/mod.rs index 24a94aa..3cdd8d7 100644 --- a/espanso-config/src/legacy/mod.rs +++ b/espanso-config/src/legacy/mod.rs @@ -410,6 +410,10 @@ impl Config for LegacyInteropConfig { fn x11_use_xclip_backend(&self) -> bool { false } + + fn x11_use_xdotool_backend(&self) -> bool { + false + } } struct LegacyMatchGroup {