Exemplo n.º 1
0
 def add_gtk_keynames(self):
     #add the keynames we find via gtk
     #since we may rely on finding those keynames from the client
     #(used with non native keymaps)
     log("add_gtk_keynames() gtk keymap=%s", get_gtk_keymap())
     for _, keyname, keycode, _, _ in get_gtk_keymap():
         if keyname not in self.keycode_translation:
             self.keycode_translation[keyname] = keycode
             if keyname in DEBUG_KEYSYMS:
                 log.info("add_gtk_keynames: %s=%s", keyname, keycode)
Exemplo n.º 2
0
 def add_gtk_keynames(self):
     #add the keynames we find via gtk
     #since we may rely on finding those keynames from the client
     #(used with non native keymaps)
     for _, keyname, keycode, _, _ in get_gtk_keymap():
         if keyname not in self.keycode_translation:
             self.keycode_translation[keyname] = keycode
Exemplo n.º 3
0
 def add_gtk_keynames(self):
     #add the keynames we find via gtk
     #since we may rely on finding those keynames from the client
     #(used with non native keymaps)
     for _, keyname, keycode, _, _ in get_gtk_keymap():
         if keyname not in self.keycode_translation:
             self.keycode_translation[keyname] = keycode
Exemplo n.º 4
0
 def set_default_keymap(self):
     """ assign a default keymap based on the current X11 server keymap
         sets up the translation tables so we can lookup keys without
         setting a client keymap.
     """
     if not self.enabled:
         return
     self.is_native_keymap = False
     clean_keyboard_state()
     #keycodes:
     keycode_to_keynames = X11Keyboard.get_keycode_mappings()
     self.keycode_translation = {}
     for keycode, keynames in keycode_to_keynames.items():
         for keyname in keynames:
             self.keycode_translation[keyname] = keycode
     #add the ones we find via gtk, since we may rely on finding those keynames from the client:
     for _, keyname, keycode, _, _ in get_gtk_keymap():
         if keyname not in self.keycode_translation:
             self.keycode_translation[keyname] = keycode
     log("set_default_keymap: keycode_translation=%s", self.keycode_translation)
     #modifiers:
     self.keynames_for_mod = {}
     #ie: {'control': [(37, 'Control_L'), (105, 'Control_R')], ...}
     mod_mappings = X11Keyboard.get_modifier_mappings()
     log("set_default_keymap: using modifier mappings=%s", mod_mappings)
     for modifier, mappings in mod_mappings.items():
         keynames = []
         for m in mappings:      #ie: (37, 'Control_L'), (105, 'Control_R')
             if len(m)==2: 
                 keynames.append(m[1])   #ie: 'Control_L'
         self.keynames_for_mod[modifier] = set(keynames)
     self.compute_modifier_keynames()
     log("set_default_keymap: keynames_for_mod=%s", self.keynames_for_mod)
     log("set_default_keymap: keycodes_for_modifier_keynames=%s", self.keycodes_for_modifier_keynames)
     log("set_default_keymap: modifier_map=%s", self.modifier_map)
Exemplo n.º 5
0
 def add_gtk_keynames(self):
     #add the keynames we find via gtk
     #since we may rely on finding those keynames from the client
     #(used with non native keymaps)
     for _, keyname, keycode, _, _ in get_gtk_keymap():
         if keyname not in self.keycode_translation:
             self.keycode_translation[keyname] = keycode
             if keyname in DEBUG_KEYSYMS:
                 log.info("add_gtk_keynames: %s=%s", keyname, keycode)
     #some keys may still be missing with GTK2:
     for keyname, equiv in {
             "dead_perispomeni": "dead_tilde",
     }.items():
         if keyname not in self.keycode_translation:
             keycode = self.keycode_translation.get(equiv)
             if keycode:
                 self.keycode_translation[keyname] = keycode
                 if keyname in DEBUG_KEYSYMS:
                     log.info("add_gtk_keynames: %s=%s", keyname, keycode)
Exemplo n.º 6
0
 def set_default_keymap(self):
     """ assign a default keymap based on the current X11 server keymap
         sets up the translation tables so we can lookup keys without
         setting a client keymap.
     """
     if not self.enabled:
         return
     self.is_native_keymap = False
     clean_keyboard_state()
     #keycodes:
     keycode_to_keynames = X11Keyboard.get_keycode_mappings()
     self.keycode_translation = {}
     for keycode, keynames in keycode_to_keynames.items():
         for keyname in keynames:
             self.keycode_translation[keyname] = keycode
     #add the ones we find via gtk, since we may rely on finding those keynames from the client:
     for _, keyname, keycode, _, _ in get_gtk_keymap():
         if keyname not in self.keycode_translation:
             self.keycode_translation[keyname] = keycode
     log("set_default_keymap: keycode_translation=%s",
         self.keycode_translation)
     #modifiers:
     self.keynames_for_mod = {}
     #ie: {'control': [(37, 'Control_L'), (105, 'Control_R')], ...}
     mod_mappings = X11Keyboard.get_modifier_mappings()
     log("set_default_keymap: using modifier mappings=%s", mod_mappings)
     for modifier, mappings in mod_mappings.items():
         keynames = []
         for m in mappings:  #ie: (37, 'Control_L'), (105, 'Control_R')
             if len(m) == 2:
                 keynames.append(m[1])  #ie: 'Control_L'
         self.keynames_for_mod[modifier] = set(keynames)
     self.compute_modifier_keynames()
     log("set_default_keymap: keynames_for_mod=%s", self.keynames_for_mod)
     log("set_default_keymap: keycodes_for_modifier_keynames=%s",
         self.keycodes_for_modifier_keynames)
     log("set_default_keymap: modifier_map=%s", self.modifier_map)
Exemplo n.º 7
0
 def get_full_keymap(self):
     return get_gtk_keymap()
Exemplo n.º 8
0
 def test_get_gtk_keymap(self):
     assert not do_get_gtk_keymap(None, ())
     if not POSIX or os.environ.get("DISPLAY"):
         assert get_gtk_keymap()
Exemplo n.º 9
0
 def get_full_keymap(self):
     return  get_gtk_keymap()