# 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/config.py
# class Config:
#     def __init__(self):
#     def load(self, default=False):
#     def _load_default(self):
#     def _ensure_config_exists(self, path):
#     def __getattr__(self, name):
# def setup_keys():
# def handle_key_press_event(event):
# def create_arguments(func):
#     def wrapper(*args, **kwargs):


from contextlib import contextmanager
from functools import wraps
from pwm.ffi.xcb import xcb
from pwm.config import config
import struct
import pwm.atom
import pwm.events
import pwm.workspaces
import pwm.color
import pwm.rules
    events.focus_changed will be fired with the new focused window as
    parameter. If no window was focused or the window was not found
    the event will be fired with None as parameter.
    """

    global focused

    win = wid if wid in managed else None

    if focused == win:
        return

    if focused:
        _handle_focus(focused, False)

    focused = win
    if focused:
        _handle_focus(focused, True)
        managed[wid].workspace.handle_focus(wid)

    pwm.events.focus_changed(win)


def _handle_focus(wid, focused):
    """Set border color and input focus according to focus."""

    border = None
    if focused:
        border = pwm.color.get_pixel(config.window.focused)
    else:

# 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/config.py
# class Config:
#     def __init__(self):
#     def load(self, default=False):
#     def _load_default(self):
#     def _ensure_config_exists(self, path):
#     def __getattr__(self, name):
# def setup_keys():
# def handle_key_press_event(event):
# def create_arguments(func):
#     def wrapper(*args, **kwargs):


# Path: pwm/windows.py
from contextlib import contextmanager
from functools import wraps
from pwm.ffi.xcb import xcb
from pwm.config import config
import struct
import pwm.atom
import pwm.events
import pwm.workspaces
import pwm.color
import pwm.rules

    events.focus_changed will be fired with the new focused window as
    parameter. If no window was focused or the window was not found
    the event will be fired with None as parameter.
    """

    global focused

    win = wid if wid in managed else None

    if focused == win:
        return

    if focused:
        _handle_focus(focused, False)

    focused = win
    if focused:
        _handle_focus(focused, True)
        managed[wid].workspace.handle_focus(wid)

    pwm.events.focus_changed(win)


def _handle_focus(wid, focused):
    """Set border color and input focus according to focus."""

    border = None
    if focused:
        border = pwm.color.get_pixel(config.window.focused)
    else:

        border = pwm.color.get_pixel(config.window.unfocused)