Skip to content

Commit

Permalink
#3592 move keymap to a substructure
Browse files Browse the repository at this point in the history
keep the old prefixed attributes present for backwards compatibility
  • Loading branch information
totaam committed Jul 22, 2022
1 parent 4cd332f commit f192c03
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
16 changes: 11 additions & 5 deletions xpra/client/keyboard_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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",
Expand All @@ -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


Expand Down
19 changes: 9 additions & 10 deletions xpra/client/ui_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit f192c03

Please sign in to comment.