feat(config): add options for alternative xdotool backend

This commit is contained in:
Federico Terzi 2022-04-12 21:38:16 +02:00
parent bf35a80d4d
commit e7e7d83885
5 changed files with 22 additions and 0 deletions

View File

@ -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(),

View File

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

View File

@ -121,6 +121,9 @@ pub(crate) struct YAMLConfig {
#[serde(default)]
pub x11_use_xclip_backend: Option<bool>,
#[serde(default)]
pub x11_use_xdotool_backend: Option<bool>,
// Include/Exclude
#[serde(default)]
pub includes: Option<Vec<String>>,
@ -213,6 +216,7 @@ impl TryFrom<YAMLConfig> 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),

View File

@ -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,

View File

@ -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 {