# 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 pwm.windows
import pwm.atom
from pwm.ffi.xcb import xcb
              xcb.EVENT_MASK_LEAVE_WINDOW)


def setup():
    """Setup the root window."""

    cookie = xcb.core.change_window_attributes_checked(
        xcb.screen.root,
        *xcb.mask([(xcb.CW_EVENT_MASK, EVENT_MASK)]))

    cookie.check()

    try:
        # We have to set the cursor now, otherwise it will not show up until
        # the first client is launched.
        set_cursor(Cursor.left_ptr)
    except:
        logging.exception("Root cursor error")

    try:
        _set_properties()
    except:
        logging.exception("Root properties error")


def set_cursor(cursor):
    fid = xcb.core.generate_id()
    xcb.core.open_font(fid, len("cursor"), "cursor".encode("UTF-8"))

    cid = xcb.core.generate_id()

# 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/root.py
import logging
import pwm.windows
import pwm.atom
from pwm.ffi.xcb import xcb

              xcb.EVENT_MASK_LEAVE_WINDOW)


def setup():
    """Setup the root window."""

    cookie = xcb.core.change_window_attributes_checked(
        xcb.screen.root,
        *xcb.mask([(xcb.CW_EVENT_MASK, EVENT_MASK)]))

    cookie.check()

    try:
        # We have to set the cursor now, otherwise it will not show up until
        # the first client is launched.
        set_cursor(Cursor.left_ptr)
    except:
        logging.exception("Root cursor error")

    try:
        _set_properties()
    except:
        logging.exception("Root properties error")


def set_cursor(cursor):
    fid = xcb.core.generate_id()
    xcb.core.open_font(fid, len("cursor"), "cursor".encode("UTF-8"))

    cid = xcb.core.generate_id()

    xcb.core.create_glyph_cursor(cid, fid, fid, cursor, cursor+1,