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);
+}
+
+void list_history(desktop_t *d, char *rsp)
+{
+ char line[MAXLEN];
+ for (node_list_t *a = d->history->head; a != NULL; a = a->next) {
+ snprintf(line, sizeof(line), "%s %X\n", a->node->client->class_name, a->node->client->window);
+ strncat(rsp, line, REMLEN(rsp));
+ }
+}
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;
+ get_pointed_window(&win);
+ 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);
}
if (d->focus != n) {
- d->last_focus = d->focus;
d->focus = n;
+ history_add(d->history, n);
}
ewmh_update_active_window();
if (p == NULL) {
d->root = NULL;
d->focus = NULL;
- d->last_focus = NULL;
} else {
node_t *b;
node_t *g = p->parent;
n->parent = NULL;
free(p);
- if (n == d->last_focus) {
- d->last_focus = NULL;
- } else if (n == d->focus) {
- if (d->last_focus != NULL)
- d->focus = d->last_focus;
- else
+ if (n == d->focus) {
+ node_t *last_focus = history_get(d->history, 1);
+ if (last_focus != NULL) {
+ d->focus = last_focus;
+ } else {
d->focus = (n_first_child ? first_extrema(b) : second_extrema(b));
- d->last_focus = NULL;
+ history_add(d->history, d->focus);
+ }
}
update_vacant_state(b->parent);
}
+
+ history_remove(d->history, n);
}
void remove_node(desktop_t *d, node_t *n)
if (n == d->focus)
strncat(rsp, " *\n", REMLEN(rsp));
- else if (n == d->last_focus)
- strncat(rsp, " ~\n", REMLEN(rsp));
else
strncat(rsp, "\n", REMLEN(rsp));
if (c->uid > max_uid)
max_uid = c->uid;
n->client = c;
- if (len >= 2)
- switch (line[len - 2]) {
- case '*':
- d->focus = n;
- break;
- case '~':
- d->last_focus = n;
- break;
- }
+ if (len >= 2 && line[len -2] == '*')
+ d->focus = n;
}
}
last_level = level;
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;