feat(config): add win32_exclude_orphan_events option

This commit is contained in:
Federico Terzi 2021-08-22 21:46:26 +02:00
parent 53eef3ce7b
commit 7eddfd1f12
5 changed files with 23 additions and 0 deletions

View File

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

View File

@ -44,6 +44,7 @@ pub(crate) struct ParsedConfig {
pub show_notifications: Option<bool>,
pub show_icon: Option<bool>,
pub secure_input_notification: Option<bool>,
pub win32_exclude_orphan_events: Option<bool>,
pub pre_paste_delay: Option<usize>,
pub restore_clipboard_delay: Option<usize>,

View File

@ -103,6 +103,9 @@ pub(crate) struct YAMLConfig {
#[serde(default)]
pub secure_input_notification: Option<bool>,
#[serde(default)]
pub win32_exclude_orphan_events: Option<bool>,
// Include/Exclude
#[serde(default)]
pub includes: Option<Vec<String>>,
@ -189,6 +192,8 @@ impl TryFrom<YAMLConfig> 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),

View File

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

View File

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