Exemple #1
0
    def parse_options(self, props):
        """ used by both process_hello and process_keymap
            to set the keyboard attributes """
        KeyboardConfigBase.parse_options(self, props)
        modded = {}

        def parse_option(name, parse_fn, *parse_args):
            prop = "xkbmap_%s" % name
            cv = getattr(self, prop)
            nv = parse_fn(prop, *parse_args)
            if cv != nv:
                setattr(self, prop, nv)
                modded[prop] = nv

        #plain strings:
        for x in ("print", "query"):
            parse_option(x, props.strget)
        #lists:
        parse_option("keycodes", props.listget)
        #dicts:
        for x in ("mod_meanings", "x11_keycodes", "query_struct"):
            parse_option(x, props.dictget, {})
        #lists of strings:
        for x in ("mod_managed", "mod_pointermissing"):
            parse_option(x, props.strlistget)
        parse_option("raw", props.boolget)
        #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", props.boolget,
                     bool(self.xkbmap_query or self.xkbmap_query_struct))
        log("assign_keymap_options(..) modified %s", modded)
        return len(modded) > 0
Exemple #2
0
    def __init__(self):
        KeyboardConfigBase.__init__(self)
        self.xkbmap_raw = False
        self.xkbmap_print = None
        self.xkbmap_query = None
        self.xkbmap_query_struct = None
        self.xkbmap_mod_meanings = {}
        self.xkbmap_mod_managed = []
        self.xkbmap_mod_pointermissing = []
        self.xkbmap_mod_nuisance = set(DEFAULT_MODIFIER_NUISANCE)
        self.xkbmap_keycodes = []
        self.xkbmap_x11_keycodes = []
        self.xkbmap_layout = None
        self.xkbmap_variant = None
        self.xkbmap_options = None
        self.xkbmap_layout_groups = False

        #this is shared between clients!
        self.keys_pressed = {}
        #these are derived by calling set_keymap:
        self.keynames_for_mod = {}
        self.keycode_translation = {}
        self.keycodes_for_modifier_keynames = {}
        self.modifier_client_keycodes = {}
        self.compute_modifier_map()
        self.modifiers_filter = []
        self.keycode_mappings = {}
 def parse_options(self, props):
     """ used by both process_hello and process_keymap
         to set the keyboard attributes """
     KeyboardConfigBase.parse_options(self, props)
     modded = []
     def parse_option(name, parse_fn):
         prop = "xkbmap_%s" % name
         cv = getattr(self, prop)
         nv = parse_fn(prop)
         if cv!=nv:
             setattr(self, prop, nv)
             modded.append(prop)
     #plain strings:
     for x in ("print", "query"):
         parse_option(x, props.strget)
     #lists:
     parse_option("keycodes", props.listget)
     #dicts:
     for x in ("mod_meanings", "x11_keycodes", "query_struct"):
         parse_option(x, props.dictget)
     #lists of strings:
     for x in ("mod_managed", "mod_pointermissing"):
         parse_option(x, props.strlistget)
     parse_option("raw", props.boolget)
     log("assign_keymap_options(..) modified %s", modded)
     return len(modded)>0
    def parse_options(self, props):
        """ used by both process_hello and process_keymap
            to set the keyboard attributes """
        KeyboardConfigBase.parse_options(self, props)
        modded = []

        def parse_option(name, parse_fn):
            prop = "xkbmap_%s" % name
            cv = getattr(self, prop)
            nv = parse_fn(prop)
            if cv != nv:
                setattr(self, prop, nv)
                modded.append(prop)

        #plain strings:
        for x in ("print", "query"):
            parse_option(x, props.strget)
        #lists:
        parse_option("keycodes", props.listget)
        #dicts:
        for x in ("mod_meanings", "x11_keycodes"):
            parse_option(x, props.dictget)
        #lists of strings:
        for x in ("mod_managed", "mod_pointermissing"):
            parse_option(x, props.strlistget)
        log("assign_keymap_options(..) modified %s", modded)
        return len(modded) > 0
 def parse_options(self, props):
     """ used by both process_hello and process_keymap
         to set the keyboard attributes """
     KeyboardConfigBase.parse_options(self, props)
     modded = []
     for x in ("print", "query", "mod_meanings", "mod_managed",
               "mod_pointermissing", "keycodes", "x11_keycodes"):
         prop = "xkbmap_%s" % x
         cv = getattr(self, prop)
         nv = props.get(prop)
         if cv != nv:
             setattr(self, prop, nv)
             modded.append(prop)
     log("assign_keymap_options(..) modified %s", modded)
     return len(modded) > 0
 def parse_options(self, props):
     """ used by both process_hello and process_keymap
         to set the keyboard attributes """
     KeyboardConfigBase.parse_options(self, props)
     modded = []
     for x in ("print", "query", "mod_meanings",
               "mod_managed", "mod_pointermissing",
               "keycodes", "x11_keycodes"):
         prop = "xkbmap_%s" % x
         cv = getattr(self, prop)
         nv = props.get(prop)
         if cv!=nv:
             setattr(self, prop, nv)
             modded.append(prop)
     log("assign_keymap_options(..) modified %s", modded)
     return len(modded)>0
