# 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):


import logging
import functools
import pwm.atom
import pwm.windows
import pwm.workspaces
import pwm.keybind
import pwm.systray
import pwm.menu
import pwm.worker
from pwm.ffi.xcb import xcb, XcbError
    while not shutdown:
        try:
            ev = xcb.core.wait_for_event()
            if ev:
                pwm.worker.tasks.put(functools.partial(_handle, ev))
        except XcbError:
            logging.exception("XCB Error")


def _handle(event):
    etype = event.response_type & ~0x80

    if etype == xcb.MAP_REQUEST:
        event = xcb.ffi.cast("xcb_map_request_event_t*", event)
        pwm.windows.manage(event.window)

    elif etype == xcb.UNMAP_NOTIFY:
        event = xcb.ffi.cast("xcb_unmap_notify_event_t*", event)
        handle_unmap(event.window)

    elif etype == xcb.DESTROY_NOTIFY:
        event = xcb.ffi.cast("xcb_destroy_notify_event_t*", event)
        handle_unmap(event.window)

    elif etype == xcb.CONFIGURE_REQUEST:
        event = xcb.ffi.cast("xcb_configure_request_event_t*", event)
        logging.debug("CONFIGURE_REQUEST {}".format(event.window))
        handle_configure_request(event)

    elif etype == xcb.EXPOSE:

# 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/events.py
import logging
import functools
import pwm.atom
import pwm.windows
import pwm.workspaces
import pwm.keybind
import pwm.systray
import pwm.menu
import pwm.worker
from pwm.ffi.xcb import xcb, XcbError

    while not shutdown:
        try:
            ev = xcb.core.wait_for_event()
            if ev:
                pwm.worker.tasks.put(functools.partial(_handle, ev))
        except XcbError:
            logging.exception("XCB Error")


def _handle(event):
    etype = event.response_type & ~0x80

    if etype == xcb.MAP_REQUEST:
        event = xcb.ffi.cast("xcb_map_request_event_t*", event)
        pwm.windows.manage(event.window)

    elif etype == xcb.UNMAP_NOTIFY:
        event = xcb.ffi.cast("xcb_unmap_notify_event_t*", event)
        handle_unmap(event.window)

    elif etype == xcb.DESTROY_NOTIFY:
        event = xcb.ffi.cast("xcb_destroy_notify_event_t*", event)
        handle_unmap(event.window)

    elif etype == xcb.CONFIGURE_REQUEST:
        event = xcb.ffi.cast("xcb_configure_request_event_t*", event)
        logging.debug("CONFIGURE_REQUEST {}".format(event.window))
        handle_configure_request(event)

    elif etype == xcb.EXPOSE:

        event = xcb.ffi.cast("xcb_expose_event_t*", event)