7 #include <xcb/xcb_event.h>
16 bool is_leaf(node_t *n)
18 return (n != NULL && n->first_child == NULL && n->second_child == NULL);
21 bool is_tiled(client_t *c)
25 return (!c->floating && !c->transient && !c->fullscreen);
28 bool is_floating(client_t *c)
32 return (c->floating && !c->fullscreen);
35 bool is_first_child(node_t *n)
37 return (n != NULL && n->parent != NULL && n->parent->first_child == n);
40 bool is_second_child(node_t *n)
42 return (n != NULL && n->parent != NULL && n->parent->second_child == n);
45 void change_split_ratio(node_t *n, value_change_t chg) {
46 n->split_ratio = pow(n->split_ratio, (chg == CHANGE_INCREASE ? INC_EXP : DEC_EXP));
49 node_t *first_extrema(node_t *n)
53 else if (n->first_child == NULL)
56 return first_extrema(n->first_child);
59 node_t *second_extrema(node_t *n)
63 else if (n->second_child == NULL)
66 return second_extrema(n->second_child);
69 node_t *next_leaf(node_t *n)
74 while (is_second_child(p))
76 if (p->parent == NULL)
78 return first_extrema(p->parent->second_child);
81 node_t *prev_leaf(node_t *n)
86 while (is_first_child(p))
88 if (p->parent == NULL)
90 return second_extrema(p->parent->first_child);
93 node_t *find_fence(node_t *n, direction_t dir)
103 if ((dir == DIR_UP && p->split_type == TYPE_HORIZONTAL && p->rectangle.y < n->rectangle.y)
104 || (dir == DIR_LEFT && p->split_type == TYPE_VERTICAL && p->rectangle.x < n->rectangle.x)
105 || (dir == DIR_DOWN && p->split_type == TYPE_HORIZONTAL && (p->rectangle.y + p->rectangle.height) > (n->rectangle.y + n->rectangle.height))
106 || (dir == DIR_RIGHT && p->split_type == TYPE_VERTICAL && (p->rectangle.x + p->rectangle.width) > (n->rectangle.x + n->rectangle.width)))
114 node_t *find_neighbor(node_t *n, direction_t dir)
116 node_t *fence = find_fence(n, dir);
121 if (dir == DIR_UP || dir == DIR_LEFT)
122 return second_extrema(fence->first_child);
123 else if (dir == DIR_DOWN || dir == DIR_RIGHT)
124 return first_extrema(fence->second_child);
129 void move_fence(node_t *n, direction_t dir, fence_move_t mov)
131 node_t *fence = find_fence(n, dir);
136 if ((mov == MOVE_PUSH && (dir == DIR_RIGHT || dir == DIR_DOWN))
137 || (mov == MOVE_PULL && (dir == DIR_LEFT || dir == DIR_UP)))
138 change_split_ratio(fence, CHANGE_INCREASE);
140 change_split_ratio(fence, CHANGE_DECREASE);
143 void rotate_tree(node_t *n, rotate_t rot)
145 if (n == NULL || is_leaf(n))
150 if ((rot == ROTATE_CLOCKWISE && n->split_type == TYPE_HORIZONTAL)
151 || (rot == ROTATE_COUNTER_CLOCKWISE && n->split_type == TYPE_VERTICAL)
152 || rot == ROTATE_FULL_CYCLE) {
153 tmp = n->first_child;
154 n->first_child = n->second_child;
155 n->second_child = tmp;
156 n->split_ratio = 1.0 - n->split_ratio;
159 if (rot != ROTATE_FULL_CYCLE) {
160 if (n->split_type == TYPE_HORIZONTAL)
161 n->split_type = TYPE_VERTICAL;
162 else if (n->split_type == TYPE_VERTICAL)
163 n->split_type = TYPE_HORIZONTAL;
166 rotate_tree(n->first_child, rot);
167 rotate_tree(n->second_child, rot);
171 void list_history(desktop_t *d, char *rsp)
174 for (node_list_t *a = d->focus_history->head; a != NULL; a = a->prev) {
175 snprintf(line, sizeof(line), "%s %X\n", a->node->client->class_name, a->node->client->window);
176 strncat(rsp, line, REMLEN(rsp));
180 void arrange(monitor_t *m, desktop_t *d)
182 PRINTF("arrange %s%s%s\n", (num_monitors > 1 ? m->name : ""), (num_monitors > 1 ? " " : ""), d->name);
184 xcb_rectangle_t rect = m->rectangle;
185 int wg = (gapless_monocle && d->layout == LAYOUT_MONOCLE ? 0 : window_gap);
186 rect.x += m->left_padding + wg;
187 rect.y += m->top_padding + wg;
188 rect.width -= m->left_padding + m->right_padding + wg;
189 rect.height -= m->top_padding + m->bottom_padding + wg;
190 if (focus_follows_pointer)
191 save_pointer_position(&last_pointer_position);
192 apply_layout(m, d, d->root, rect, rect);
195 void apply_layout(monitor_t *m, desktop_t *d, node_t *n, xcb_rectangle_t rect, xcb_rectangle_t root_rect)
203 if (n->client->fullscreen)
206 if (is_floating(n->client) && n->client->border_width != border_width) {
207 int ds = 2 * (border_width - n->client->border_width);
208 n->client->floating_rectangle.width += ds;
209 n->client->floating_rectangle.height += ds;
212 if (borderless_monocle && is_tiled(n->client) && d->layout == LAYOUT_MONOCLE)
213 n->client->border_width = 0;
215 n->client->border_width = border_width;
218 if (is_tiled(n->client)) {
219 if (d->layout == LAYOUT_TILED)
221 else if (d->layout == LAYOUT_MONOCLE)
223 int wg = (gapless_monocle && d->layout == LAYOUT_MONOCLE ? 0 : window_gap);
224 int bleed = wg + 2 * n->client->border_width;
225 r.width = (bleed < r.width ? r.width - bleed : 1);
226 r.height = (bleed < r.height ? r.height - bleed : 1);
227 n->client->tiled_rectangle = r;
229 r = n->client->floating_rectangle;
232 window_move_resize(n->client->window, r.x, r.y, r.width, r.height);
233 window_border_width(n->client->window, n->client->border_width);
234 window_draw_border(n, n == d->focus, m == mon);
237 xcb_rectangle_t first_rect;
238 xcb_rectangle_t second_rect;
240 if (n->first_child->vacant || n->second_child->vacant) {
241 first_rect = second_rect = rect;
244 if (n->split_type == TYPE_VERTICAL) {
245 fence = rect.width * n->split_ratio;
246 first_rect = (xcb_rectangle_t) {rect.x, rect.y, fence, rect.height};
247 second_rect = (xcb_rectangle_t) {rect.x + fence, rect.y, rect.width - fence, rect.height};
249 } else if (n->split_type == TYPE_HORIZONTAL) {
250 fence = rect.height * n->split_ratio;
251 first_rect = (xcb_rectangle_t) {rect.x, rect.y, rect.width, fence};
252 second_rect = (xcb_rectangle_t) {rect.x, rect.y + fence, rect.width, rect.height - fence};
256 apply_layout(m, d, n->first_child, first_rect, root_rect);
257 apply_layout(m, d, n->second_child, second_rect, root_rect);
261 void insert_node(monitor_t *m, desktop_t *d, node_t *n)
263 if (d == NULL || n == NULL)
266 PRINTF("insert node %X\n", n->client->window);
268 node_t *focus = d->focus;
273 node_t *dad = make_node();
274 node_t *fopar = focus->parent;
276 n->client->born_as = split_mode;
277 switch (split_mode) {
280 dad->first_child = n;
281 dad->second_child = focus;
282 if (m->rectangle.width > m->rectangle.height)
283 dad->split_type = TYPE_VERTICAL;
285 dad->split_type = TYPE_HORIZONTAL;
289 node_t *grandpa = fopar->parent;
290 dad->parent = grandpa;
291 if (grandpa != NULL) {
292 if (is_first_child(fopar))
293 grandpa->first_child = dad;
295 grandpa->second_child = dad;
299 dad->split_type = fopar->split_type;
300 dad->split_ratio = fopar->split_ratio;
302 if (is_first_child(focus)) {
303 dad->first_child = n;
304 dad->second_child = fopar;
305 rotate_tree(fopar, ROTATE_CLOCKWISE);
307 dad->first_child = fopar;
308 dad->second_child = n;
309 rotate_tree(fopar, ROTATE_COUNTER_CLOCKWISE);
315 if (is_first_child(focus))
316 fopar->first_child = dad;
318 fopar->second_child = dad;
320 dad->split_ratio = focus->split_ratio;
325 dad->split_type = TYPE_VERTICAL;
326 dad->first_child = n;
327 dad->second_child = focus;
330 dad->split_type = TYPE_VERTICAL;
331 dad->first_child = focus;
332 dad->second_child = n;
335 dad->split_type = TYPE_HORIZONTAL;
336 dad->first_child = n;
337 dad->second_child = focus;
340 dad->split_type = TYPE_HORIZONTAL;
341 dad->first_child = focus;
342 dad->second_child = n;
345 if (d->root == focus)
347 split_mode = MODE_AUTOMATIC;
351 update_vacant_state(fopar);
355 void focus_node(monitor_t *m, desktop_t *d, node_t *n, bool is_mapped)
360 PRINTF("focus node %X\n", n->client->window);
362 split_mode = MODE_AUTOMATIC;
363 n->client->urgent = false;
367 for (desktop_t *cd = mon->desk_head; cd != NULL; cd = cd->next)
368 window_draw_border(cd->focus, true, false);
369 for (desktop_t *cd = m->desk_head; cd != NULL; cd = cd->next)
371 window_draw_border(cd->focus, true, true);
373 window_draw_border(n, true, true);
376 window_draw_border(d->focus, false, true);
377 window_draw_border(n, true, true);
379 xcb_set_input_focus(dpy, XCB_INPUT_FOCUS_POINTER_ROOT, n->client->window, XCB_CURRENT_TIME);
382 if (focus_follows_pointer) {
383 save_pointer_position(&last_pointer_position);
384 if (n != mon->desk->focus) {
385 if (last_focused_window != XCB_NONE) {
386 uint32_t values[] = {CLIENT_EVENT_MASK_FFP};
387 xcb_change_window_attributes(dpy, last_focused_window, XCB_CW_EVENT_MASK, values);
389 uint32_t values[] = {CLIENT_EVENT_MASK};
390 xcb_change_window_attributes(dpy, n->client->window, XCB_CW_EVENT_MASK, values);
391 last_focused_window = n->client->window;
395 if (!is_tiled(n->client)) {
396 if (!adaptative_raise || !might_cover(d, n))
397 window_raise(n->client->window);
399 window_pseudo_raise(d, n->client->window);
404 history_add(d->focus_history, n);
407 ewmh_update_active_window();
411 void update_current(void)
413 if (mon->desk->focus == NULL)
414 ewmh_update_active_window();
416 focus_node(mon, mon->desk, mon->desk->focus, true);
420 void unlink_node(desktop_t *d, node_t *n)
422 if (d == NULL || n == NULL)
425 PRINTF("unlink node %X\n", n->client->window);
427 node_t *p = n->parent;
434 node_t *g = p->parent;
435 bool n_first_child = is_first_child(n);
438 if (n->client->born_as == MODE_AUTOMATIC)
439 rotate_tree(b, ROTATE_COUNTER_CLOCKWISE);
442 if (n->client->born_as == MODE_AUTOMATIC)
443 rotate_tree(b, ROTATE_CLOCKWISE);
447 if (is_first_child(p))
459 if (d->focus_history->head->prev != NULL) {
460 d->focus = d->focus_history->head->prev->node;
462 d->focus = (n_first_child ? first_extrema(b) : second_extrema(b));
463 history_add(d->focus_history, d->focus);
467 update_vacant_state(b->parent);
470 history_remove(d->focus_history, n);
473 void remove_node(desktop_t *d, node_t *n)
475 if (d == NULL || n == NULL)
478 PRINTF("remove node %X\n", n->client->window);
485 ewmh_update_client_list();
491 void destroy_tree(node_t *n)
495 node_t *first_tree = n->first_child;
496 node_t *second_tree = n->second_child;
497 if (n->client != NULL)
500 destroy_tree(first_tree);
501 destroy_tree(second_tree);
504 void swap_nodes(node_t *n1, node_t *n2)
506 if (n1 == NULL || n2 == NULL || n1 == n2)
511 /* (n1 and n2 are leaves) */
512 node_t *pn1 = n1->parent;
513 node_t *pn2 = n2->parent;
514 bool n1_first_child = is_first_child(n1);
515 bool n2_first_child = is_first_child(n2);
519 pn1->first_child = n2;
521 pn1->second_child = n2;
526 pn2->first_child = n1;
528 pn2->second_child = n1;
534 if (n1->vacant != n2->vacant) {
535 update_vacant_state(n1->parent);
536 update_vacant_state(n2->parent);
540 void transfer_node(monitor_t *ms, desktop_t *ds, monitor_t *md, desktop_t *dd, node_t *n)
542 if (n == NULL || ds == NULL || dd == NULL || ms == NULL || md == NULL || (ms == md && dd == ds))
545 PRINTF("transfer node %X\n", n->client->window);
548 insert_node(md, dd, n);
549 ewmh_set_wm_desktop(n, dd);
551 if (ds == ms->desk && dd != md->desk) {
552 window_hide(n->client->window);
555 fit_monitor(md, n->client);
557 if (n->client->fullscreen)
558 window_move_resize(n->client->window, md->rectangle.x, md->rectangle.y, md->rectangle.width, md->rectangle.height);
560 if (ds != ms->desk && dd == md->desk) {
561 window_show(n->client->window);
562 focus_node(md, dd, n, true);
564 focus_node(md, dd, n, false);
567 if (ds == ms->desk || dd == md->desk)
571 void select_monitor(monitor_t *m)
573 if (m == NULL || mon == m)
576 PRINTF("select monitor %s\n", m->name);
578 focus_node(m, m->desk, m->desk->focus, true);
583 ewmh_update_current_desktop();
587 void select_desktop(desktop_t *d)
589 if (d == NULL || d == mon->desk)
592 PRINTF("select desktop %s\n", d->name);
595 node_t *n = first_extrema(d->root);
598 window_show(n->client->window);
602 n = first_extrema(mon->desk->root);
605 window_hide(n->client->window);
610 mon->last_desk = mon->desk;
614 ewmh_update_current_desktop();
618 void cycle_monitor(cycle_dir_t dir)
620 if (dir == CYCLE_NEXT)
621 select_monitor((mon->next == NULL ? mon_head : mon->next));
622 else if (dir == CYCLE_PREV)
623 select_monitor((mon->prev == NULL ? mon_tail : mon->prev));
626 void cycle_desktop(monitor_t *m, desktop_t *d, cycle_dir_t dir, skip_desktop_t skip)
628 desktop_t *f = (dir == CYCLE_PREV ? d->prev : d->next);
630 f = (dir == CYCLE_PREV ? m->desk_tail : m->desk_head);
633 if (skip == DESKTOP_SKIP_NONE
634 || (skip == DESKTOP_SKIP_FREE && f->root != NULL)
635 || (skip == DESKTOP_SKIP_OCCUPIED && f->root == NULL)) {
639 f = (dir == CYCLE_PREV ? f->prev : f->next);
641 f = (dir == CYCLE_PREV ? m->desk_tail : m->desk_head);
645 void cycle_leaf(monitor_t *m, desktop_t *d, node_t *n, cycle_dir_t dir, skip_client_t skip)
652 node_t *f = (dir == CYCLE_PREV ? prev_leaf(n) : next_leaf(n));
654 f = (dir == CYCLE_PREV ? second_extrema(d->root) : first_extrema(d->root));
657 bool tiled = is_tiled(f->client);
658 if (skip == CLIENT_SKIP_NONE || (skip == CLIENT_SKIP_TILED && !tiled) || (skip == CLIENT_SKIP_FLOATING && tiled)
659 || (skip == CLIENT_SKIP_CLASS_DIFFER && strcmp(f->client->class_name, n->client->class_name) == 0)
660 || (skip == CLIENT_SKIP_CLASS_EQUAL && strcmp(f->client->class_name, n->client->class_name) != 0)) {
661 focus_node(m, d, f, true);
664 f = (dir == CYCLE_PREV ? prev_leaf(f) : next_leaf(f));
666 f = (dir == CYCLE_PREV ? second_extrema(d->root) : first_extrema(d->root));
670 void nearest_leaf(monitor_t *m, desktop_t *d, node_t *n, nearest_arg_t dir, skip_client_t skip)
675 PUTS("nearest leaf");
679 for (node_t *f = first_extrema(d->root); f != NULL; f = next_leaf(f))
680 if (skip == CLIENT_SKIP_NONE || (skip == CLIENT_SKIP_TILED && !is_tiled(f->client)) || (skip == CLIENT_SKIP_FLOATING && is_tiled(f->client))
681 || (skip == CLIENT_SKIP_CLASS_DIFFER && strcmp(f->client->class_name, n->client->class_name) == 0)
682 || (skip == CLIENT_SKIP_CLASS_EQUAL && strcmp(f->client->class_name, n->client->class_name) != 0))
683 if ((dir == NEAREST_OLDER
684 && (f->client->uid < n->client->uid)
685 && (x == NULL || f->client->uid > x->client->uid))
686 || (dir == NEAREST_NEWER
687 && (f->client->uid > n->client->uid)
688 && (x == NULL || f->client->uid < x->client->uid)))
691 focus_node(m, d, x, true);
694 void circulate_leaves(monitor_t *m, desktop_t *d, circulate_dir_t dir) {
695 if (d == NULL || d->root == NULL || is_leaf(d->root))
697 node_t *par = d->focus->parent;
698 bool focus_first_child = is_first_child(d->focus);
699 if (dir == CIRCULATE_FORWARD)
700 for (node_t *s = second_extrema(d->root), *f = prev_leaf(s); f != NULL; s = prev_leaf(f), f = prev_leaf(s))
703 for (node_t *f = first_extrema(d->root), *s = next_leaf(f); s != NULL; f = next_leaf(s), s = next_leaf(f))
705 if (focus_first_child)
706 focus_node(m, d, par->first_child, true);
708 focus_node(m, d, par->second_child, true);
711 void update_vacant_state(node_t *n)
716 PUTS("update vacant state");
718 /* n is not a leaf */
722 p->vacant = (p->first_child->vacant && p->second_child->vacant);
727 void fit_monitor(monitor_t *m, client_t *c)
729 xcb_rectangle_t crect = c->floating_rectangle;
730 xcb_rectangle_t mrect = m->rectangle;
731 while (crect.x < mrect.x)
732 crect.x += mrect.width;
733 while (crect.x > (mrect.x + mrect.width - 1))
734 crect.x -= mrect.width;
735 while (crect.y < mrect.y)
736 crect.y += mrect.height;
737 while (crect.y > (mrect.y + mrect.height - 1))
738 crect.y -= mrect.height;
739 c->floating_rectangle = crect;
742 void put_status(void)
744 if (status_fifo == NULL)
747 for (monitor_t *m = mon_head; m != NULL; m = m->next) {
748 fprintf(status_fifo, "%c%s:", (mon == m ? 'M' : 'm'), m->name);
749 for (desktop_t *d = m->desk_head; d != NULL; d = d->next, urgent = false) {
750 for (node_t *n = first_extrema(d->root); n != NULL && !urgent; n = next_leaf(n))
751 urgent |= n->client->urgent;
752 fprintf(status_fifo, "%c%c%s:", (m->desk == d ? 'D' : (d->root != NULL ? 'd' : '_')), (urgent ? '!' : '_'), d->name);
755 fprintf(status_fifo, "L%s:W%X\n", (mon->desk->layout == LAYOUT_TILED ? "tiled" : "monocle"), (mon->desk->focus == NULL ? 0 : mon->desk->focus->client->window));
759 void list_monitors(list_option_t opt, char *rsp)
762 for (monitor_t *m = mon_head; m != NULL; m = m->next) {
763 snprintf(line, sizeof(line), "%s %ux%u%+i%+i", m->name, m->rectangle.width, m->rectangle.height, m->rectangle.x, m->rectangle.y);
764 strncat(rsp, line, REMLEN(rsp));
766 strncat(rsp, " #\n", REMLEN(rsp));
767 else if (m == last_mon)
768 strncat(rsp, " ~\n", REMLEN(rsp));
770 strncat(rsp, "\n", REMLEN(rsp));
771 if (opt == LIST_OPTION_VERBOSE)
772 list_desktops(m, opt, 1, rsp);
776 void list_desktops(monitor_t *m, list_option_t opt, unsigned int depth, char *rsp)
779 for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
780 for (unsigned int i = 0; i < depth; i++)
781 strncat(rsp, " ", REMLEN(rsp));
782 snprintf(line, sizeof(line), "%s %c", d->name, (d->layout == LAYOUT_TILED ? 'T' : 'M'));
783 strncat(rsp, line, REMLEN(rsp));
785 strncat(rsp, " @\n", REMLEN(rsp));
786 else if (d == m->last_desk)
787 strncat(rsp, " ~\n", REMLEN(rsp));
789 strncat(rsp, "\n", REMLEN(rsp));
790 if (opt == LIST_OPTION_VERBOSE)
791 list(d, d->root, rsp, depth + 1);
795 void list(desktop_t *d, node_t *n, char *rsp, unsigned int depth)
802 for (unsigned int i = 0; i < depth; i++)
803 strncat(rsp, " ", REMLEN(rsp));
806 client_t *c = n->client;
807 snprintf(line, sizeof(line), "%c %s %X %u %u %ux%u%+i%+i %c%c%c%c%c", (c->born_as == MODE_AUTOMATIC ? 'a' : 'm'), c->class_name, c->window, c->uid, c->border_width, c->floating_rectangle.width, c->floating_rectangle.height, c->floating_rectangle.x, c->floating_rectangle.y, (c->floating ? 'f' : '-'), (c->transient ? 't' : '-'), (c->fullscreen ? 'F' : '-'), (c->urgent ? 'u' : '-'), (c->locked ? 'l' : '-'));
809 snprintf(line, sizeof(line), "%c %.2f", (n->split_type == TYPE_HORIZONTAL ? 'H' : 'V'), n->split_ratio);
812 strncat(rsp, line, REMLEN(rsp));
815 strncat(rsp, " *\n", REMLEN(rsp));
816 else if (n == d->last_focus)
817 strncat(rsp, " ~\n", REMLEN(rsp));
819 strncat(rsp, "\n", REMLEN(rsp));
821 list(d, n->first_child, rsp, depth + 1);
822 list(d, n->second_child, rsp, depth + 1);
825 void restore(char *file_path)
827 if (file_path == NULL)
830 FILE *snapshot = fopen(file_path, "r");
831 if (snapshot == NULL) {
832 warn("restore: can't open file\n");
841 unsigned int level, last_level = 0, max_uid = 0;
842 bool aborted = false;
844 while (!aborted && fgets(line, sizeof(line), snapshot) != NULL) {
845 unsigned int len = strlen(line);
847 while (level < strlen(line) && isspace(line[level]))
855 switch (line[len - 2]) {
863 } else if (level == 2) {
869 while (i > 0 && !isupper(line[i]))
872 d->layout = LAYOUT_MONOCLE;
873 else if (line[i] == 'T')
874 d->layout = LAYOUT_TILED;
876 switch (line[len - 2]) {
885 node_t *birth = make_node();
890 if (level > last_level) {
891 n->first_child = birth;
895 } while (n != NULL && n->second_child != NULL);
897 warn("restore: file is malformed\n");
900 n->second_child = birth;
906 if (isupper(line[level])) {
908 sscanf(line + level, "%c %lf", &st, &n->split_ratio);
910 n->split_type = TYPE_HORIZONTAL;
912 n->split_type = TYPE_VERTICAL;
914 client_t *c = make_client(XCB_NONE);
916 char ba, floating, transient, fullscreen, urgent, locked;
917 sscanf(line + level, "%c %s %X %u %u %hux%hu%hi%hi %c%c%c%c%c", &ba, c->class_name, &c->window, &c->uid, &c->border_width, &c->floating_rectangle.width, &c->floating_rectangle.height, &c->floating_rectangle.x, &c->floating_rectangle.y, &floating, &transient, &fullscreen, &urgent, &locked);
919 c->born_as = MODE_AUTOMATIC;
921 c->born_as = MODE_MANUAL;
922 c->floating = (floating == '-' ? false : true);
923 c->transient = (transient == '-' ? false : true);
924 c->fullscreen = (fullscreen == '-' ? false : true);
925 c->urgent = (urgent == '-' ? false : true);
926 c->locked = (locked == '-' ? false : true);
927 if (c->uid > max_uid)
931 switch (line[len - 2]) {
945 client_uid = max_uid + 1;
946 for (monitor_t *m = mon_head; m != NULL; m = m->next)
947 for (desktop_t *d = m->desk_head; d != NULL; d = d->next)
948 for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n)) {
949 uint32_t values[] = {(focus_follows_pointer ? CLIENT_EVENT_MASK_FFP : CLIENT_EVENT_MASK)};
950 xcb_change_window_attributes(dpy, n->client->window, XCB_CW_EVENT_MASK, values);
951 if (n->client->floating) {
953 update_vacant_state(n->parent);