Exemple #7
0
 def get_info(self):
     info = KeyboardConfigBase.get_info(self)
     #keycodes:
     if self.keycode_translation:
         ksinfo = info.setdefault("keysym", {})
         kssinf = info.setdefault("keysyms", {})
         kcinfo = info.setdefault("keycode", {})
         for kc, keycode in self.keycode_translation.items():
             if isinstance(kc, tuple):
                 a, b = kc
                 if isinstance(a, int):
                     client_keycode, keysym = a, b
                     ksinfo.setdefault(keysym, {})[client_keycode] = keycode
                     kcinfo.setdefault(client_keycode, {})[keysym] = keycode
                 elif isinstance(b, int):
                     keysym, index = a, b
                     kssinf.setdefault(keycode, []).append((index, keysym))
             else:
                 kcinfo[kc] = keycode
     if self.xkbmap_keycodes:
         i = 0
         kminfo = info.setdefault("keymap", {})
         for keyval, name, keycode, group, level in self.xkbmap_keycodes:
             kminfo[i] = (keyval, name, keycode, group, level)
             i += 1
     #modifiers:
     modinfo = {}
     modsinfo = {}
     modinfo["filter"] = self.modifiers_filter
     if self.modifier_client_keycodes:
         for mod, keys in self.modifier_client_keycodes.items():
             modinfo.setdefault(mod, {})["client_keys"] = keys
     if self.keynames_for_mod:
         for mod, keys in self.keynames_for_mod.items():
             modinfo.setdefault(mod, {})["keys"] = tuple(keys)
     if self.keycodes_for_modifier_keynames:
         for mod, keys in self.keycodes_for_modifier_keynames.items():
             modinfo.setdefault(mod, {})["keycodes"] = tuple(keys)
     if self.xkbmap_mod_meanings:
         for mod, mod_name in self.xkbmap_mod_meanings.items():
             modinfo[mod] = mod_name
     info["x11_keycode"] = self.xkbmap_x11_keycodes
     for x in ("print", "layout", "variant", "mod_managed",
               "mod_pointermissing", "raw", "layout_groups"):
         v = getattr(self, "xkbmap_%s" % x)
         if v:
             info[x] = v
     modsinfo["nuisance"] = tuple(self.xkbmap_mod_nuisance or [])
     info["modifier"] = modinfo
     info["modifiers"] = modsinfo
     #this would need to always run in the UI thread:
     #info["state"] = {
     #    "modifiers" : self.get_current_mask(),
     #    }
     log("keyboard info: %s", info)
     return info
 def get_hash(self):
     """
         This hash will be different whenever the keyboard configuration changes.
     """
     import hashlib
     m = hashlib.sha1()
     m.update(KeyboardConfigBase.get_hash(self))
     for x in (self.xkbmap_print, self.xkbmap_query, \
               self.xkbmap_mod_meanings, self.xkbmap_mod_pointermissing, \
               self.xkbmap_keycodes, self.xkbmap_x11_keycodes):
         m.update("/%s" % str(x))
     return "%s/%s/%s" % (self.xkbmap_layout, self.xkbmap_variant, m.hexdigest())
