Skip to content

Commit

Permalink
#3592 remove unstructured setxkbmap query data from server
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Jul 23, 2022
1 parent f501bd8 commit e7066cd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
17 changes: 6 additions & 11 deletions xpra/x11/server_keyboard_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class KeyboardConfig(KeyboardConfigBase):
def __init__(self):
super().__init__()
self.xkbmap_raw = False
self.xkbmap_query = None
self.xkbmap_query_struct = None
self.xkbmap_mod_meanings = {}
self.xkbmap_mod_managed = []
Expand Down Expand Up @@ -150,9 +149,6 @@ def parse_option(name, parse_fn, old_parse_fn, *parse_args):
if cv!=nv:
setattr(self, f"xkbmap_{name}", nv)
modded[name] = nv
#plain strings:
for x in ("query", ):
parse_option(x, keymap_dict.strget, props.strget)
#lists:
parse_option("keycodes", keymap_dict.tupleget, props.tupleget)
#dicts:
Expand All @@ -165,7 +161,7 @@ def parse_option(name, parse_fn, old_parse_fn, *parse_args):
#older clients don't specify if they support layout groups safely
#(MS Windows clients used base-1)
#so only enable it by default for X11 clients
parse_option("layout_groups", keymap_dict.boolget, props.boolget, bool(self.xkbmap_query or self.xkbmap_query_struct))
parse_option("layout_groups", keymap_dict.boolget, props.boolget, bool(self.xkbmap_query_struct))
log("assign_keymap_options(..) modified %s", modded)
return len(modded)>0

Expand All @@ -188,7 +184,7 @@ def get_hash(self):
def hashadd(v):
m.update(("/%s" % str(v)).encode("utf8"))
m.update(super().get_hash())
for x in (self.xkbmap_query, self.xkbmap_raw, \
for x in (self.xkbmap_raw, \
self.xkbmap_mod_meanings, self.xkbmap_mod_pointermissing, \
self.xkbmap_keycodes, self.xkbmap_x11_keycodes):
hashadd(x)
Expand Down Expand Up @@ -328,9 +324,8 @@ def set_layout(self, layout, variant, options):
def set_keymap(self, translate_only=False):
if not self.enabled:
return
log("set_keymap(%s) layout=%r, variant=%r, options=%r, query=%r",
translate_only, self.xkbmap_layout, self.xkbmap_variant, self.xkbmap_options,
self.xkbmap_query)
log("set_keymap(%s) layout=%r, variant=%r, options=%r, query-struct=%r",
translate_only, self.xkbmap_layout, self.xkbmap_variant, self.xkbmap_options, self.xkbmap_query_struct)
if translate_only:
self.keycode_translation = set_keycode_translation(self.xkbmap_x11_keycodes, self.xkbmap_keycodes)
self.add_gtk_keynames()
Expand Down Expand Up @@ -360,7 +355,7 @@ def set_keymap(self, translate_only=False):
#on the keycode mappings (at least for the from_keycodes case):
self.compute_modifiers()
#key translation:
if bool(self.xkbmap_query):
if bool(self.xkbmap_query_struct):
#native full mapping of all keycodes:
self.keycode_translation = set_all_keycodes(self.xkbmap_x11_keycodes, self.xkbmap_keycodes, False, self.keynames_for_mod)
else:
Expand Down Expand Up @@ -465,7 +460,7 @@ def do_get_keycode(self, client_keycode, keyname, pressed, modifiers, keyval, ke
return -1, group
if self.xkbmap_raw:
return client_keycode, group
if self.xkbmap_query:
if self.xkbmap_query_struct:
keycode = self.keycode_translation.get((client_keycode, keyname)) or client_keycode
self.kmlog(keyname, "do_get_keycode (%i, %s)=%s (native keymap)", client_keycode, keyname, keycode)
return keycode, group
Expand Down
5 changes: 2 additions & 3 deletions xpra/x11/xkbhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ def clean_keyboard_state():
def do_set_keymap(xkbmap_layout, xkbmap_variant, xkbmap_options, xkbmap_query_struct):
""" xkbmap_layout is the generic layout name (used on non posix platforms)
xkbmap_variant is the layout variant (may not be set)
xkbmap_print is the output of "setxkbmap -print" on the client
xkbmap_query is the output of "setxkbmap -query" on the client
xkbmap_query_struct is xkbmap_query parsed into a dictionary
xkbmap_query_struct is the output of "setxkbmap -query" on the client
parsed into a dictionary
Use those to try to setup the correct keyboard map for the client
so that all the keycodes sent will be mapped
"""
Expand Down

0 comments on commit e7066cd

Please sign in to comment.