From 8d4137982c3250f1b590905019d0266ca7c3bff1 Mon Sep 17 00:00:00 2001 From: Marc Schreiber Date: Sat, 10 Feb 2024 21:27:13 +0100 Subject: [PATCH] Fix Emits of Additional ANSI Characters This commit ensures that ANSI chars won't be emitted when pressing non-standard modifier keys. Fixes #4975 --- window/src/os/x11/keyboard.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/window/src/os/x11/keyboard.rs b/window/src/os/x11/keyboard.rs index 8fd3edeee6e..87cce2ee45b 100644 --- a/window/src/os/x11/keyboard.rs +++ b/window/src/os/x11/keyboard.rs @@ -396,7 +396,13 @@ impl KeyboardWithFallback { } _ => sym, } - } else if kc.is_none() && key_code_from_sym.is_none() { + } else if kc.is_none() + && key_code_from_sym.is_none() + // Make sure that non-standard modifier keys of Neo2 layout are not mapped + // to a fallback because that would result in extra emitions of the + // original ANSI characters + && !Self::is_keysym_iso_modifier(xsym) + { // Not sure if this is a good idea, see // for context. match fallback_feed { @@ -457,6 +463,19 @@ impl KeyboardWithFallback { } } + fn is_keysym_iso_modifier(xsym: xkbcommon::xkb::Keysym) -> bool { + use xkbcommon::xkb::Keysym; + matches!( + xsym, + Keysym::ISO_Level3_Lock + | Keysym::ISO_Level3_Shift + | Keysym::ISO_Level5_Lock + | Keysym::ISO_Level5_Shift + | Keysym::ISO_Level3_Latch + | Keysym::ISO_Level5_Latch + ) + } + fn mod_is_active(&self, modifier: &str) -> bool { // [TODO] consider state Depressed & consumed mods self.selected