Exemple #9
0
    def __init__(self):
        KeyboardConfigBase.__init__(self)
        self.xkbmap_print = None
        self.xkbmap_query = None
        self.xkbmap_mod_meanings = {}
        self.xkbmap_mod_managed = []
        self.xkbmap_mod_pointermissing = []
        self.xkbmap_keycodes = []
        self.xkbmap_x11_keycodes = []
        self.xkbmap_layout = None
        self.xkbmap_variant = None

        #this is shared between clients!
        self.keys_pressed = {}
        #these are derived by calling set_keymap:
        self.keynames_for_mod = {}
        self.keycode_translation = {}
        self.keycodes_for_modifier_keynames = {}
        self.modifier_client_keycodes = {}
        self.compute_modifier_map()
        self.modifiers_filter = []
 def get_hash(self):
     """
         This hash will be different whenever the keyboard configuration changes.
     """
     import hashlib
     m = hashlib.sha1()
     m.update(KeyboardConfigBase.get_hash(self))
     for x in (self.xkbmap_print, self.xkbmap_query, \
               self.xkbmap_mod_meanings, self.xkbmap_mod_pointermissing, \
               self.xkbmap_keycodes, self.xkbmap_x11_keycodes):
         m.update("/%s" % str(x))
     return "%s/%s/%s" % (self.xkbmap_layout, self.xkbmap_variant, m.hexdigest())
 def get_info(self):
     info = KeyboardConfigBase.get_info(self)
     info["modifiers.filter"] = self.modifiers_filter
     #keycodes:
     if self.keycode_translation:
         for kc, keycode in self.keycode_translation.items():
             if type(kc) == tuple:
                 client_keycode, keysym = kc
                 info["keysym." + str(keysym) + "." +
                      str(client_keycode)] = keycode
                 info["keycode." + str(client_keycode) + "." +
                      keysym] = keycode
             else:
                 info["keysym." + str(kc)] = keycode
                 info["keycode." + str(kc)] = keycode
     if self.xkbmap_keycodes:
         i = 0
         for keyval, name, keycode, group, level in self.xkbmap_keycodes:
             info["keymap.%s" % i] = (keyval, name, keycode, group, level)
             i += 1
     #modifiers:
     if self.modifier_client_keycodes:
         for mod, keys in self.modifier_client_keycodes.items():
             info["modifier." + mod + ".client_keys"] = keys
     if self.keynames_for_mod:
         for mod, keys in self.keynames_for_mod.items():
             info["modifier." + mod + ".keys"] = tuple(keys)
     if self.keycodes_for_modifier_keynames:
         for mod, keys in self.keycodes_for_modifier_keynames.items():
             info["modifier." + mod + ".keycodes"] = tuple(keys)
     if self.xkbmap_mod_meanings:
         for mod, mod_name in self.xkbmap_mod_meanings.items():
             info["modifier." + mod] = mod_name
     if self.xkbmap_x11_keycodes:
         for keycode, keysyms in self.xkbmap_x11_keycodes.items():
             info["x11_keycode." + str(keycode)] = keysyms
     for x in ("print", "layout", "variant"):
         v = getattr(self, "xkbmap_" + x)
         if v:
             info[x] = v
     for x in ("nuisance", ):
         v = getattr(self, "xkbmap_mod_" + x)
         if v:
             info["modifiers." + x] = list(v)
     for x in ("managed", "pointermissing"):
         v = getattr(self, "xkbmap_mod_" + x)
         if v:
             info["modifiers." + x] = v
     log("keyboard info: %s",
         "\n".join(["%s=%s" % (k, v) for k, v in info.items()]))
     return info
 def get_info(self):
     info = KeyboardConfigBase.get_info(self)
     info["modifiers.filter"] = self.modifiers_filter
     #keycodes:
     if self.keycode_translation:
         for kc, keycode in self.keycode_translation.items():
             if type(kc)==tuple:
                 client_keycode, keysym = kc
                 info["keysym." + str(keysym)+"."+str(client_keycode)] = keycode
                 info["keycode." + str(client_keycode)+"."+keysym] = keycode
             else:
                 info["keysym." + str(kc)] = keycode
                 info["keycode." + str(kc)] = keycode
     if self.xkbmap_keycodes:
         i = 0
         for keyval, name, keycode, group, level in self.xkbmap_keycodes:
             info["keymap.%s" % i] = (keyval, name, keycode, group, level)
             i += 1
     #modifiers:
     if self.modifier_client_keycodes:
         for mod, keys in self.modifier_client_keycodes.items():
             info["modifier." + mod + ".client_keys"] = keys
     if self.keynames_for_mod:
         for mod, keys in self.keynames_for_mod.items():
             info["modifier." + mod + ".keys"] = tuple(keys)
     if self.keycodes_for_modifier_keynames:
         for mod, keys in self.keycodes_for_modifier_keynames.items():
             info["modifier." + mod + ".keycodes"] = tuple(keys)
     if self.xkbmap_mod_meanings:
         for mod, mod_name in self.xkbmap_mod_meanings.items():
             info["modifier." + mod ] = mod_name
     if self.xkbmap_x11_keycodes:
         for keycode, keysyms in self.xkbmap_x11_keycodes.items():
             info["x11_keycode." + str(keycode) ] = keysyms
     for x in ("print", "layout", "variant"):
         v = getattr(self, "xkbmap_"+x)
         if v:
             info[x] = v
     for x in ("nuisance", ):
         v = getattr(self, "xkbmap_mod_"+x)
         if v:
             info["modifiers."+x] = list(v)
     for x in ("managed", "pointermissing"):
         v = getattr(self, "xkbmap_mod_"+x)
         if v:
             info["modifiers."+x] = v
     log("keyboard info: %s", "\n".join(["%s=%s" % (k,v) for k,v in info.items()]))
     return info
 def get_info(self):
     info = KeyboardConfigBase.get_info(self)
     #keycodes:
     if self.keycode_translation:
         ksinfo = info.setdefault("keysym", {})
         kcinfo = info.setdefault("keycode", {})
         for kc, keycode in self.keycode_translation.items():
             if type(kc) == tuple:
                 client_keycode, keysym = kc
                 ksinfo.setdefault(keysym, {})[client_keycode] = keycode
                 kcinfo.setdefault(client_keycode, {})[keysym] = keycode
             else:
                 kcinfo[kc] = keycode
     if self.xkbmap_keycodes:
         i = 0
         kminfo = info.setdefault("keymap", {})
         for keyval, name, keycode, group, level in self.xkbmap_keycodes:
             kminfo[i] = (keyval, name, keycode, group, level)
             i += 1
     #modifiers:
     modinfo = {}
     modsinfo = {}
     modinfo["filter"] = self.modifiers_filter
     if self.modifier_client_keycodes:
         for mod, keys in self.modifier_client_keycodes.items():
             modinfo.setdefault(mod, {})["client_keys"] = keys
     if self.keynames_for_mod:
         for mod, keys in self.keynames_for_mod.items():
             modinfo.setdefault(mod, {})["keys"] = tuple(keys)
     if self.keycodes_for_modifier_keynames:
         for mod, keys in self.keycodes_for_modifier_keynames.items():
             modinfo.setdefault(mod, {})["keycodes"] = tuple(keys)
     if self.xkbmap_mod_meanings:
         for mod, mod_name in self.xkbmap_mod_meanings.items():
             modinfo[mod] = mod_name
     info["x11_keycode"] = self.xkbmap_x11_keycodes
     for x in ("print", "layout", "variant", "mod_managed",
               "mod_pointermissing", "raw", "layout_groups"):
         v = getattr(self, "xkbmap_%s" % x)
         if v:
             info[x] = v
     modsinfo["nuisance"] = tuple(self.xkbmap_mod_nuisance or [])
     info["modifier"] = modinfo
     info["modifiers"] = modsinfo
     log("keyboard info: %s", info)
     return info
 def get_info(self):
     info = KeyboardConfigBase.get_info(self)
     #keycodes:
     if self.keycode_translation:
         ksinfo = info.setdefault("keysym", {})
         kcinfo = info.setdefault("keycode", {})
         for kc, keycode in self.keycode_translation.items():
             if type(kc)==tuple:
                 client_keycode, keysym = kc
                 ksinfo.setdefault(keysym, {})[client_keycode] = keycode
                 kcinfo.setdefault(client_keycode, {})[keysym] = keycode
             else:
                 kcinfo[kc] = keycode
     if self.xkbmap_keycodes:
         i = 0
         kminfo = info.setdefault("keymap", {})
         for keyval, name, keycode, group, level in self.xkbmap_keycodes:
             kminfo[i] = (keyval, name, keycode, group, level)
             i += 1
     #modifiers:
     modinfo = {}
     modsinfo = {}
     modinfo["filter"] = self.modifiers_filter
     if self.modifier_client_keycodes:
         for mod, keys in self.modifier_client_keycodes.items():
             modinfo.setdefault(mod, {})["client_keys"] = keys
     if self.keynames_for_mod:
         for mod, keys in self.keynames_for_mod.items():
             modinfo.setdefault(mod, {})["keys"] = tuple(keys)
     if self.keycodes_for_modifier_keynames:
         for mod, keys in self.keycodes_for_modifier_keynames.items():
             modinfo.setdefault(mod, {})["keycodes"] = tuple(keys)
     if self.xkbmap_mod_meanings:
         for mod, mod_name in self.xkbmap_mod_meanings.items():
             modinfo[mod] = mod_name
     info["x11_keycode"] = self.xkbmap_x11_keycodes
     for x in ("print", "layout", "variant", "mod_managed", "mod_pointermissing", "raw"):
         v = getattr(self, "xkbmap_"+x)
         if v:
             info[x] = v
     modsinfo["nuisance"] = list(self.xkbmap_mod_nuisance or [])
     info["modifier"] = modinfo
     info["modifiers"] = modsinfo
     log("keyboard info: %s", info)
     return info
