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);
170 void flip_tree(node_t *n, flip_t flp)
172 if (n == NULL || is_leaf(n))
177 if ((flp == FLIP_HORIZONTAL && n->split_type == TYPE_HORIZONTAL)
178 || (flp == FLIP_VERTICAL && n->split_type == TYPE_VERTICAL)) {
179 tmp = n->first_child;
180 n->first_child = n->second_child;
181 n->second_child = tmp;
182 n->split_ratio = 1.0 - n->split_ratio;
185 flip_tree(n->first_child, flp);
186 flip_tree(n->second_child, flp);
189 void arrange(monitor_t *m, desktop_t *d)
191 PRINTF("arrange %s%s%s\n", (num_monitors > 1 ? m->name : ""), (num_monitors > 1 ? " " : ""), d->name);
193 xcb_rectangle_t rect = m->rectangle;
194 int wg = (gapless_monocle && d->layout == LAYOUT_MONOCLE ? 0 : window_gap);
195 rect.x += m->left_padding + wg;
196 rect.y += m->top_padding + wg;
197 rect.width -= m->left_padding + m->right_padding + wg;
198 rect.height -= m->top_padding + m->bottom_padding + wg;
199 apply_layout(m, d, d->root, rect, rect);
202 void apply_layout(monitor_t *m, desktop_t *d, node_t *n, xcb_rectangle_t rect, xcb_rectangle_t root_rect)
210 if (n->client->fullscreen)
213 if (is_floating(n->client) && n->client->border_width != border_width) {
214 int ds = 2 * (border_width - n->client->border_width);
215 n->client->floating_rectangle.width += ds;
216 n->client->floating_rectangle.height += ds;
219 if (borderless_monocle && is_tiled(n->client) && d->layout == LAYOUT_MONOCLE)
220 n->client->border_width = 0;
222 n->client->border_width = border_width;
225 if (is_tiled(n->client)) {
226 if (d->layout == LAYOUT_TILED)
228 else if (d->layout == LAYOUT_MONOCLE)
230 int wg = (gapless_monocle && d->layout == LAYOUT_MONOCLE ? 0 : window_gap);
231 int bleed = wg + 2 * n->client->border_width;
232 r.width = (bleed < r.width ? r.width - bleed : 1);
233 r.height = (bleed < r.height ? r.height - bleed : 1);
234 n->client->tiled_rectangle = r;
236 r = n->client->floating_rectangle;
239 window_move_resize(n->client->window, r.x, r.y, r.width, r.height);
240 window_border_width(n->client->window, n->client->border_width);
241 window_draw_border(n, n == d->focus, m == mon);
244 xcb_rectangle_t first_rect;
245 xcb_rectangle_t second_rect;
247 if (n->first_child->vacant || n->second_child->vacant) {
248 first_rect = second_rect = rect;
251 if (n->split_type == TYPE_VERTICAL) {
252 fence = rect.width * n->split_ratio;
253 first_rect = (xcb_rectangle_t) {rect.x, rect.y, fence, rect.height};
254 second_rect = (xcb_rectangle_t) {rect.x + fence, rect.y, rect.width - fence, rect.height};
256 } else if (n->split_type == TYPE_HORIZONTAL) {
257 fence = rect.height * n->split_ratio;
258 first_rect = (xcb_rectangle_t) {rect.x, rect.y, rect.width, fence};
259 second_rect = (xcb_rectangle_t) {rect.x, rect.y + fence, rect.width, rect.height - fence};
263 apply_layout(m, d, n->first_child, first_rect, root_rect);
264 apply_layout(m, d, n->second_child, second_rect, root_rect);
268 void insert_node(monitor_t *m, desktop_t *d, node_t *n)
270 if (d == NULL || n == NULL)
273 PRINTF("insert node %X\n", n->client->window);
275 node_t *focus = d->focus;
280 node_t *dad = make_node();
281 node_t *fopar = focus->parent;
283 n->client->born_as = split_mode;
284 switch (split_mode) {
287 dad->first_child = n;
288 dad->second_child = focus;
289 if (m->rectangle.width > m->rectangle.height)
290 dad->split_type = TYPE_VERTICAL;
292 dad->split_type = TYPE_HORIZONTAL;
296 node_t *grandpa = fopar->parent;
297 dad->parent = grandpa;
298 if (grandpa != NULL) {
299 if (is_first_child(fopar))
300 grandpa->first_child = dad;
302 grandpa->second_child = dad;
306 dad->split_type = fopar->split_type;
307 dad->split_ratio = fopar->split_ratio;
309 if (is_first_child(focus)) {
310 dad->first_child = n;
311 dad->second_child = fopar;
312 rotate_tree(fopar, ROTATE_CLOCKWISE);
314 dad->first_child = fopar;
315 dad->second_child = n;
316 rotate_tree(fopar, ROTATE_COUNTER_CLOCKWISE);
322 if (is_first_child(focus))
323 fopar->first_child = dad;
325 fopar->second_child = dad;
327 dad->split_ratio = focus->split_ratio;
332 dad->split_type = TYPE_VERTICAL;
333 dad->first_child = n;
334 dad->second_child = focus;
337 dad->split_type = TYPE_VERTICAL;
338 dad->first_child = focus;
339 dad->second_child = n;
342 dad->split_type = TYPE_HORIZONTAL;
343 dad->first_child = n;
344 dad->second_child = focus;
347 dad->split_type = TYPE_HORIZONTAL;
348 dad->first_child = focus;
349 dad->second_child = n;
352 if (d->root == focus)
354 split_mode = MODE_AUTOMATIC;
358 update_vacant_state(fopar);
362 void focus_node(monitor_t *m, desktop_t *d, node_t *n, bool is_mapped)
367 PRINTF("focus node %X\n", n->client->window);
369 split_mode = MODE_AUTOMATIC;
370 n->client->urgent = false;
374 for (desktop_t *cd = mon->desk_head; cd != NULL; cd = cd->next)
375 window_draw_border(cd->focus, true, false);
376 for (desktop_t *cd = m->desk_head; cd != NULL; cd = cd->next)
378 window_draw_border(cd->focus, true, true);
380 window_draw_border(n, true, true);
383 window_draw_border(d->focus, false, true);
384 window_draw_border(n, true, true);
386 xcb_set_input_focus(dpy, XCB_INPUT_FOCUS_POINTER_ROOT, n->client->window, XCB_CURRENT_TIME);
389 if (focus_follows_pointer) {
390 xcb_window_t win = XCB_NONE;
391 query_pointer(&win, NULL);
392 if (win != n->client->window)
393 enable_motion_recorder();
395 disable_motion_recorder();
398 if (!is_tiled(n->client)) {
399 if (!adaptative_raise || !might_cover(d, n))
400 window_raise(n->client->window);
402 window_pseudo_raise(d, n->client->window);
406 d->last_focus = d->focus;
410 ewmh_update_active_window();
414 void update_current(void)
416 if (mon->desk->focus == NULL)
417 ewmh_update_active_window();
419 focus_node(mon, mon->desk, mon->desk->focus, true);
423 void unlink_node(desktop_t *d, node_t *n)
425 if (d == NULL || n == NULL)
428 PRINTF("unlink node %X\n", n->client->window);
430 node_t *p = n->parent;
435 d->last_focus = NULL;
438 node_t *g = p->parent;
439 bool n_first_child = is_first_child(n);
442 if (n->client->born_as == MODE_AUTOMATIC)
443 rotate_tree(b, ROTATE_COUNTER_CLOCKWISE);
446 if (n->client->born_as == MODE_AUTOMATIC)
447 rotate_tree(b, ROTATE_CLOCKWISE);
451 if (is_first_child(p))
462 if (n == d->last_focus) {
463 d->last_focus = NULL;
464 } else if (n == d->focus) {
465 if (d->last_focus != NULL)
466 d->focus = d->last_focus;
468 d->focus = (n_first_child ? first_extrema(b) : second_extrema(b));
469 d->last_focus = NULL;
472 update_vacant_state(b->parent);
476 void remove_node(desktop_t *d, node_t *n)
478 if (d == NULL || n == NULL)
481 PRINTF("remove node %X\n", n->client->window);
488 ewmh_update_client_list();
494 void destroy_tree(node_t *n)
498 node_t *first_tree = n->first_child;
499 node_t *second_tree = n->second_child;
500 if (n->client != NULL)
503 destroy_tree(first_tree);
504 destroy_tree(second_tree);
507 void swap_nodes(desktop_t *d1, node_t *n1, desktop_t *d2, node_t *n2)
509 if (n1 == NULL || n2 == NULL || n1 == n2)
514 /* (n1 and n2 are leaves) */
515 node_t *pn1 = n1->parent;
516 node_t *pn2 = n2->parent;
517 bool n1_first_child = is_first_child(n1);
518 bool n2_first_child = is_first_child(n2);
522 pn1->first_child = n2;
524 pn1->second_child = n2;
529 pn2->first_child = n1;
531 pn2->second_child = n1;
537 if (n1->vacant != n2->vacant) {
538 update_vacant_state(n1->parent);
539 update_vacant_state(n2->parent);
547 if (d1->last_focus == n1)
553 if (d2->last_focus == n2)
558 void transfer_node(monitor_t *ms, desktop_t *ds, monitor_t *md, desktop_t *dd, node_t *n)
560 if (n == NULL || ds == NULL || dd == NULL || ms == NULL || md == NULL || (ms == md && dd == ds))
563 PRINTF("transfer node %X\n", n->client->window);
566 insert_node(md, dd, n);
567 ewmh_set_wm_desktop(n, dd);
569 if (ds == ms->desk && dd != md->desk) {
570 window_hide(n->client->window);
573 fit_monitor(md, n->client);
575 if (n->client->fullscreen)
576 window_move_resize(n->client->window, md->rectangle.x, md->rectangle.y, md->rectangle.width, md->rectangle.height);
578 if (ds != ms->desk && dd == md->desk) {
579 window_show(n->client->window);
580 focus_node(md, dd, n, true);
582 focus_node(md, dd, n, false);
585 if (ds == ms->desk || dd == md->desk)
589 void select_monitor(monitor_t *m)
591 if (m == NULL || mon == m)
594 PRINTF("select monitor %s\n", m->name);
596 focus_node(m, m->desk, m->desk->focus, true);
601 ewmh_update_current_desktop();
605 void select_desktop(desktop_t *d)
607 if (d == NULL || d == mon->desk)
610 PRINTF("select desktop %s\n", d->name);
613 node_t *n = first_extrema(d->root);
616 window_show(n->client->window);
620 n = first_extrema(mon->desk->root);
623 window_hide(n->client->window);
628 mon->last_desk = mon->desk;
632 ewmh_update_current_desktop();
636 void cycle_monitor(cycle_dir_t dir)
638 if (dir == CYCLE_NEXT)
639 select_monitor((mon->next == NULL ? mon_head : mon->next));
640 else if (dir == CYCLE_PREV)
641 select_monitor((mon->prev == NULL ? mon_tail : mon->prev));
644 void cycle_desktop(monitor_t *m, desktop_t *d, cycle_dir_t dir, skip_desktop_t skip)
646 desktop_t *f = (dir == CYCLE_PREV ? d->prev : d->next);
648 f = (dir == CYCLE_PREV ? m->desk_tail : m->desk_head);
651 if (skip == DESKTOP_SKIP_NONE
652 || (skip == DESKTOP_SKIP_FREE && f->root != NULL)
653 || (skip == DESKTOP_SKIP_OCCUPIED && f->root == NULL)) {
657 f = (dir == CYCLE_PREV ? f->prev : f->next);
659 f = (dir == CYCLE_PREV ? m->desk_tail : m->desk_head);
663 void cycle_leaf(monitor_t *m, desktop_t *d, node_t *n, cycle_dir_t dir, skip_client_t skip)
670 node_t *f = (dir == CYCLE_PREV ? prev_leaf(n) : next_leaf(n));
672 f = (dir == CYCLE_PREV ? second_extrema(d->root) : first_extrema(d->root));
675 bool tiled = is_tiled(f->client);
676 if (skip == CLIENT_SKIP_NONE || (skip == CLIENT_SKIP_TILED && !tiled) || (skip == CLIENT_SKIP_FLOATING && tiled)
677 || (skip == CLIENT_SKIP_CLASS_DIFFER && strcmp(f->client->class_name, n->client->class_name) == 0)
678 || (skip == CLIENT_SKIP_CLASS_EQUAL && strcmp(f->client->class_name, n->client->class_name) != 0)) {
679 focus_node(m, d, f, true);
682 f = (dir == CYCLE_PREV ? prev_leaf(f) : next_leaf(f));
684 f = (dir == CYCLE_PREV ? second_extrema(d->root) : first_extrema(d->root));
688 void nearest_leaf(monitor_t *m, desktop_t *d, node_t *n, nearest_arg_t dir, skip_client_t skip)
693 PUTS("nearest leaf");
697 for (node_t *f = first_extrema(d->root); f != NULL; f = next_leaf(f))
698 if (skip == CLIENT_SKIP_NONE || (skip == CLIENT_SKIP_TILED && !is_tiled(f->client)) || (skip == CLIENT_SKIP_FLOATING && is_tiled(f->client))
699 || (skip == CLIENT_SKIP_CLASS_DIFFER && strcmp(f->client->class_name, n->client->class_name) == 0)
700 || (skip == CLIENT_SKIP_CLASS_EQUAL && strcmp(f->client->class_name, n->client->class_name) != 0))
701 if ((dir == NEAREST_OLDER
702 && (f->client->uid < n->client->uid)
703 && (x == NULL || f->client->uid > x->client->uid))
704 || (dir == NEAREST_NEWER
705 && (f->client->uid > n->client->uid)
706 && (x == NULL || f->client->uid < x->client->uid)))
709 focus_node(m, d, x, true);
712 void circulate_leaves(monitor_t *m, desktop_t *d, circulate_dir_t dir) {
713 if (d == NULL || d->root == NULL || is_leaf(d->root))
715 node_t *par = d->focus->parent;
716 bool focus_first_child = is_first_child(d->focus);
717 if (dir == CIRCULATE_FORWARD)
718 for (node_t *s = second_extrema(d->root), *f = prev_leaf(s); f != NULL; s = prev_leaf(f), f = prev_leaf(s))
719 swap_nodes(d, f, d, s);
721 for (node_t *f = first_extrema(d->root), *s = next_leaf(f); s != NULL; f = next_leaf(s), s = next_leaf(f))
722 swap_nodes(d, f, d, s);
723 if (focus_first_child)
724 focus_node(m, d, par->first_child, true);
726 focus_node(m, d, par->second_child, true);
729 void update_vacant_state(node_t *n)
734 PUTS("update vacant state");
736 /* n is not a leaf */
740 p->vacant = (p->first_child->vacant && p->second_child->vacant);
745 void fit_monitor(monitor_t *m, client_t *c)
747 xcb_rectangle_t crect = c->floating_rectangle;
748 xcb_rectangle_t mrect = m->rectangle;
749 while (crect.x < mrect.x)
750 crect.x += mrect.width;
751 while (crect.x > (mrect.x + mrect.width - 1))
752 crect.x -= mrect.width;
753 while (crect.y < mrect.y)
754 crect.y += mrect.height;
755 while (crect.y > (mrect.y + mrect.height - 1))
756 crect.y -= mrect.height;
757 c->floating_rectangle = crect;
760 void put_status(void)
762 if (status_fifo == NULL)
765 for (monitor_t *m = mon_head; m != NULL; m = m->next) {
766 fprintf(status_fifo, "%c%s:", (mon == m ? 'M' : 'm'), m->name);
767 for (desktop_t *d = m->desk_head; d != NULL; d = d->next, urgent = false) {
768 for (node_t *n = first_extrema(d->root); n != NULL && !urgent; n = next_leaf(n))
769 urgent |= n->client->urgent;
770 fprintf(status_fifo, "%c%c%s:", (m->desk == d ? 'D' : (d->root != NULL ? 'd' : '_')), (urgent ? '!' : '_'), d->name);
773 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));
777 void list_monitors(list_option_t opt, char *rsp)
780 for (monitor_t *m = mon_head; m != NULL; m = m->next) {
781 snprintf(line, sizeof(line), "%s %ux%u%+i%+i", m->name, m->rectangle.width, m->rectangle.height, m->rectangle.x, m->rectangle.y);
782 strncat(rsp, line, REMLEN(rsp));
784 strncat(rsp, " #\n", REMLEN(rsp));
785 else if (m == last_mon)
786 strncat(rsp, " ~\n", REMLEN(rsp));
788 strncat(rsp, "\n", REMLEN(rsp));
789 if (opt == LIST_OPTION_VERBOSE)
790 list_desktops(m, opt, 1, rsp);
794 void list_desktops(monitor_t *m, list_option_t opt, unsigned int depth, char *rsp)
797 for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
798 for (unsigned int i = 0; i < depth; i++)
799 strncat(rsp, " ", REMLEN(rsp));
800 snprintf(line, sizeof(line), "%s %c", d->name, (d->layout == LAYOUT_TILED ? 'T' : 'M'));
801 strncat(rsp, line, REMLEN(rsp));
803 strncat(rsp, " @\n", REMLEN(rsp));
804 else if (d == m->last_desk)
805 strncat(rsp, " ~\n", REMLEN(rsp));
807 strncat(rsp, "\n", REMLEN(rsp));
808 if (opt == LIST_OPTION_VERBOSE)
809 list(d, d->root, rsp, depth + 1);
813 void list(desktop_t *d, node_t *n, char *rsp, unsigned int depth)
820 for (unsigned int i = 0; i < depth; i++)
821 strncat(rsp, " ", REMLEN(rsp));
824 client_t *c = n->client;
825 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' : '-'));
827 snprintf(line, sizeof(line), "%c %.2f", (n->split_type == TYPE_HORIZONTAL ? 'H' : 'V'), n->split_ratio);
830 strncat(rsp, line, REMLEN(rsp));
833 strncat(rsp, " *\n", REMLEN(rsp));
834 else if (n == d->last_focus)
835 strncat(rsp, " ~\n", REMLEN(rsp));
837 strncat(rsp, "\n", REMLEN(rsp));
839 list(d, n->first_child, rsp, depth + 1);
840 list(d, n->second_child, rsp, depth + 1);
843 void restore(char *file_path)
845 if (file_path == NULL)
848 FILE *snapshot = fopen(file_path, "r");
849 if (snapshot == NULL) {
850 warn("restore: can't open file\n");
859 unsigned int level, last_level = 0, max_uid = 0;
860 bool aborted = false;
862 while (!aborted && fgets(line, sizeof(line), snapshot) != NULL) {
863 unsigned int len = strlen(line);
865 while (level < strlen(line) && isspace(line[level]))
873 switch (line[len - 2]) {
881 } else if (level == 2) {
887 while (i > 0 && !isupper(line[i]))
890 d->layout = LAYOUT_MONOCLE;
891 else if (line[i] == 'T')
892 d->layout = LAYOUT_TILED;
894 switch (line[len - 2]) {
903 node_t *birth = make_node();
908 if (level > last_level) {
909 n->first_child = birth;
913 } while (n != NULL && n->second_child != NULL);
915 warn("restore: file is malformed\n");
918 n->second_child = birth;
924 if (isupper(line[level])) {
926 sscanf(line + level, "%c %lf", &st, &n->split_ratio);
928 n->split_type = TYPE_HORIZONTAL;
930 n->split_type = TYPE_VERTICAL;
932 client_t *c = make_client(XCB_NONE);
934 char ba, floating, transient, fullscreen, urgent, locked;
935 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);
937 c->born_as = MODE_AUTOMATIC;
939 c->born_as = MODE_MANUAL;
940 c->floating = (floating == '-' ? false : true);
941 c->transient = (transient == '-' ? false : true);
942 c->fullscreen = (fullscreen == '-' ? false : true);
943 c->urgent = (urgent == '-' ? false : true);
944 c->locked = (locked == '-' ? false : true);
945 if (c->uid > max_uid)
949 switch (line[len - 2]) {
963 client_uid = max_uid + 1;
964 for (monitor_t *m = mon_head; m != NULL; m = m->next)
965 for (desktop_t *d = m->desk_head; d != NULL; d = d->next)
966 for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n)) {
967 uint32_t values[] = {(focus_follows_pointer ? CLIENT_EVENT_MASK_FFP : CLIENT_EVENT_MASK)};
968 xcb_change_window_attributes(dpy, n->client->window, XCB_CW_EVENT_MASK, values);
969 if (n->client->floating) {
971 update_vacant_state(n->parent);