From f192c0312bc98360aec94e6aa92af90511259401 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Fri, 22 Jul 2022 17:38:59 -0400 Subject: [PATCH] #3592 move keymap to a substructure keep the old prefixed attributes present for backwards compatibility --- xpra/client/keyboard_helper.py | 16 +++++++++++----- xpra/client/ui_client_base.py | 19 +++++++++---------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/xpra/client/keyboard_helper.py b/xpra/client/keyboard_helper.py index e7f0b4d94e..bd78f3241e 100644 --- a/xpra/client/keyboard_helper.py +++ b/xpra/client/keyboard_helper.py @@ -313,7 +313,10 @@ def send_layout(self): def send_keymap(self): log("send_keymap()") - self.send("keymap-changed", self.get_keymap_properties()) + props = self.get_prefixed_keymap_properties() + #legacy format: flat with 'xkbmap_' prefix: + props["keymap"] = self.get_keymap_properties() + self.send("keymap-changed", props) def update_hash(self): @@ -335,6 +338,11 @@ def get_full_keymap(self): return [] + def get_prefixed_keymap_properties(self): + key_props = self.get_keymap_properties() + #legacy format: flat with 'xkbmap_' prefix: + return dict((f"xkbmap_{k}", v) for k, v in key_props.items()) + def get_keymap_properties(self): props = {} for x in ("layout", "layouts", "variant", "variants", @@ -343,10 +351,8 @@ def get_keymap_properties(self): "mod_managed", "mod_pointermissing", "keycodes", "x11_keycodes"): p = "xkbmap_%s" % x v = getattr(self, p) - #replace None with empty string: - if v is None: - v = "" - props[p] = v + if v: + props[x] = v return props diff --git a/xpra/client/ui_client_base.py b/xpra/client/ui_client_base.py index 0d4d22e75d..023f65f883 100644 --- a/xpra/client/ui_client_base.py +++ b/xpra/client/ui_client_base.py @@ -735,15 +735,21 @@ def send_keyboard_sync_enabled_status(self, *_args): # keyboard: def get_keyboard_caps(self): caps = {} - if self.readonly or not self.keyboard_helper: + kh = self.keyboard_helper + if self.readonly or not kh: #don't bother sending keyboard info, as it won't be used caps["keyboard"] = False else: - caps.update(self.get_keymap_properties()) + #legacy, unprefixed: + caps.update(kh.get_prefixed_keymap_properties()) + caps.update({ + "keyboard" : True, + "keymap" : kh.get_keymap_properties(), + "modifiers" :self.get_current_modifiers(), + }) #show the user a summary of what we have detected: self.keyboard_helper.log_keyboard_info() - caps["modifiers"] = self.get_current_modifiers() delay_ms, interval_ms = self.keyboard_helper.key_repeat_delay, self.keyboard_helper.key_repeat_interval if delay_ms>0 and interval_ms>0: caps["key_repeat"] = (delay_ms,interval_ms) @@ -761,13 +767,6 @@ def window_keyboard_layout_changed(self, window): if self.keyboard_helper: self.keyboard_helper.keymap_changed() - def get_keymap_properties(self): - if not self.keyboard_helper: - return {} - props = self.keyboard_helper.get_keymap_properties() - props["modifiers"] = self.get_current_modifiers() - return props - def handle_key_action(self, window, key_event): if self.readonly or self.keyboard_helper is None: return False