# Path: tilenol/xcb/core.py
# class Rectangle(namedtuple('_Rectangle', 'x y width height')):
#     __slots__ = ()
# 
# Path: tilenol/commands.py
# class CommandDispatcher(dict):
# 
#     def __init__(self):
#         self.events = Events()
# 
#     def __setitem__(self, name, value):
#         super().__setitem__(name, value)
#         ev = self.events.get(name)
#         if ev is not None:
#             ev.emit()
# 
#     def call(self, obj, meth, *args):
#         getattr(self[obj], 'cmd_' + meth)(*args)
# 
#     def callback(self, *args):
#         return partial(self.call, *args)
# 
# Path: tilenol/layout/base.py
# class Layout(metaclass=LayoutMeta):
# 
#     def __init__(self):
#         self.visible = False
#         self.relayout = Event('layout.relayout')
#         self.relayout.listen(self.check_relayout)
# 
#     def check_relayout(self):
#         if self.visible:
#             self.layout()
#             self.group.check_focus()
# 
#     @classmethod
#     def get_defined_classes(cls, base):
#         res = OrderedDict()
#         for k in cls.fields:
#             v = getattr(cls, k)
#             if isinstance(v, type) and issubclass(v, base):
#                 res[k] = v
#         return res
# 
#     def dirty(self):
#         self.relayout.emit()
# 
#     def all_visible_windows(self):
#         for i in getattr(self, 'visible_windows', ()):
#             yield i
#         sub = getattr(self, 'sublayouts', None)
#         if sub:
#             for s in sub():
#                 for i in s.visible_windows:
#                     yield i
# 
#     def hide(self):
#         self.visible = False
#         for i in self.all_visible_windows():
#             i.hide()
# 
#     def show(self):
#         self.visible = True
#         for i in self.all_visible_windows():
#             i.show()


from collections import OrderedDict
from math import floor
from functools import wraps
from zorro.di import has_dependencies, dependency, di
from tilenol.xcb import Rectangle
from tilenol.commands import CommandDispatcher
from . import Layout
        self.dirty()

    def _assign_boxes(self, box):
        if self.fixed:
            all_stacks = self.stack_list
        else:
            all_stacks = [s for s in self.stack_list if not s.empty]
        curw = 0
        if self.vertical:
            rstart = start = box.x
            totalpx = box.width
        else:
            rstart = start = box.y
            totalpx = box.height
        totpx = sum((s.size or s.min_size) for s in all_stacks)
        totw = sum(s.weight for s in all_stacks if s.size is None)
        skip_pixels = totpx > totalpx or (not totw and totpx != totalpx)
        if skip_pixels:
            totw = sum(s.weight for s in all_stacks)
        else:
            totalpx -= sum(s.size for s in all_stacks if s.size is not None)
        pxoff = 0
        for s in all_stacks:
            if s.size is not None and not skip_pixels:
                end = start + s.size
                pxoff += s.size
            else:
                curw += s.weight
                end = rstart + pxoff + int(floor(curw/totw*totalpx))
            if self.vertical:

# Path: tilenol/xcb/core.py
# class Rectangle(namedtuple('_Rectangle', 'x y width height')):
#     __slots__ = ()
# 
# Path: tilenol/commands.py
# class CommandDispatcher(dict):
# 
#     def __init__(self):
#         self.events = Events()
# 
#     def __setitem__(self, name, value):
#         super().__setitem__(name, value)
#         ev = self.events.get(name)
#         if ev is not None:
#             ev.emit()
# 
#     def call(self, obj, meth, *args):
#         getattr(self[obj], 'cmd_' + meth)(*args)
# 
#     def callback(self, *args):
#         return partial(self.call, *args)
# 
# Path: tilenol/layout/base.py
# class Layout(metaclass=LayoutMeta):
# 
#     def __init__(self):
#         self.visible = False
#         self.relayout = Event('layout.relayout')
#         self.relayout.listen(self.check_relayout)
# 
#     def check_relayout(self):
#         if self.visible:
#             self.layout()
#             self.group.check_focus()
# 
#     @classmethod
#     def get_defined_classes(cls, base):
#         res = OrderedDict()
#         for k in cls.fields:
#             v = getattr(cls, k)
#             if isinstance(v, type) and issubclass(v, base):
#                 res[k] = v
#         return res
# 
#     def dirty(self):
#         self.relayout.emit()
# 
#     def all_visible_windows(self):
#         for i in getattr(self, 'visible_windows', ()):
#             yield i
#         sub = getattr(self, 'sublayouts', None)
#         if sub:
#             for s in sub():
#                 for i in s.visible_windows:
#                     yield i
# 
#     def hide(self):
#         self.visible = False
#         for i in self.all_visible_windows():
#             i.hide()
# 
#     def show(self):
#         self.visible = True
#         for i in self.all_visible_windows():
#             i.show()


# Path: tilenol/layout/tile.py
from collections import OrderedDict
from math import floor
from functools import wraps
from zorro.di import has_dependencies, dependency, di
from tilenol.xcb import Rectangle
from tilenol.commands import CommandDispatcher
from . import Layout

        self.dirty()

    def _assign_boxes(self, box):
        if self.fixed:
            all_stacks = self.stack_list
        else:
            all_stacks = [s for s in self.stack_list if not s.empty]
        curw = 0
        if self.vertical:
            rstart = start = box.x
            totalpx = box.width
        else:
            rstart = start = box.y
            totalpx = box.height
        totpx = sum((s.size or s.min_size) for s in all_stacks)
        totw = sum(s.weight for s in all_stacks if s.size is None)
        skip_pixels = totpx > totalpx or (not totw and totpx != totalpx)
        if skip_pixels:
            totw = sum(s.weight for s in all_stacks)
        else:
            totalpx -= sum(s.size for s in all_stacks if s.size is not None)
        pxoff = 0
        for s in all_stacks:
            if s.size is not None and not skip_pixels:
                end = start + s.size
                pxoff += s.size
            else:
                curw += s.weight
                end = rstart + pxoff + int(floor(curw/totw*totalpx))
            if self.vertical:

                s.box = Rectangle(start, box.y, end-start, box.height)