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);
if (focus_follows_pointer) {
xcb_window_t win = XCB_NONE;
- get_pointed_window(&win);
+ query_pointer(&win, NULL);
if (win != n->client->window)
enable_motion_recorder();
+ else
+ disable_motion_recorder();
}
if (!is_tiled(n->client)) {
destroy_tree(second_tree);
}
-void swap_nodes(node_t *n1, node_t *n2)
+void swap_nodes(desktop_t *d1, node_t *n1, desktop_t *d2, node_t *n2)
{
if (n1 == NULL || n2 == NULL || n1 == n2)
return;
update_vacant_state(n1->parent);
update_vacant_state(n2->parent);
}
+
+ if (d1 != d2) {
+ if (d1->root == n1)
+ d1->root = n2;
+ if (d1->focus == n1)
+ d1->focus = n2;
+ if (d1->last_focus == n1)
+ d1->last_focus = n2;
+ if (d2->root == n2)
+ d2->root = n1;
+ if (d2->focus == n2)
+ d2->focus = n1;
+ if (d2->last_focus == n2)
+ d2->last_focus = n1;
+ }
}
void transfer_node(monitor_t *ms, desktop_t *ds, monitor_t *md, desktop_t *dd, node_t *n)
bool focus_first_child = is_first_child(d->focus);
if (dir == CIRCULATE_FORWARD)
for (node_t *s = second_extrema(d->root), *f = prev_leaf(s); f != NULL; s = prev_leaf(f), f = prev_leaf(s))
- swap_nodes(f, s);
+ swap_nodes(d, f, d, s);
else
for (node_t *f = first_extrema(d->root), *s = next_leaf(f); s != NULL; f = next_leaf(s), s = next_leaf(f))
- swap_nodes(f, s);
+ swap_nodes(d, f, d, s);
if (focus_first_child)
focus_node(m, d, par->first_child, true);
else