diff --git a/espanso-config/src/config/mod.rs b/espanso-config/src/config/mod.rs index a7d552c..c4385f2 100644 --- a/espanso-config/src/config/mod.rs +++ b/espanso-config/src/config/mod.rs @@ -144,6 +144,12 @@ pub trait Config: Send + Sync { // If false, avoid showing the SecureInput notification on macOS fn secure_input_notification(&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. + // Disabling this option might conflict with the undo feature. + fn win32_exclude_orphan_events(&self) -> bool; + fn is_match<'a>(&self, app: &AppProperties<'a>) -> bool; fn pretty_dump(&self) -> String { diff --git a/espanso-config/src/config/parse/mod.rs b/espanso-config/src/config/parse/mod.rs index d8f49fb..adef3f7 100644 --- a/espanso-config/src/config/parse/mod.rs +++ b/espanso-config/src/config/parse/mod.rs @@ -44,6 +44,7 @@ pub(crate) struct ParsedConfig { pub show_notifications: Option, pub show_icon: Option, pub secure_input_notification: Option, + pub win32_exclude_orphan_events: 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 18fcdd9..b896dff 100644 --- a/espanso-config/src/config/parse/yaml.rs +++ b/espanso-config/src/config/parse/yaml.rs @@ -103,6 +103,9 @@ pub(crate) struct YAMLConfig { #[serde(default)] pub secure_input_notification: Option, + #[serde(default)] + pub win32_exclude_orphan_events: Option, + // Include/Exclude #[serde(default)] pub includes: Option>, @@ -189,6 +192,8 @@ impl TryFrom for ParsedConfig { restore_clipboard_delay: yaml_config.restore_clipboard_delay, paste_shortcut_event_delay: yaml_config.paste_shortcut_event_delay, + win32_exclude_orphan_events: yaml_config.win32_exclude_orphan_events, + use_standard_includes: yaml_config.use_standard_includes, includes: yaml_config.includes, extra_includes: yaml_config.extra_includes, @@ -242,6 +247,7 @@ mod tests { show_icon: false show_notifications: false secure_input_notification: false + win32_exclude_orphan_events: false use_standard_includes: true includes: ["test1"] @@ -292,6 +298,7 @@ mod tests { show_icon: Some(false), show_notifications: Some(false), secure_input_notification: Some(false), + win32_exclude_orphan_events: Some(false), pre_paste_delay: Some(300), diff --git a/espanso-config/src/config/resolve.rs b/espanso-config/src/config/resolve.rs index 3db8eb4..5f12183 100644 --- a/espanso-config/src/config/resolve.rs +++ b/espanso-config/src/config/resolve.rs @@ -310,6 +310,10 @@ impl Config for ResolvedConfig { fn secure_input_notification(&self) -> bool { self.parsed.secure_input_notification.unwrap_or(true) } + + fn win32_exclude_orphan_events(&self) -> bool { + self.parsed.win32_exclude_orphan_events.unwrap_or(true) + } } impl ResolvedConfig { @@ -390,6 +394,7 @@ impl ResolvedConfig { show_icon, show_notifications, secure_input_notification, + win32_exclude_orphan_events, includes, excludes, extra_includes, diff --git a/espanso-config/src/legacy/mod.rs b/espanso-config/src/legacy/mod.rs index d059358..d7a9dbc 100644 --- a/espanso-config/src/legacy/mod.rs +++ b/espanso-config/src/legacy/mod.rs @@ -386,6 +386,10 @@ impl Config for LegacyInteropConfig { fn enable(&self) -> bool { self.config.enable_active } + + fn win32_exclude_orphan_events(&self) -> bool { + true + } } struct LegacyMatchGroup {