Exemple #15
0
 def get_hash(self):
     """
         This hash will be different whenever the keyboard configuration changes.
     """
     import hashlib
     m = hashlib.sha1()
     def hashadd(v):
         m.update(("/%s" % str(v)).encode("utf8"))
     m.update(KeyboardConfigBase.get_hash(self))
     for x in (self.xkbmap_print, self.xkbmap_query, self.xkbmap_raw, \
               self.xkbmap_mod_meanings, self.xkbmap_mod_pointermissing, \
               self.xkbmap_keycodes, self.xkbmap_x11_keycodes):
         hashadd(x)
     if self.xkbmap_query_struct:
         #flatten the dict in a predicatable order:
         for k in sorted(self.xkbmap_query_struct.keys()):
             hashadd(self.xkbmap_query_struct.get(k))
     return "%s/%s/%s/%s" % (self.xkbmap_layout, self.xkbmap_variant, self.xkbmap_options, m.hexdigest())
 def get_hash(self):
     """
         This hash will be different whenever the keyboard configuration changes.
     """
     import hashlib
     m = hashlib.sha1()
     def hashadd(v):
         m.update(("/%s" % str(v)).encode("utf8"))
     m.update(KeyboardConfigBase.get_hash(self))
     for x in (self.xkbmap_print, self.xkbmap_query, self.xkbmap_raw, \
               self.xkbmap_mod_meanings, self.xkbmap_mod_pointermissing, \
               self.xkbmap_keycodes, self.xkbmap_x11_keycodes):
         hashadd(x)
     if self.xkbmap_query_struct:
         #flatten the dict in a predicatable order:
         for k in sorted(self.xkbmap_query_struct.keys()):
             hashadd(self.xkbmap_query_struct.get(k))
     return "%s/%s/%s" % (self.xkbmap_layout, self.xkbmap_variant, m.hexdigest())
Exemple #17
0
 def __init__(self):
     KeyboardConfigBase.__init__(self)
Exemple #18
0
 def __init__(self):
     KeyboardConfigBase.__init__(self)
Exemple #19
0
 def get_info(self):
     info = KeyboardConfigBase.get_info(self)
     return info
Exemple #20
0
 def parse_options(self, props):
     return KeyboardConfigBase.parse_options(self, props)
Exemple #21
0
 def parse_options(self, props):
     return KeyboardConfigBase.parse_options(self, props)
Exemple #22
0
 def get_info(self):
     info = KeyboardConfigBase.get_info(self)
     return info