def compute_modifier_keynames(self): self.keycodes_for_modifier_keynames = {} self.xkbmap_mod_nuisance = set(DEFAULT_MODIFIER_NUISANCE) display = display_get_default() keymap = keymap_get_for_display(display) gdk = import_gdk() if self.keynames_for_mod: for modifier, keynames in self.keynames_for_mod.items(): for keyname in keynames: if keyname in DEFAULT_MODIFIER_NUISANCE_KEYNAMES: self.xkbmap_mod_nuisance.add(modifier) keyval = gdk.keyval_from_name(bytestostr(keyname)) if keyval == 0: log.error( "Error: no keyval found for keyname '%s' (modifier '%s')", keyname, modifier) return [] entries = keymap.get_entries_for_keyval(keyval) if entries: keycodes = [] if is_gtk3(): if entries[0] is True: keycodes = [ entry.keycode for entry in entries[1] ] else: keycodes = [entry[0] for entry in entries] for keycode in keycodes: l = self.keycodes_for_modifier_keynames.setdefault( keyname, []) if keycode not in l: l.append(keycode) log("compute_modifier_keynames: keycodes_for_modifier_keynames=%s", self.keycodes_for_modifier_keynames)
def get_gtk_keymap(ignore_keys=[None, "VoidSymbol"]): """ Augment the keymap we get from gtk.gdk.keymap_get_default() by adding the keyval_name. We can also ignore some keys """ from xpra.gtk_common.gobject_compat import import_gdk gdk = import_gdk() try: keymap = gdk.keymap_get_default() except: keymap = None return [] keycodes=[] used_keycodes = [] max_entries = 1 for i in range(0, 2**8): entries = keymap.get_entries_for_keycode(i) if entries: max_entries = max(max_entries, len(entries)) for keyval, keycode, group, level in entries: name = gdk.keyval_name(keyval) if name not in ignore_keys: keycodes.append((nn(keyval), nn(name), nn(keycode), nn(group), nn(level))) used_keycodes.append(keycode) return keycodes
def get_gtk_keymap(ignore_keys=[None, "VoidSymbol"]): """ Augment the keymap we get from gtk.gdk.keymap_get_default() by adding the keyval_name. We can also ignore some keys """ from xpra.gtk_common.gobject_compat import import_gdk gdk = import_gdk() try: keymap = gdk.keymap_get_default() except: keymap = None return [] keycodes = [] used_keycodes = [] max_entries = 1 for i in range(0, 2**8): entries = keymap.get_entries_for_keycode(i) if entries: max_entries = max(max_entries, len(entries)) for keyval, keycode, group, level in entries: name = gdk.keyval_name(keyval) if name not in ignore_keys: keycodes.append((nn(keyval), nn(name), nn(keycode), nn(group), nn(level))) used_keycodes.append(keycode) return keycodes
def __repr__(self): from xpra.gtk_common.gobject_compat import import_gdk gdk = import_gdk() d = {} for k,v in self.__dict__.items(): if k=="name": continue elif k=="serial": d[k] = "%#x" % v elif v and type(v)==gdk.Window: d[k] = "%#x" % v.xid elif v and type(v)==gdk.Display: d[k] = "%s" % v.get_name() else: d[k] = v return "<X11:%s %r>" % (self.name, d)
# This file is part of Xpra. # Copyright (C) 2010 Nathaniel Smith <*****@*****.**> # Copyright (C) 2011-2018 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. # A tray implemented using gtk.StatusIcon import os from xpra.os_util import WIN32, OSX, POSIX, PYTHON3, monotonic_time from xpra.util import envbool from xpra.gtk_common.gobject_compat import import_gtk, import_gdk gtk = import_gtk() gdk = import_gdk() from xpra.client.tray_base import TrayBase, log from xpra.gtk_common.gtk_util import get_icon_from_file, get_pixbuf_from_data, get_default_root_window, \ INTERP_HYPER, SHIFT_MASK, ORIENTATION_VERTICAL, ORIENTATION_HORIZONTAL ORIENTATION = { ORIENTATION_HORIZONTAL: "HORIZONTAL", ORIENTATION_VERTICAL: "VERTICAL", } GUESS_GEOMETRY = WIN32 or OSX GUESS_GEOMETRY = envbool("XPRA_GUESS_ICON_GEOMETRY", GUESS_GEOMETRY) log("tray GUESS_GEOMETRY=%s", GUESS_GEOMETRY) class GTKStatusIconTray(TrayBase): def __init__(self, *args, **kwargs):
#!/usr/bin/env python # This file is part of Xpra. # Copyright (C) 2011-2014 Antoine Martin <*****@*****.**> from xpra.gtk_common.gobject_compat import import_gtk, import_gdk, is_gtk3, import_pango, import_gobject from xpra.gtk_common.gtk_util import SHIFT_MASK, LOCK_MASK, CONTROL_MASK, MOD1_MASK, MOD2_MASK, MOD3_MASK, MOD4_MASK, MOD5_MASK import sys gtk = import_gtk() gdk = import_gdk() pango = import_pango() gobject = import_gobject() from xpra.deque import maxdeque from xpra.platform.paths import get_icon from xpra.gtk_common import gtk_util assert gtk_util, "cannot load compat class" modifier_names = { SHIFT_MASK : "Shift", LOCK_MASK : "Lock", CONTROL_MASK : "Control", MOD1_MASK : "mod1", MOD2_MASK : "mod2", MOD3_MASK : "mod3", MOD4_MASK : "mod4", MOD5_MASK : "mod5" } short_modifier_names = { SHIFT_MASK : "S",