Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
keycodes=[]
for i in range(0, 2**8):
entries = keymap.get_entries_for_keycode(i)
log("%s.get_entries_for_keycode(%s)=%s", keymap, i, entries)
if not entries:
continue
if is_gtk3():
found, keys, keyvals = entries
if not found:
continue
for i in range(len(keys)):
key = keys[i]
keyval = keyvals[i]
name = gdk.keyval_name(keyval)
if name not in ignore_keys:
keycodes.append((nn(keyval), nn(name), nn(key.keycode), nn(key.group), nn(key.level)))
else:
#gtk2:
for keyval, keycode, group, level in entries:
#assert keycode==i
name = gdk.keyval_name(keyval)
#ugly workaround for "period" key on win32 (see ticket 588)
#which is reported as "period" instead of "KP_Decimal",
#despite being on the numeric keypad just like all the other KP_* keys...
if name=="period" and keyval==46 and keycode==110:
name = "KP_Decimal"
elif name=="dead_tilde" and keyval==65107 and keycode==50:
name = "asciitilde"
elif name=="dead_grave" and keyval==65104 and keycode==55:
name = "grave"
if name not in ignore_keys:
keycodes.append((nn(keyval), nn(name), nn(keycode), nn(group), nn(level)))
def parse_key_event(self, event, pressed):
key_event = GTKKeyEvent()
key_event.modifiers = self._client.mask_to_names(event.state)
key_event.keyname = nn(gdk.keyval_name(event.keyval))
key_event.keyval = nn(event.keyval)
key_event.keycode = event.hardware_keycode
key_event.group = event.group
key_event.string = nn(event.string)
key_event.pressed = pressed
keylog("parse_key_event(%s, %s)=%s", event, pressed, key_event)
return key_event
def parse_key_event(self, event, pressed):
key_event = GTKKeyEvent()
key_event.modifiers = self._client.mask_to_names(event.state)
key_event.keyname = nn(gdk.keyval_name(event.keyval))
key_event.keyval = nn(event.keyval)
key_event.keycode = event.hardware_keycode
key_event.group = event.group
key_event.string = nn(event.string)
key_event.pressed = pressed
return key_event
def send_layout(self):
keylog("send_layout()")
self.send("layout-changed", nn(self.keyboard_helper.xkbmap_layout), nn(self.keyboard_helper.xkbmap_variant))
def get_keymap_properties(self):
props = {}
for x in ["xkbmap_print", "xkbmap_query", "xkbmap_mod_meanings",
"xkbmap_mod_managed", "xkbmap_mod_pointermissing", "xkbmap_keycodes", "xkbmap_x11_keycodes"]:
props[x] = nn(getattr(self, x))
return props