- `flip horizontal|vertical` — Flip the window tree.
+- `balance` — Adjust the split ratios so that all windows occupy the same area.
+
- `rule PATTERN [DESKTOP_NAME] [floating]` — Create a new rule (`PATTERN` must match the class or instance name).
- `remove_rule UID ...` — Remove the rules with the given UIDs.
.BI flip " horizontal|vertical"
Flip the window tree.
.TP
+.B balance
+Adjust the split ratios so that all windows occupy the same area.
+.TP
.BI rule " PATTERN [DESKTOP_NAME] [floating]"
Create a new rule (PATTERN must match the class or instance name).
.TP
if (parse_flip(flp, &f))
flip_tree(mon->desk->root, f);
}
+ } else if (strcmp(cmd, "balance") == 0) {
+ balance_tree(mon->desk->root);
} else if (strcmp(cmd, "grab_pointer") == 0) {
char *pac = strtok(NULL, TOK_SEP);
if (pac != NULL) {
flip_tree(n->second_child, flp);
}
+int balance_tree(node_t *n)
+{
+ if (n == NULL || n->vacant) {
+ return 0;
+ } else if (is_leaf(n)) {
+ return 1;
+ } else {
+ int b1 = balance_tree(n->first_child);
+ int b2 = balance_tree(n->second_child);
+ int b = b1 + b2;
+ if (b1 > 0 && b2 > 0)
+ n->split_ratio = (double) b1 / b;
+ return b;
+ }
+}
+
void arrange(monitor_t *m, desktop_t *d)
{
PRINTF("arrange %s%s%s\n", (num_monitors > 1 ? m->name : ""), (num_monitors > 1 ? " " : ""), d->name);
void move_fence(node_t *, direction_t, fence_move_t);
void rotate_tree(node_t *, rotate_t);
void flip_tree(node_t *, flip_t);
+int balance_tree(node_t *);
void arrange(monitor_t *, desktop_t *);
void apply_layout(monitor_t *, desktop_t *, node_t *, xcb_rectangle_t, xcb_rectangle_t);
void insert_node(monitor_t *, desktop_t *, node_t *);