# Path: pwm/ffi/xcb.py
# class XcbError(Exception):
# class Cookie:
# class Xcb:
#     def __init__(self, error):
#     def __str__(self):
#     def __init__(self, name, value):
#     def __getattr__(self, name):
#     def reply(self):
#     def check(self):
#     def __init__(self):
#     def __getattr__(self, name):
#         def request(func, *args, **kwargs):
#     def connect(self, display=None):
#     def mask(self, masks):
# 
# Path: pwm/ffi/xcb.py
# class XcbError(Exception):
#     def __init__(self, error):
#         self.error = error
# 
#     def __str__(self):
#         label = xcb.event_get_error_label(self.error.response_type)
#         return "{}, type {}, code {}, major {}, minor {}".format(
#             xcb.ffi.string(label).decode("UTF-8"),
#             self.error.response_type, self.error.error_code,
#             self.error.major_code, self.error.minor_code)
# 
# Path: pwm/keysyms.py



from collections import defaultdict
from pwm.ffi.xcb import xcb
from pwm.ffi.xcb import XcbError
from pwm.keysyms import keysyms, keysym_strings
import re
    :rtype: xcb.xproto.ModMask
    """
    return __keysmods.get(keycode, 0)


def get_keys_to_mods():
    """
    Fetches and creates the keycode -> modifier mask mapping. Typically, you
    shouldn't have to use this---xpybutil will keep this up to date if it
    changes.

    This function may be useful in that it should closely replicate the output
    of the ``xmodmap`` command. For example:

     ::

        keymods = get_keys_to_mods()
        for kc in sorted(keymods, key=lambda kc: keymods[kc]):
            print keymods[kc], hex(kc), get_keysym_string(get_keysym(kc))

    Which will very closely replicate ``xmodmap``. I'm not getting precise
    results quite yet, but I do believe I'm getting at least most of what
    matters. (i.e., ``xmodmap`` returns valid keysym strings for some that
    I cannot.)

    :return: A dict mapping from keycode to modifier mask.
    :rtype: dict
    """
    modmasks = [xcb.MOD_MASK_SHIFT, xcb.MOD_MASK_LOCK, xcb.MOD_MASK_CONTROL,
                xcb.MOD_MASK_1, xcb.MOD_MASK_2, xcb.MOD_MASK_3,

# Path: pwm/ffi/xcb.py
# class XcbError(Exception):
# class Cookie:
# class Xcb:
#     def __init__(self, error):
#     def __str__(self):
#     def __init__(self, name, value):
#     def __getattr__(self, name):
#     def reply(self):
#     def check(self):
#     def __init__(self):
#     def __getattr__(self, name):
#         def request(func, *args, **kwargs):
#     def connect(self, display=None):
#     def mask(self, masks):
# 
# Path: pwm/ffi/xcb.py
# class XcbError(Exception):
#     def __init__(self, error):
#         self.error = error
# 
#     def __str__(self):
#         label = xcb.event_get_error_label(self.error.response_type)
#         return "{}, type {}, code {}, major {}, minor {}".format(
#             xcb.ffi.string(label).decode("UTF-8"),
#             self.error.response_type, self.error.error_code,
#             self.error.major_code, self.error.minor_code)
# 
# Path: pwm/keysyms.py



# Path: pwm/keybind.py
from collections import defaultdict
from pwm.ffi.xcb import xcb
from pwm.ffi.xcb import XcbError
from pwm.keysyms import keysyms, keysym_strings
import re

    :rtype: xcb.xproto.ModMask
    """
    return __keysmods.get(keycode, 0)


def get_keys_to_mods():
    """
    Fetches and creates the keycode -> modifier mask mapping. Typically, you
    shouldn't have to use this---xpybutil will keep this up to date if it
    changes.

    This function may be useful in that it should closely replicate the output
    of the ``xmodmap`` command. For example:

     ::

        keymods = get_keys_to_mods()
        for kc in sorted(keymods, key=lambda kc: keymods[kc]):
            print keymods[kc], hex(kc), get_keysym_string(get_keysym(kc))

    Which will very closely replicate ``xmodmap``. I'm not getting precise
    results quite yet, but I do believe I'm getting at least most of what
    matters. (i.e., ``xmodmap`` returns valid keysym strings for some that
    I cannot.)

    :return: A dict mapping from keycode to modifier mask.
    :rtype: dict
    """
    modmasks = [xcb.MOD_MASK_SHIFT, xcb.MOD_MASK_LOCK, xcb.MOD_MASK_CONTROL,
                xcb.MOD_MASK_1, xcb.MOD_MASK_2, xcb.MOD_MASK_3,

                xcb.MOD_MASK_4, xcb.MOD_MASK_5]  # order matters