From f5b83a7d8b19d50f161ecb5d51d44d1e8a4babfc Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sat, 3 Aug 2024 12:34:35 +0700 Subject: [PATCH] try harder to find a matching key by name --- xpra/server/keyboard_config_base.py | 3 +++ xpra/x11/server_keyboard_config.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/xpra/server/keyboard_config_base.py b/xpra/server/keyboard_config_base.py index 784a5c98b6..9ce913676f 100644 --- a/xpra/server/keyboard_config_base.py +++ b/xpra/server/keyboard_config_base.py @@ -55,6 +55,9 @@ def get_keycode(self, client_keycode:int, keyname:str, pressed:bool, #del self.pressed_translation[client_keycode] return r keycode, group = self.do_get_keycode(client_keycode, keyname, pressed, modifiers, keyval, keystr, group) + if keycode < 0 and not keyname.islower(): + keyname = keyname.lower() + keycode, group = self.do_get_keycode(client_keycode, keyname, pressed, modifiers, keyval, keystr, group) if pressed and keycode not in (None, -1): #keep track of it, so we can unpress the same key: self.pressed_translation[client_keycode] = keycode, group diff --git a/xpra/x11/server_keyboard_config.py b/xpra/x11/server_keyboard_config.py index 74c7403c8e..3a135e6798 100644 --- a/xpra/x11/server_keyboard_config.py +++ b/xpra/x11/server_keyboard_config.py @@ -332,6 +332,7 @@ def set_keymap(self, translate_only:bool=False) -> None: if translate_only: self.keycode_translation = set_keycode_translation(self.x11_keycodes, self.keycodes) self.add_gtk_keynames() + self.add_loose_matches() self.compute_modifiers() self.compute_modifier_keynames() self.compute_client_modifier_keycodes() @@ -382,6 +383,7 @@ def set_keymap(self, translate_only:bool=False) -> None: log("keyname_for_mod=%s", self.keynames_for_mod) clean_keyboard_state() self.update_keycode_mappings() + self.add_loose_matches() def add_gtk_keynames(self) -> None: @@ -395,6 +397,12 @@ def add_gtk_keynames(self) -> None: if keyname in DEBUG_KEYSYMS: log.info("add_gtk_keynames: %s=%s", keyname, keycode) + def add_loose_matches(self) -> None: + # add lowercase versions of all keynames + for keyname, keycode in tuple(self.keycode_translation.items()): + if not keyname.islower(): + self.keycode_translation[keyname.lower()] = keycode + def set_default_keymap(self) -> None: """ assign a default keymap based on the current X11 server keymap