Пример #1
0
def regrab(changes):
    global __grabbed, __events

    cmodkeys = []
    for wid, modifiers, keycode, button in __grabbed:
        if keycode in changes:
            cmodkeys.append((wid, modifiers, keycode, button))

            keysym.ungrab_key(state.conn, wid, modifiers, keycode)
            keysym.grab_key(state.conn, wid, modifiers, changes[keycode])

            old = (modifiers, keycode, button)
            new = (modifiers, changes[keycode], button)
            for xevent in __events:
                for wid in __events[xevent]:
                    if old in __events[xevent][wid]:
                        __events[xevent][wid][new] = __events[xevent][wid][old]
                        del __events[xevent][wid][old]

    for wid, modifiers, keycode, button in cmodkeys:
        old = (wid, modifiers, keycode, button)
        new = (wid, modifiers, changes[keycode], button)

        __grabbed[new] = __grabbed[old]
        del __grabbed[old]
Пример #2
0
def regrab(changes):
    global __grabbed, __events

    cmodkeys = []
    for wid, modifiers, keycode, button in __grabbed:
        if keycode in changes:
            cmodkeys.append((wid, modifiers, keycode, button))

            keysym.ungrab_key(state.conn, wid, modifiers, keycode)
            keysym.grab_key(state.conn, wid, modifiers, changes[keycode])

            old = (modifiers, keycode, button)
            new = (modifiers, changes[keycode], button)
            for xevent in __events:
                for wid in __events[xevent]:
                    if old in __events[xevent][wid]:
                        __events[xevent][wid][new] = __events[xevent][wid][old]
                        del __events[xevent][wid][old]

    for wid, modifiers, keycode, button in cmodkeys:
        old = (wid, modifiers, keycode, button)
        new = (wid, modifiers, changes[keycode], button)

        __grabbed[new] = __grabbed[old]
        del __grabbed[old]
Пример #3
0
def __unregister_key(xevent, callback, wid, key_string):
    global __grabbed

    modifiers, keycode = __parse_keystring(key_string)
    modkey = (wid, modifiers, keycode, None)

    if not keycode:
        return False

    if not unregister_callback(xevent, callback, wid, modifiers, keycode,
                               None):
        return False

    if __grabbed[modkey] > 1:
        __grabbed[modkey] -= 1
    elif __grabbed[modkey] == 1:
        __grabbed[modkey] = 0

        if not keysym.ungrab_key(state.conn, wid, modifiers, keycode):
            return False
    else:
        return False

    return True
Пример #4
0
def __unregister_key(xevent, callback, wid, key_string):
    global __grabbed

    modifiers, keycode = __parse_keystring(key_string)
    modkey = (wid, modifiers, keycode, None)

    if not keycode:
        return False

    if not unregister_callback(xevent, callback, wid, modifiers, keycode,
                               None):
        return False

    if __grabbed[modkey] > 1:
        __grabbed[modkey] -= 1
    elif __grabbed[modkey] == 1:
        __grabbed[modkey] = 0

        if not keysym.ungrab_key(state.conn, wid, modifiers, keycode):
            return False
    else:
        return False

    return True