rotate_tree(n->second_child, rot);
}
+void flip_tree(node_t *n, flip_t flp)
+{
+ if (n == NULL || is_leaf(n))
+ return;
+
+ node_t *tmp;
+
+ if ((flp == FLIP_HORIZONTAL && n->split_type == TYPE_HORIZONTAL)
+ || (flp == FLIP_VERTICAL && n->split_type == TYPE_VERTICAL)) {
+ tmp = n->first_child;
+ n->first_child = n->second_child;
+ n->second_child = tmp;
+ n->split_ratio = 1.0 - n->split_ratio;
+ }
+
+ flip_tree(n->first_child, flp);
+ 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)
{
rect.y += m->top_padding + wg;
rect.width -= m->left_padding + m->right_padding + wg;
rect.height -= m->top_padding + m->bottom_padding + wg;
- if (focus_follows_mouse)
- update_pointer_position(&pointer_position);
apply_layout(m, d, d->root, rect, rect);
}
window_draw_border(d->focus, false, true);
window_draw_border(n, true, true);
}
- if (focus_follows_mouse)
- update_pointer_position(&pointer_position);
xcb_set_input_focus(dpy, XCB_INPUT_FOCUS_POINTER_ROOT, n->client->window, XCB_CURRENT_TIME);
}
+ if (focus_follows_pointer) {
+ xcb_window_t win = XCB_NONE;
+ query_pointer(&win, NULL);
+ if (win != n->client->window)
+ enable_motion_recorder();
+ else
+ disable_motion_recorder();
+ }
+
if (!is_tiled(n->client)) {
if (!adaptative_raise || !might_cover(d, n))
window_raise(n->client->window);
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
for (monitor_t *m = mon_head; m != NULL; m = m->next)
for (desktop_t *d = m->desk_head; d != NULL; d = d->next)
for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n)) {
- uint32_t values[] = {CLIENT_EVENT_MASK};
+ uint32_t values[] = {(focus_follows_pointer ? CLIENT_EVENT_MASK_FFP : CLIENT_EVENT_MASK)};
xcb_change_window_attributes(dpy, n->client->window, XCB_CW_EVENT_MASK, values);
if (n->client->floating) {
n->vacant = true;