Skip to content

Commit

Permalink
try harder to find a matching key by name
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Aug 3, 2024
1 parent c7accaf commit d9126ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions xpra/server/keyboard_config_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,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
Expand Down
8 changes: 8 additions & 0 deletions xpra/x11/server/keyboard_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ def set_keymap(self, translate_only=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()
Expand Down Expand Up @@ -388,6 +389,7 @@ def set_keymap(self, translate_only=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:
# add the keynames we find via gtk
Expand All @@ -400,6 +402,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
Expand Down

0 comments on commit d9126ae

Please sign in to comment.