2 * vim:ts=4:sw=4:expandtab
8 * "Renders" the given container (and its children), meaning that all rects are
9 * updated correctly. Note that this function does not call any xcb_*
10 * functions, so the changes are completely done in memory only (and
11 * side-effect free). As soon as you call x_push_changes(), the changes will be
15 void render_con(Con *con) {
16 printf("currently rendering node %p / %s / layout %d\n",
17 con, con->name, con->layout);
20 TAILQ_FOREACH(child, &(con->nodes_head), nodes)
22 printf("children: %d, orientation = %d\n", children, con->orientation);
24 /* Copy container rect, subtract container border */
25 /* This is the actually usable space inside this container for clients */
26 Rect rect = con->rect;
37 printf("mapped = true\n");
40 /* if this container contains a window, set the coordinates */
42 /* depending on the border style, the rect of the child window
43 * needs to be smaller */
44 Rect *inset = &(con->window_rect);
45 *inset = (Rect){0, 0, con->rect.width, con->rect.height};
46 /* TODO: different border styles */
48 inset->width -= 2 * 2;
52 /* Check for fullscreen nodes */
53 Con *fullscreen = con_get_fullscreen_con(con);
55 LOG("got fs node: %p\n", fullscreen);
56 fullscreen->rect = rect;
57 x_raise_con(fullscreen);
58 render_con(fullscreen);
62 TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
65 if (con->layout == L_DEFAULT) {
66 double percentage = 1.0 / children;
67 if (child->percent > 0.0)
68 percentage = child->percent;
69 printf("child %p / %s requests percentage %f\n",
70 child, child->name, percentage);
72 if (con->orientation == HORIZ) {
75 child->rect.width = percentage * rect.width;
76 child->rect.height = rect.height;
77 x += child->rect.width;
81 child->rect.width = rect.width;
82 child->rect.height = percentage * rect.height;
83 y += child->rect.height;
86 /* first we have the decoration, if this is a leaf node */
87 if (con_is_leaf(child)) {
88 printf("that child is a leaf node, subtracting deco\n");
89 /* TODO: make a function for relative coords? */
90 child->deco_rect.x = child->rect.x - con->rect.x;
91 child->deco_rect.y = child->rect.y - con->rect.y;
94 child->rect.height -= 17;
96 child->deco_rect.width = child->rect.width;
97 child->deco_rect.height = 17;
101 if (con->layout == L_STACKED) {
102 printf("stacked con\n");
105 child->rect.width = rect.width;
106 child->rect.height = rect.height;
108 child->rect.y += (17 * children);
109 child->rect.height -= (17 * children);
111 child->deco_rect.x = x - con->rect.x;
112 child->deco_rect.y = y - con->rect.y + (i * 17);
113 child->deco_rect.width = child->rect.width;
114 child->deco_rect.height = 17;
117 printf("child at (%d, %d) with (%d x %d)\n",
118 child->rect.x, child->rect.y, child->rect.width, child->rect.height);
119 printf("x now %d, y now %d\n", x, y);
125 /* in a stacking container, we ensure the focused client is raised */
126 if (con->layout == L_STACKED) {
127 Con *foc = TAILQ_FIRST(&(con->focus_head));
128 if (foc != TAILQ_END(&(con->focus_head)))
132 TAILQ_FOREACH(child, &(con->floating_head), floating_windows) {
133 LOG("render floating:\n");
134 LOG("floating child at (%d,%d) with %d x %d\n", child->rect.x, child->rect.y, child->rect.width, child->rect.height);
139 printf("-- level up\n");