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 /* Check for fullscreen nodes */
41 Con *fullscreen = con_get_fullscreen_con(con);
43 LOG("got fs node: %p\n", fullscreen);
44 fullscreen->rect = rect;
45 render_con(fullscreen);
50 TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
53 if (con->layout == L_DEFAULT) {
54 double percentage = 1.0 / children;
55 if (child->percent > 0.0)
56 percentage = child->percent;
57 printf("child %p / %s requests percentage %f\n",
58 child, child->name, percentage);
60 if (con->orientation == HORIZ) {
63 child->rect.width = percentage * rect.width;
64 child->rect.height = rect.height;
65 x += child->rect.width;
69 child->rect.width = rect.width;
70 child->rect.height = percentage * rect.height;
71 y += child->rect.height;
74 /* first we have the decoration, if this is a leaf node */
75 if (con_is_leaf(child)) {
76 printf("that child is a leaf node, subtracting deco\n");
77 /* TODO: make a function for relative coords? */
78 child->deco_rect.x = child->rect.x - con->rect.x;
79 child->deco_rect.y = child->rect.y - con->rect.y;
82 child->rect.height -= 17;
84 child->deco_rect.width = child->rect.width;
85 child->deco_rect.height = 17;
89 if (con->layout == L_STACKED) {
90 printf("stacked con\n");
93 child->rect.width = rect.width;
94 child->rect.height = rect.height;
96 child->rect.y += (17 * children);
97 child->rect.height -= (17 * children);
99 child->deco_rect.x = x - con->rect.x;
100 child->deco_rect.y = y - con->rect.y + (i * 17);
101 child->deco_rect.width = child->rect.width;
102 child->deco_rect.height = 17;
105 printf("child at (%d, %d) with (%d x %d)\n",
106 child->rect.x, child->rect.y, child->rect.width, child->rect.height);
107 printf("x now %d, y now %d\n", x, y);
109 /* depending on the border style, the rect of the child window
110 * needs to be smaller */
111 Rect *inset = &(child->window_rect);
112 *inset = (Rect){0, 0, child->rect.width, child->rect.height};
113 /* TODO: different border styles */
115 inset->width -= 2 * 2;
123 /* in a stacking container, we ensure the focused client is raised */
124 if (con->layout == L_STACKED) {
125 Con *foc = TAILQ_FIRST(&(con->focus_head));
129 TAILQ_FOREACH(child, &(con->floating_head), floating_windows) {
130 LOG("render floating:\n");
131 LOG("floating child at (%d,%d) with %d x %d\n", child->rect.x, child->rect.y, child->rect.width, child->rect.height);
136 printf("-- level up\n");