How to use the xcffib.xproto.KeyButMask function in xcffib

To help you get started, we’ve selected a few xcffib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github codito / pyqtkeybind / pyqtkeybind / x11 / keybindutil.py View on Github external
qtmods |= Qt.ControlModifier.real
        modifiers |= getattr(xproto.KeyButMask, "Control", 0)

    # Calculate the keys
    qtkeys = ks ^ qtmods
    key = QKeySequence(Qt.Key(qtkeys)).toString().lower()
    keycode = lookup_string(conn, key)
    return modifiers, keycode

    # Fallback logic
    modifiers = 0
    keycode = None

    key_string = "Shift+Control+A"
    for part in key_string.split('+'):
        if hasattr(xproto.KeyButMask, part):
            modifiers |= getattr(xproto.KeyButMask, part)
        else:
            if len(part) == 1:
                part = part.lower()
            keycode = lookup_string(conn, part)

    return modifiers, keycode
github codito / pyqtkeybind / pyqtkeybind / x11 / keybindutil.py View on Github external
modifiers |= getattr(xproto.KeyButMask, "Control", 0)

    # Calculate the keys
    qtkeys = ks ^ qtmods
    key = QKeySequence(Qt.Key(qtkeys)).toString().lower()
    keycode = lookup_string(conn, key)
    return modifiers, keycode

    # Fallback logic
    modifiers = 0
    keycode = None

    key_string = "Shift+Control+A"
    for part in key_string.split('+'):
        if hasattr(xproto.KeyButMask, part):
            modifiers |= getattr(xproto.KeyButMask, part)
        else:
            if len(part) == 1:
                part = part.lower()
            keycode = lookup_string(conn, part)

    return modifiers, keycode
github asrp / guitktk / wrap_event.py View on Github external
if keysym in unikeysym.keys else u""
            if event.char == unichr(0):
                event.char = ""
            event.mods = []
            for attrib in dir(KeyButMask):
                if not attrib.startswith("__"):
                    if event.state & getattr(KeyButMask, attrib):
                        event.mods.append(attrib.lower())
        elif event.type in [Event.mouse_press, Event.mouse_release]:
            event.button = event.detail
            event.xy = numpy.array([event.event_x, event.event_y])
            event.txy = numpy.linalg.solve(doc["drawing"].transform, numpy.append(event.xy, [1]))[:2]
            event.mods = []
            for attrib in dir(KeyButMask):
                if not attrib.startswith("__"):
                    if event.state & getattr(KeyButMask, attrib):
                        event.mods.append(attrib.lower())
            if event.type == Event.mouse_press and event.button == 1:
                startdrag = event.xy
            logger.info("Wrapped: %s", (event.__class__.__name__, event.button, event.xy, event.mods))
        elif event.type == Event.motion:
            event.xy = numpy.array([event.event_x, event.event_y])
            event.txy = numpy.linalg.solve(doc["drawing"].transform, numpy.append(event.xy, [1]))[:2]
            if event.state & EventMask.Button1Motion:
                event.drag_button = 1
            elif event.state & EventMask.Button2Motion:
                event.drag_button = 2
            elif event.state & EventMask.Button1Motion:
                event.drag_button = 3
            else:
                event.drag_button = None
            if event.drag_button:
github codito / pyqtkeybind / pyqtkeybind / x11 / keybindutil.py View on Github external
ret.append('Lock')
    if state & xproto.ModMask.Control:
        ret.append('Control')
    if state & xproto.ModMask._1:
        ret.append('Mod1')
    if state & xproto.ModMask._2:
        ret.append('Mod2')
    if state & xproto.ModMask._3:
        ret.append('Mod3')
    if state & xproto.ModMask._4:
        ret.append('Mod4')
    if state & xproto.ModMask._5:
        ret.append('Mod5')
    if state & xproto.KeyButMask.Button1:
        ret.append('Button1')
    if state & xproto.KeyButMask.Button2:
        ret.append('Button2')
    if state & xproto.KeyButMask.Button3:
        ret.append('Button3')
    if state & xproto.KeyButMask.Button4:
        ret.append('Button4')
    if state & xproto.KeyButMask.Button5:
        ret.append('Button5')

    return ret
github codito / pyqtkeybind / pyqtkeybind / x11 / keybindutil.py View on Github external
ret.append('Shift')
    if state & xproto.ModMask.Lock:
        ret.append('Lock')
    if state & xproto.ModMask.Control:
        ret.append('Control')
    if state & xproto.ModMask._1:
        ret.append('Mod1')
    if state & xproto.ModMask._2:
        ret.append('Mod2')
    if state & xproto.ModMask._3:
        ret.append('Mod3')
    if state & xproto.ModMask._4:
        ret.append('Mod4')
    if state & xproto.ModMask._5:
        ret.append('Mod5')
    if state & xproto.KeyButMask.Button1:
        ret.append('Button1')
    if state & xproto.KeyButMask.Button2:
        ret.append('Button2')
    if state & xproto.KeyButMask.Button3:
        ret.append('Button3')
    if state & xproto.KeyButMask.Button4:
        ret.append('Button4')
    if state & xproto.KeyButMask.Button5:
        ret.append('Button5')

    return ret
github asrp / guitktk / wrap_event.py View on Github external
def wrap_xcb_event(event, doc):
        global startdrag
        event.type = xcb_event.get(event.__class__, event.__class__)
        # Should include key_release!
        if event.type == Event.key_press:
            event.key_name = key_name(event.detail).lower()
            keysym = keybind.get_keysym(event.detail, event.state & 0b111)
            event.char = unikeysym.keys[keysym]["unicode"]\
                         if keysym in unikeysym.keys else u""
            if event.char == unichr(0):
                event.char = ""
            event.mods = []
            for attrib in dir(KeyButMask):
                if not attrib.startswith("__"):
                    if event.state & getattr(KeyButMask, attrib):
                        event.mods.append(attrib.lower())
        elif event.type in [Event.mouse_press, Event.mouse_release]:
            event.button = event.detail
            event.xy = numpy.array([event.event_x, event.event_y])
            event.txy = numpy.linalg.solve(doc["drawing"].transform, numpy.append(event.xy, [1]))[:2]
            event.mods = []
            for attrib in dir(KeyButMask):
                if not attrib.startswith("__"):
                    if event.state & getattr(KeyButMask, attrib):
                        event.mods.append(attrib.lower())
            if event.type == Event.mouse_press and event.button == 1:
                startdrag = event.xy
            logger.info("Wrapped: %s", (event.__class__.__name__, event.button, event.xy, event.mods))
        elif event.type == Event.motion: