diff --git a/espanso-config/src/config/mod.rs b/espanso-config/src/config/mod.rs index c4385f2..d3d12da 100644 --- a/espanso-config/src/config/mod.rs +++ b/espanso-config/src/config/mod.rs @@ -108,6 +108,12 @@ pub trait Config: Send + Sync { // application is missing some key events. fn key_delay(&self) -> Option; + // Extra delay to apply when injecting modifiers under the EVDEV backend. + // This is useful on Wayland if espanso is injecting seemingly random + // cased letters, for example "Hi theRE1" instead of "Hi there!". + // Increase if necessary, decrease to speed up the injection. + fn evdev_modifier_delay(&self) -> Option; + // Chars that when pressed mark the start and end of a word. // Examples of this are . or , fn word_separators(&self) -> Vec; diff --git a/espanso-config/src/config/parse/mod.rs b/espanso-config/src/config/parse/mod.rs index adef3f7..00a21ab 100644 --- a/espanso-config/src/config/parse/mod.rs +++ b/espanso-config/src/config/parse/mod.rs @@ -52,6 +52,7 @@ pub(crate) struct ParsedConfig { pub inject_delay: Option, pub key_delay: Option, pub keyboard_layout: Option>, + pub evdev_modifier_delay: Option, // Includes pub includes: Option>, diff --git a/espanso-config/src/config/parse/yaml.rs b/espanso-config/src/config/parse/yaml.rs index b896dff..7d6234d 100644 --- a/espanso-config/src/config/parse/yaml.rs +++ b/espanso-config/src/config/parse/yaml.rs @@ -73,6 +73,9 @@ pub(crate) struct YAMLConfig { #[serde(default)] pub backspace_delay: Option, + #[serde(default)] + pub evdev_modifier_delay: Option, + #[serde(default)] pub word_separators: Option>, @@ -165,6 +168,7 @@ impl TryFrom for ParsedConfig { disable_x11_fast_inject: yaml_config.disable_x11_fast_inject, inject_delay: yaml_config.inject_delay, key_delay: yaml_config.key_delay.or(yaml_config.backspace_delay), + evdev_modifier_delay: yaml_config.evdev_modifier_delay, word_separators: yaml_config.word_separators, backspace_limit: yaml_config.backspace_limit, apply_patch: yaml_config.apply_patch, @@ -232,6 +236,7 @@ mod tests { inject_delay: 10 key_delay: 20 backspace_delay: 30 + evdev_modifier_delay: 40 word_separators: ["'", "."] backspace_limit: 10 apply_patch: false @@ -301,6 +306,7 @@ mod tests { win32_exclude_orphan_events: Some(false), pre_paste_delay: Some(300), + evdev_modifier_delay: Some(40), toggle_key: Some("CTRL".to_string()), word_separators: Some(vec!["'".to_owned(), ".".to_owned()]), diff --git a/espanso-config/src/config/resolve.rs b/espanso-config/src/config/resolve.rs index 5f12183..9a81380 100644 --- a/espanso-config/src/config/resolve.rs +++ b/espanso-config/src/config/resolve.rs @@ -17,16 +17,7 @@ * along with espanso. If not, see . */ -use super::{ - default::{ - DEFAULT_CLIPBOARD_THRESHOLD, DEFAULT_PRE_PASTE_DELAY, DEFAULT_RESTORE_CLIPBOARD_DELAY, - DEFAULT_SHORTCUT_EVENT_DELAY, - }, - parse::ParsedConfig, - path::calculate_paths, - util::os_matches, - AppProperties, Backend, Config, RMLVOConfig, ToggleKey, -}; +use super::{AppProperties, Backend, Config, RMLVOConfig, ToggleKey, default::{DEFAULT_CLIPBOARD_THRESHOLD, DEFAULT_PRE_PASTE_DELAY, DEFAULT_RESTORE_CLIPBOARD_DELAY, DEFAULT_SHORTCUT_EVENT_DELAY}, parse::ParsedConfig, path::calculate_paths, util::os_matches}; use crate::{counter::next_id, merge}; use anyhow::Result; use log::error; @@ -314,6 +305,10 @@ impl Config for ResolvedConfig { fn win32_exclude_orphan_events(&self) -> bool { self.parsed.win32_exclude_orphan_events.unwrap_or(true) } + + fn evdev_modifier_delay(&self) -> Option { + self.parsed.evdev_modifier_delay + } } impl ResolvedConfig { @@ -385,6 +380,7 @@ impl ResolvedConfig { toggle_key, inject_delay, key_delay, + evdev_modifier_delay, word_separators, backspace_limit, keyboard_layout, diff --git a/espanso-config/src/legacy/mod.rs b/espanso-config/src/legacy/mod.rs index 10fea96..9fcc2bf 100644 --- a/espanso-config/src/legacy/mod.rs +++ b/espanso-config/src/legacy/mod.rs @@ -390,6 +390,10 @@ impl Config for LegacyInteropConfig { fn win32_exclude_orphan_events(&self) -> bool { true } + + fn evdev_modifier_delay(&self) -> Option { + Some(10) + } } struct LegacyMatchGroup {