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 int tiled_area(node_t *n)
133 xcb_rectangle_t rect = n->client->tiled_rectangle;
134 return rect.width * rect.height;
137 node_t *find_by_area(desktop_t *d, swap_arg_t a)
143 int r_area = tiled_area(r);
145 for (node_t *f = first_extrema(d->root); f != NULL; f = next_leaf(f)) {
146 int f_area = tiled_area(f);
150 } else if ((a == SWAP_BIGGEST && f_area > r_area)
151 || (a == SWAP_SMALLEST && f_area < r_area)) {
160 void move_fence(node_t *n, direction_t dir, fence_move_t mov)
162 node_t *fence = find_fence(n, dir);
167 if ((mov == MOVE_PUSH && (dir == DIR_RIGHT || dir == DIR_DOWN))
168 || (mov == MOVE_PULL && (dir == DIR_LEFT || dir == DIR_UP)))
169 change_split_ratio(fence, CHANGE_INCREASE);
171 change_split_ratio(fence, CHANGE_DECREASE);
174 void rotate_tree(node_t *n, rotate_t rot)
176 if (n == NULL || is_leaf(n))
181 if ((rot == ROTATE_CLOCKWISE && n->split_type == TYPE_HORIZONTAL)
182 || (rot == ROTATE_COUNTER_CLOCKWISE && n->split_type == TYPE_VERTICAL)
183 || rot == ROTATE_FULL_CYCLE) {
184 tmp = n->first_child;
185 n->first_child = n->second_child;
186 n->second_child = tmp;
187 n->split_ratio = 1.0 - n->split_ratio;
190 if (rot != ROTATE_FULL_CYCLE) {
191 if (n->split_type == TYPE_HORIZONTAL)
192 n->split_type = TYPE_VERTICAL;
193 else if (n->split_type == TYPE_VERTICAL)
194 n->split_type = TYPE_HORIZONTAL;
197 rotate_tree(n->first_child, rot);
198 rotate_tree(n->second_child, rot);
201 void flip_tree(node_t *n, flip_t flp)
203 if (n == NULL || is_leaf(n))
208 if ((flp == FLIP_HORIZONTAL && n->split_type == TYPE_HORIZONTAL)
209 || (flp == FLIP_VERTICAL && n->split_type == TYPE_VERTICAL)) {
210 tmp = n->first_child;
211 n->first_child = n->second_child;
212 n->second_child = tmp;
213 n->split_ratio = 1.0 - n->split_ratio;
216 flip_tree(n->first_child, flp);
217 flip_tree(n->second_child, flp);
220 int balance_tree(node_t *n)
222 if (n == NULL || n->vacant) {
224 } else if (is_leaf(n)) {
227 int b1 = balance_tree(n->first_child);
228 int b2 = balance_tree(n->second_child);
230 if (b1 > 0 && b2 > 0)
231 n->split_ratio = (double) b1 / b;
236 void arrange(monitor_t *m, desktop_t *d)
238 PRINTF("arrange %s%s%s\n", (num_monitors > 1 ? m->name : ""), (num_monitors > 1 ? " " : ""), d->name);
240 xcb_rectangle_t rect = m->rectangle;
241 int wg = (gapless_monocle && d->layout == LAYOUT_MONOCLE ? 0 : window_gap);
242 rect.x += m->left_padding + wg;
243 rect.y += m->top_padding + wg;
244 rect.width -= m->left_padding + m->right_padding + wg;
245 rect.height -= m->top_padding + m->bottom_padding + wg;
246 apply_layout(m, d, d->root, rect, rect);
249 void apply_layout(monitor_t *m, desktop_t *d, node_t *n, xcb_rectangle_t rect, xcb_rectangle_t root_rect)
257 if (n->client->fullscreen)
260 if (is_floating(n->client) && n->client->border_width != border_width) {
261 int ds = 2 * (border_width - n->client->border_width);
262 n->client->floating_rectangle.width += ds;
263 n->client->floating_rectangle.height += ds;
266 if (borderless_monocle && is_tiled(n->client) && d->layout == LAYOUT_MONOCLE)
267 n->client->border_width = 0;
269 n->client->border_width = border_width;
272 if (is_tiled(n->client)) {
273 if (d->layout == LAYOUT_TILED)
275 else if (d->layout == LAYOUT_MONOCLE)
277 int wg = (gapless_monocle && d->layout == LAYOUT_MONOCLE ? 0 : window_gap);
278 int bleed = wg + 2 * n->client->border_width;
279 r.width = (bleed < r.width ? r.width - bleed : 1);
280 r.height = (bleed < r.height ? r.height - bleed : 1);
281 n->client->tiled_rectangle = r;
283 r = n->client->floating_rectangle;
286 window_move_resize(n->client->window, r.x, r.y, r.width, r.height);
287 window_border_width(n->client->window, n->client->border_width);
288 window_draw_border(n, n == d->focus, m == mon);
291 xcb_rectangle_t first_rect;
292 xcb_rectangle_t second_rect;
294 if (n->first_child->vacant || n->second_child->vacant) {
295 first_rect = second_rect = rect;
298 if (n->split_type == TYPE_VERTICAL) {
299 fence = rect.width * n->split_ratio;
300 first_rect = (xcb_rectangle_t) {rect.x, rect.y, fence, rect.height};
301 second_rect = (xcb_rectangle_t) {rect.x + fence, rect.y, rect.width - fence, rect.height};
303 } else if (n->split_type == TYPE_HORIZONTAL) {
304 fence = rect.height * n->split_ratio;
305 first_rect = (xcb_rectangle_t) {rect.x, rect.y, rect.width, fence};
306 second_rect = (xcb_rectangle_t) {rect.x, rect.y + fence, rect.width, rect.height - fence};
310 apply_layout(m, d, n->first_child, first_rect, root_rect);
311 apply_layout(m, d, n->second_child, second_rect, root_rect);
315 void insert_node(monitor_t *m, desktop_t *d, node_t *n)
317 if (d == NULL || n == NULL)
320 PRINTF("insert node %X\n", n->client->window);
322 node_t *focus = d->focus;
327 node_t *dad = make_node();
328 node_t *fopar = focus->parent;
330 n->client->born_as = split_mode;
331 switch (split_mode) {
334 dad->first_child = n;
335 dad->second_child = focus;
336 if (m->rectangle.width > m->rectangle.height)
337 dad->split_type = TYPE_VERTICAL;
339 dad->split_type = TYPE_HORIZONTAL;
343 node_t *grandpa = fopar->parent;
344 dad->parent = grandpa;
345 if (grandpa != NULL) {
346 if (is_first_child(fopar))
347 grandpa->first_child = dad;
349 grandpa->second_child = dad;
353 dad->split_type = fopar->split_type;
354 dad->split_ratio = fopar->split_ratio;
356 if (is_first_child(focus)) {
357 dad->first_child = n;
358 dad->second_child = fopar;
359 rotate_tree(fopar, ROTATE_CLOCKWISE);
361 dad->first_child = fopar;
362 dad->second_child = n;
363 rotate_tree(fopar, ROTATE_COUNTER_CLOCKWISE);
369 if (is_first_child(focus))
370 fopar->first_child = dad;
372 fopar->second_child = dad;
374 dad->split_ratio = focus->split_ratio;
379 dad->split_type = TYPE_VERTICAL;
380 dad->first_child = n;
381 dad->second_child = focus;
384 dad->split_type = TYPE_VERTICAL;
385 dad->first_child = focus;
386 dad->second_child = n;
389 dad->split_type = TYPE_HORIZONTAL;
390 dad->first_child = n;
391 dad->second_child = focus;
394 dad->split_type = TYPE_HORIZONTAL;
395 dad->first_child = focus;
396 dad->second_child = n;
399 if (d->root == focus)
401 split_mode = MODE_AUTOMATIC;
405 update_vacant_state(fopar);
409 void focus_node(monitor_t *m, desktop_t *d, node_t *n, bool is_mapped)
414 PRINTF("focus node %X\n", n->client->window);
416 split_mode = MODE_AUTOMATIC;
417 n->client->urgent = false;
421 for (desktop_t *cd = mon->desk_head; cd != NULL; cd = cd->next)
422 window_draw_border(cd->focus, true, false);
423 for (desktop_t *cd = m->desk_head; cd != NULL; cd = cd->next)
425 window_draw_border(cd->focus, true, true);
427 window_draw_border(n, true, true);
430 window_draw_border(d->focus, false, true);
431 window_draw_border(n, true, true);
433 xcb_set_input_focus(dpy, XCB_INPUT_FOCUS_POINTER_ROOT, n->client->window, XCB_CURRENT_TIME);
436 if (!is_tiled(n->client)) {
437 if (!adaptative_raise || !might_cover(d, n))
438 window_raise(n->client->window);
440 window_pseudo_raise(d, n->client->window);
443 if (focus_follows_pointer) {
444 xcb_window_t win = XCB_NONE;
445 query_pointer(&win, NULL);
446 if (win != n->client->window)
447 enable_motion_recorder();
449 disable_motion_recorder();
453 d->last_focus = d->focus;
457 ewmh_update_active_window();
461 void update_current(void)
463 if (mon->desk->focus == NULL)
464 ewmh_update_active_window();
466 focus_node(mon, mon->desk, mon->desk->focus, true);
470 void unlink_node(desktop_t *d, node_t *n)
472 if (d == NULL || n == NULL)
475 PRINTF("unlink node %X\n", n->client->window);
477 node_t *p = n->parent;
482 d->last_focus = NULL;
485 node_t *g = p->parent;
486 bool n_first_child = is_first_child(n);
489 if (n->client->born_as == MODE_AUTOMATIC)
490 rotate_tree(b, ROTATE_COUNTER_CLOCKWISE);
493 if (n->client->born_as == MODE_AUTOMATIC)
494 rotate_tree(b, ROTATE_CLOCKWISE);
498 if (is_first_child(p))
509 if (n == d->last_focus) {
510 d->last_focus = NULL;
511 } else if (n == d->focus) {
512 if (d->last_focus != NULL)
513 d->focus = d->last_focus;
515 d->focus = (n_first_child ? first_extrema(b) : second_extrema(b));
516 d->last_focus = NULL;
519 update_vacant_state(b->parent);
523 void remove_node(desktop_t *d, node_t *n)
525 if (d == NULL || n == NULL)
528 PRINTF("remove node %X\n", n->client->window);
535 ewmh_update_client_list();
541 void destroy_tree(node_t *n)
545 node_t *first_tree = n->first_child;
546 node_t *second_tree = n->second_child;
547 if (n->client != NULL)
550 destroy_tree(first_tree);
551 destroy_tree(second_tree);
554 void swap_nodes(desktop_t *d1, node_t *n1, desktop_t *d2, node_t *n2)
556 if (n1 == NULL || n2 == NULL || n1 == n2)
561 /* (n1 and n2 are leaves) */
562 node_t *pn1 = n1->parent;
563 node_t *pn2 = n2->parent;
564 bool n1_first_child = is_first_child(n1);
565 bool n2_first_child = is_first_child(n2);
569 pn1->first_child = n2;
571 pn1->second_child = n2;
576 pn2->first_child = n1;
578 pn2->second_child = n1;
584 if (n1->vacant != n2->vacant) {
585 update_vacant_state(n1->parent);
586 update_vacant_state(n2->parent);
594 if (d1->last_focus == n1)
600 if (d2->last_focus == n2)
605 void transfer_node(monitor_t *ms, desktop_t *ds, monitor_t *md, desktop_t *dd, node_t *n)
607 if (n == NULL || ds == NULL || dd == NULL || ms == NULL || md == NULL || (ms == md && dd == ds))
610 PRINTF("transfer node %X\n", n->client->window);
613 insert_node(md, dd, n);
614 ewmh_set_wm_desktop(n, dd);
616 if (ds == ms->desk && dd != md->desk) {
619 window_hide(n->client->window);
622 fit_monitor(md, n->client);
624 if (n->client->fullscreen)
625 window_move_resize(n->client->window, md->rectangle.x, md->rectangle.y, md->rectangle.width, md->rectangle.height);
627 if (ds != ms->desk && dd == md->desk) {
628 window_show(n->client->window);
629 focus_node(md, dd, n, true);
631 focus_node(md, dd, n, false);
634 if (ds == ms->desk || dd == md->desk)
638 void select_monitor(monitor_t *m)
640 if (m == NULL || mon == m)
643 PRINTF("select monitor %s\n", m->name);
645 focus_node(m, m->desk, m->desk->focus, true);
650 ewmh_update_current_desktop();
654 void select_desktop(desktop_t *d)
656 if (d == NULL || d == mon->desk)
659 PRINTF("select desktop %s\n", d->name);
664 node_t *n = first_extrema(d->root);
667 window_show(n->client->window);
671 n = first_extrema(mon->desk->root);
674 window_hide(n->client->window);
679 mon->last_desk = mon->desk;
683 ewmh_update_current_desktop();
687 void cycle_monitor(cycle_dir_t dir)
689 if (dir == CYCLE_NEXT)
690 select_monitor((mon->next == NULL ? mon_head : mon->next));
691 else if (dir == CYCLE_PREV)
692 select_monitor((mon->prev == NULL ? mon_tail : mon->prev));
695 void cycle_desktop(monitor_t *m, desktop_t *d, cycle_dir_t dir, skip_desktop_t skip)
697 desktop_t *f = (dir == CYCLE_PREV ? d->prev : d->next);
699 f = (dir == CYCLE_PREV ? m->desk_tail : m->desk_head);
702 if (skip == DESKTOP_SKIP_NONE
703 || (skip == DESKTOP_SKIP_FREE && f->root != NULL)
704 || (skip == DESKTOP_SKIP_OCCUPIED && f->root == NULL)) {
708 f = (dir == CYCLE_PREV ? f->prev : f->next);
710 f = (dir == CYCLE_PREV ? m->desk_tail : m->desk_head);
714 void cycle_leaf(monitor_t *m, desktop_t *d, node_t *n, cycle_dir_t dir, skip_client_t skip)
721 node_t *f = (dir == CYCLE_PREV ? prev_leaf(n) : next_leaf(n));
723 f = (dir == CYCLE_PREV ? second_extrema(d->root) : first_extrema(d->root));
726 bool tiled = is_tiled(f->client);
727 if (skip == CLIENT_SKIP_NONE || (skip == CLIENT_SKIP_TILED && !tiled) || (skip == CLIENT_SKIP_FLOATING && tiled)
728 || (skip == CLIENT_SKIP_CLASS_DIFFER && strcmp(f->client->class_name, n->client->class_name) == 0)
729 || (skip == CLIENT_SKIP_CLASS_EQUAL && strcmp(f->client->class_name, n->client->class_name) != 0)) {
730 focus_node(m, d, f, true);
733 f = (dir == CYCLE_PREV ? prev_leaf(f) : next_leaf(f));
735 f = (dir == CYCLE_PREV ? second_extrema(d->root) : first_extrema(d->root));
739 void nearest_leaf(monitor_t *m, desktop_t *d, node_t *n, nearest_arg_t dir, skip_client_t skip)
744 PUTS("nearest leaf");
748 for (node_t *f = first_extrema(d->root); f != NULL; f = next_leaf(f))
749 if (skip == CLIENT_SKIP_NONE || (skip == CLIENT_SKIP_TILED && !is_tiled(f->client)) || (skip == CLIENT_SKIP_FLOATING && is_tiled(f->client))
750 || (skip == CLIENT_SKIP_CLASS_DIFFER && strcmp(f->client->class_name, n->client->class_name) == 0)
751 || (skip == CLIENT_SKIP_CLASS_EQUAL && strcmp(f->client->class_name, n->client->class_name) != 0))
752 if ((dir == NEAREST_OLDER
753 && (f->client->uid < n->client->uid)
754 && (x == NULL || f->client->uid > x->client->uid))
755 || (dir == NEAREST_NEWER
756 && (f->client->uid > n->client->uid)
757 && (x == NULL || f->client->uid < x->client->uid)))
760 focus_node(m, d, x, true);
763 void circulate_leaves(monitor_t *m, desktop_t *d, circulate_dir_t dir) {
764 if (d == NULL || d->root == NULL || is_leaf(d->root))
766 node_t *par = d->focus->parent;
767 bool focus_first_child = is_first_child(d->focus);
768 if (dir == CIRCULATE_FORWARD)
769 for (node_t *s = second_extrema(d->root), *f = prev_leaf(s); f != NULL; s = prev_leaf(f), f = prev_leaf(s))
770 swap_nodes(d, f, d, s);
772 for (node_t *f = first_extrema(d->root), *s = next_leaf(f); s != NULL; f = next_leaf(s), s = next_leaf(f))
773 swap_nodes(d, f, d, s);
774 if (focus_first_child)
775 focus_node(m, d, par->first_child, true);
777 focus_node(m, d, par->second_child, true);
780 void update_vacant_state(node_t *n)
785 PUTS("update vacant state");
787 /* n is not a leaf */
791 p->vacant = (p->first_child->vacant && p->second_child->vacant);
796 void fit_monitor(monitor_t *m, client_t *c)
798 xcb_rectangle_t crect = c->floating_rectangle;
799 xcb_rectangle_t mrect = m->rectangle;
800 while (crect.x < mrect.x)
801 crect.x += mrect.width;
802 while (crect.x > (mrect.x + mrect.width - 1))
803 crect.x -= mrect.width;
804 while (crect.y < mrect.y)
805 crect.y += mrect.height;
806 while (crect.y > (mrect.y + mrect.height - 1))
807 crect.y -= mrect.height;
808 c->floating_rectangle = crect;
811 void put_status(void)
813 if (status_fifo == NULL)
815 if (status_prefix != NULL)
816 fprintf(status_fifo, "%s", status_prefix);
818 for (monitor_t *m = mon_head; m != NULL; m = m->next) {
819 fprintf(status_fifo, "%c%s:", (mon == m ? 'M' : 'm'), m->name);
820 for (desktop_t *d = m->desk_head; d != NULL; d = d->next, urgent = false) {
821 for (node_t *n = first_extrema(d->root); n != NULL && !urgent; n = next_leaf(n))
822 urgent |= n->client->urgent;
823 fprintf(status_fifo, "%c%c%s:", (m->desk == d ? 'D' : (d->root != NULL ? 'd' : '_')), (urgent ? '!' : '_'), d->name);
826 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));
830 void list_monitors(list_option_t opt, char *rsp)
833 for (monitor_t *m = mon_head; m != NULL; m = m->next) {
834 snprintf(line, sizeof(line), "%s %ux%u%+i%+i", m->name, m->rectangle.width, m->rectangle.height, m->rectangle.x, m->rectangle.y);
835 strncat(rsp, line, REMLEN(rsp));
837 strncat(rsp, " #\n", REMLEN(rsp));
838 else if (m == last_mon)
839 strncat(rsp, " ~\n", REMLEN(rsp));
841 strncat(rsp, "\n", REMLEN(rsp));
842 if (opt == LIST_OPTION_VERBOSE)
843 list_desktops(m, opt, 1, rsp);
847 void list_desktops(monitor_t *m, list_option_t opt, unsigned int depth, char *rsp)
850 for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
851 for (unsigned int i = 0; i < depth; i++)
852 strncat(rsp, " ", REMLEN(rsp));
853 snprintf(line, sizeof(line), "%s %c", d->name, (d->layout == LAYOUT_TILED ? 'T' : 'M'));
854 strncat(rsp, line, REMLEN(rsp));
856 strncat(rsp, " @\n", REMLEN(rsp));
857 else if (d == m->last_desk)
858 strncat(rsp, " ~\n", REMLEN(rsp));
860 strncat(rsp, "\n", REMLEN(rsp));
861 if (opt == LIST_OPTION_VERBOSE)
862 list(d, d->root, rsp, depth + 1);
866 void list(desktop_t *d, node_t *n, char *rsp, unsigned int depth)
873 for (unsigned int i = 0; i < depth; i++)
874 strncat(rsp, " ", REMLEN(rsp));
877 client_t *c = n->client;
878 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' : '-'));
880 snprintf(line, sizeof(line), "%c %.2f", (n->split_type == TYPE_HORIZONTAL ? 'H' : 'V'), n->split_ratio);
883 strncat(rsp, line, REMLEN(rsp));
886 strncat(rsp, " *\n", REMLEN(rsp));
887 else if (n == d->last_focus)
888 strncat(rsp, " ~\n", REMLEN(rsp));
890 strncat(rsp, "\n", REMLEN(rsp));
892 list(d, n->first_child, rsp, depth + 1);
893 list(d, n->second_child, rsp, depth + 1);
896 void restore(char *file_path)
898 if (file_path == NULL)
901 FILE *snapshot = fopen(file_path, "r");
902 if (snapshot == NULL) {
903 warn("restore: can't open file\n");
912 unsigned int level, last_level = 0, max_uid = 0;
913 bool aborted = false;
915 while (!aborted && fgets(line, sizeof(line), snapshot) != NULL) {
916 unsigned int len = strlen(line);
918 while (level < strlen(line) && isspace(line[level]))
926 switch (line[len - 2]) {
934 } else if (level == 2) {
940 while (i > 0 && !isupper(line[i]))
943 d->layout = LAYOUT_MONOCLE;
944 else if (line[i] == 'T')
945 d->layout = LAYOUT_TILED;
947 switch (line[len - 2]) {
956 node_t *birth = make_node();
961 if (level > last_level) {
962 n->first_child = birth;
966 } while (n != NULL && n->second_child != NULL);
968 warn("restore: file is malformed\n");
971 n->second_child = birth;
977 if (isupper(line[level])) {
979 sscanf(line + level, "%c %lf", &st, &n->split_ratio);
981 n->split_type = TYPE_HORIZONTAL;
983 n->split_type = TYPE_VERTICAL;
985 client_t *c = make_client(XCB_NONE);
987 char ba, floating, transient, fullscreen, urgent, locked;
988 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);
990 c->born_as = MODE_AUTOMATIC;
992 c->born_as = MODE_MANUAL;
993 c->floating = (floating == '-' ? false : true);
994 c->transient = (transient == '-' ? false : true);
995 c->fullscreen = (fullscreen == '-' ? false : true);
996 c->urgent = (urgent == '-' ? false : true);
997 c->locked = (locked == '-' ? false : true);
998 if (c->uid > max_uid)
1002 switch (line[len - 2]) {
1018 client_uid = max_uid + 1;
1019 for (monitor_t *m = mon_head; m != NULL; m = m->next)
1020 for (desktop_t *d = m->desk_head; d != NULL; d = d->next)
1021 for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n)) {
1022 uint32_t values[] = {(focus_follows_pointer ? CLIENT_EVENT_MASK_FFP : CLIENT_EVENT_MASK)};
1023 xcb_change_window_attributes(dpy, n->client->window, XCB_CW_EVENT_MASK, values);
1024 if (n->client->floating) {
1026 update_vacant_state(n->parent);
1029 ewmh_update_current_desktop();