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 render_con(fullscreen);
61 TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
64 if (con->layout == L_DEFAULT) {
65 double percentage = 1.0 / children;
66 if (child->percent > 0.0)
67 percentage = child->percent;
68 printf("child %p / %s requests percentage %f\n",
69 child, child->name, percentage);
71 if (con->orientation == HORIZ) {
74 child->rect.width = percentage * rect.width;
75 child->rect.height = rect.height;
76 x += child->rect.width;
80 child->rect.width = rect.width;
81 child->rect.height = percentage * rect.height;
82 y += child->rect.height;
85 /* first we have the decoration, if this is a leaf node */
86 if (con_is_leaf(child)) {
87 printf("that child is a leaf node, subtracting deco\n");
88 /* TODO: make a function for relative coords? */
89 child->deco_rect.x = child->rect.x - con->rect.x;
90 child->deco_rect.y = child->rect.y - con->rect.y;
93 child->rect.height -= 17;
95 child->deco_rect.width = child->rect.width;
96 child->deco_rect.height = 17;
100 if (con->layout == L_STACKED) {
101 printf("stacked con\n");
104 child->rect.width = rect.width;
105 child->rect.height = rect.height;
107 child->rect.y += (17 * children);
108 child->rect.height -= (17 * children);
110 child->deco_rect.x = x - con->rect.x;
111 child->deco_rect.y = y - con->rect.y + (i * 17);
112 child->deco_rect.width = child->rect.width;
113 child->deco_rect.height = 17;
116 printf("child at (%d, %d) with (%d x %d)\n",
117 child->rect.x, child->rect.y, child->rect.width, child->rect.height);
118 printf("x now %d, y now %d\n", x, y);
124 /* in a stacking container, we ensure the focused client is raised */
125 if (con->layout == L_STACKED) {
126 Con *foc = TAILQ_FIRST(&(con->focus_head));
127 if (foc != TAILQ_END(&(con->focus_head)))
131 TAILQ_FOREACH(child, &(con->floating_head), floating_windows) {
132 LOG("render floating:\n");
133 LOG("floating child at (%d,%d) with %d x %d\n", child->rect.x, child->rect.y, child->rect.width, child->rect.height);
138 printf("-- level up\n");