コード例 #1
0
ファイル: keys.py プロジェクト: svn2github/Xpra
def get_gtk_keymap(ignore_keys=[None, "VoidSymbol"], add_if_missing=[]):
    """
        Augment the keymap we get from gtk.gdk.keymap_get_default()
        by adding the keyval_name.
        We can also ignore some keys
    """
    from wimpiggy.gobject_compat import import_gdk
    gdk = import_gdk()
    try:
        keymap = gdk.keymap_get_default()
    except:
        keymap = None
        return  []
    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)))
                if name in add_if_missing:
                    add_if_missing.remove(name)
    #TODO: do this server-side to ensure all modifiers can be set
    if add_if_missing:
        for name in add_if_missing:
            keycodes.append((0, name, 0, 0, 0))
    return keycodes
コード例 #2
0
def get_gtk_keymap(ignore_keys=[None, "VoidSymbol"], add_if_missing=[]):
    """
        Augment the keymap we get from gtk.gdk.keymap_get_default()
        by adding the keyval_name.
        We can also ignore some keys
    """
    from wimpiggy.gobject_compat import import_gdk
    gdk = import_gdk()
    try:
        keymap = gdk.keymap_get_default()
    except:
        keymap = None
        return []
    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)))
                if name in add_if_missing:
                    add_if_missing.remove(name)
    #TODO: do this server-side to ensure all modifiers can be set
    if add_if_missing:
        for name in add_if_missing:
            keycodes.append((0, name, -1, 0, 0))
    return keycodes
コード例 #3
0
ファイル: keys.py プロジェクト: rudresh2319/Xpra
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 wimpiggy.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
コード例 #4
0
ファイル: client.py プロジェクト: rudresh2319/Xpra
# This file is part of Parti.
# Copyright (C) 2011 Serviware (Arthur Huillet, <*****@*****.**>)
# Copyright (C) 2010-2012 Antoine Martin <*****@*****.**>
# Copyright (C) 2008, 2010 Nathaniel Smith <*****@*****.**>
# Parti is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

#pygtk3 vs pygtk2 (sigh)
from wimpiggy.gobject_compat import import_gobject, import_gtk, import_gdk, is_gtk3

gobject = import_gobject()
gtk = import_gtk()
gdk = import_gdk()
if is_gtk3():

    def get_root_size():
        return gdk.get_default_root_window().get_geometry()[2:]

    def set_windows_cursor(gtkwindows, new_cursor):
        pass
        #window.override_cursor(cursor, None)
else:

    def get_root_size():
        return gdk.get_default_root_window().get_size()

    def set_windows_cursor(gtkwindows, new_cursor):
        cursor = None
        if len(new_cursor) > 0:
            (_, _, w, h, xhot, yhot, serial, pixels) = new_cursor
            log.debug(
コード例 #5
0
ファイル: client.py プロジェクト: svn2github/Xpra
# This file is part of Parti.
# Copyright (C) 2011 Serviware (Arthur Huillet, <*****@*****.**>)
# Copyright (C) 2010-2012 Antoine Martin <*****@*****.**>
# Copyright (C) 2008, 2010 Nathaniel Smith <*****@*****.**>
# Parti is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

#pygtk3 vs pygtk2 (sigh)
from wimpiggy.gobject_compat import import_gobject, import_gtk, import_gdk, is_gtk3
gobject = import_gobject()
gtk = import_gtk()
gdk = import_gdk()
if is_gtk3():
    def get_root_size():
        return gdk.get_default_root_window().get_geometry()[2:]
    def set_windows_cursor(gtkwindows, new_cursor):
        pass
        #window.override_cursor(cursor, None)
else:
    def get_root_size():
        return gdk.get_default_root_window().get_size()
    def set_windows_cursor(gtkwindows, new_cursor):
        cursor = None
        if len(new_cursor)>0:
            (_, _, w, h, xhot, yhot, serial, pixels) = new_cursor
            log.debug("new cursor at %s,%s with serial=%s, dimensions: %sx%s, len(pixels)=%s" % (xhot,yhot, serial, w,h, len(pixels)))
            pixbuf = gdk.pixbuf_new_from_data(pixels, gdk.COLORSPACE_RGB, True, 8, w, h, w * 4)
            x = max(0, min(xhot, w-1))
            y = max(0, min(yhot, h-1))
            size = gdk.display_get_default().get_default_cursor_size()
            if size>0 and (size<w or size<h):