From 320637797862af635cbbcc7a2a2f48a9dee71979 Mon Sep 17 00:00:00 2001 From: Dasha Mukhina Date: Wed, 4 Sep 2024 21:23:54 +0400 Subject: [PATCH] fix(input): binds not working on non-Latin layouts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit KeysymHandle::raw_syms() returns typed symbols as-is. For example, if "Й" (Cyrillic letter 'Io', corresponding to "Q" on the English layout) is pressed, raw_syms() returns "Cyrillic_io". However, keybinds are usually defined as "+Q" (i.e., in Latin), which causes a mismatch. --- src/input/mod.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/input/mod.rs b/src/input/mod.rs index 449cf743..2929a560 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -65,7 +65,7 @@ use smithay::{ }, xwayland::X11Surface, }; -use tracing::{error, trace}; +use tracing::{error, trace, warn}; use xkbcommon::xkb::{Keycode, Keysym}; use std::{ @@ -483,7 +483,14 @@ impl State { // is this a normal binding? if binding.key.is_some() && state == KeyState::Pressed - && handle.raw_syms().contains(&binding.key.unwrap()) + && (handle.raw_syms().contains(&binding.key.unwrap()) || + // fallback to the Latin or current layout symbol + // if no binding is found for the current layout's key + handle.raw_latin_sym_or_raw_current_sym() + .unwrap_or_else(|| { + warn!("No keysym found for keypress {:?}: passing NoSymbol", handle); + Keysym::NoSymbol + }) == binding.key.unwrap()) && cosmic_modifiers_eq_smithay(&binding.modifiers, modifiers) { modifiers_queue.clear();