Skip to content

Commit

Permalink
fix(core): ensure tab bars are restored properly from state
Browse files Browse the repository at this point in the history
  • Loading branch information
aravinda0 committed Jan 2, 2024
1 parent 99e68af commit fe8f397
Show file tree
Hide file tree
Showing 5 changed files with 520 additions and 263 deletions.
15 changes: 13 additions & 2 deletions src/qtile_bonsai/core/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,16 @@ def reset(self, from_state: dict | None = None):
there.
Subscribers will be notified of nodes that are removed/added in the process.
NOTE:
For the moment, only the nodes and their `box.principal_rect` information is
read from `from_state`. Things like margins/border/padding, tab bar
settings, are read from the current config.
This aligns with how we want things when working under qtile, which is our
current scope.
Later™, We can figure out how to make this more general (like simply restore
as-is from provided state), while still working for qtile.
"""
removed_nodes = list(self.iter_walk())
self._root = None
Expand Down Expand Up @@ -1009,11 +1019,12 @@ def walk_and_create(n, parent) -> Node:
tc = self.create_tab_container()
tc.id = node_id
bar_rect_state = n["tab_bar"]["box"]["principal_rect"]
tc.tab_bar.box.principal_rect = Rect(
tc.tab_bar = self._build_tab_bar(
bar_rect_state["x"],
bar_rect_state["y"],
bar_rect_state["w"],
bar_rect_state["h"],
parent.tab_level + 1 if parent is not None else 1,
len(n["children"]),
)
tc.parent = parent
tc.children = [walk_and_create(c, tc) for c in n["children"]]
Expand Down
Empty file added tests/data/__init__.py
Empty file.
Loading

0 comments on commit fe8f397

Please sign in to comment.