- xcb_change_gc_single(conn, gc, XCB_GC_FOREGROUND, background_color);
-
- /* We need to use the container’s width because it is the more recent value - when
- in stacking mode, clients get reconfigured only on demand (the not active client
- is not reconfigured), so the client’s rect.width would be wrong */
- xcb_rectangle_t rect = {0, offset, client->container->width, offset + client->rect.height};
- xcb_poly_fill_rectangle(conn, drawable, gc, 1, &rect);
-
- /* Draw the lines */
- xcb_draw_line(conn, drawable, gc, border_color, 2, offset, client->rect.width, offset);
- xcb_draw_line(conn, drawable, gc, border_color, 2, offset + font->height + 3,
- 2 + client->rect.width, offset + font->height + 3);
-
- /* Draw the font */
- uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT;
- uint32_t values[] = { text_color, background_color, font->id };
- xcb_change_gc(conn, gc, mask, values);
-
- /* TODO: utf8? */
- char *label;
- asprintf(&label, "%.*s", client->name_len, client->name);
- xcb_image_text_8(conn, strlen(label), drawable, gc, 3 /* X */, offset + font->height /* Y = baseline of font */, label);
- free(label);
+ if (client->borderless && mode == MODE_DEFAULT)
+ xcb_change_gc_single(conn, gc, XCB_GC_FOREGROUND, get_colorpixel(conn, "#000000"));
+ else xcb_change_gc_single(conn, gc, XCB_GC_FOREGROUND, color->background);
+
+ /* In stacking mode, we only render the rect for this specific decoration */
+ if (mode == MODE_STACK || mode == MODE_TABBED) {
+ /* We need to use the container’s width because it is the more recent value - when
+ in stacking mode, clients get reconfigured only on demand (the not active client
+ is not reconfigured), so the client’s rect.width would be wrong */
+ xcb_rectangle_t rect = {offset_x, offset_y,
+ offset_x + client->container->width,
+ offset_y + decoration_height };
+ xcb_poly_fill_rectangle(conn, drawable, gc, 1, &rect);
+ } else {
+ xcb_rectangle_t rect = {0, 0, client->rect.width, client->rect.height};
+ xcb_poly_fill_rectangle(conn, drawable, gc, 1, &rect);
+
+ /* Draw the inner background to have a black frame around clients (such as mplayer)
+ which cannot be resized exactly in our frames and therefore are centered */
+ xcb_change_gc_single(conn, client->titlegc, XCB_GC_FOREGROUND, get_colorpixel(conn, "#000000"));
+ if (client->titlebar_position == TITLEBAR_OFF && client->borderless) {
+ xcb_rectangle_t crect = {0, 0, client->rect.width, client->rect.height};
+ xcb_poly_fill_rectangle(conn, client->frame, client->titlegc, 1, &crect);
+ } else if (client->titlebar_position == TITLEBAR_OFF && !client->borderless) {
+ xcb_rectangle_t crect = {1, 1, client->rect.width - (1 + 1), client->rect.height - (1 + 1)};
+ xcb_poly_fill_rectangle(conn, client->frame, client->titlegc, 1, &crect);
+ } else {
+ xcb_rectangle_t crect = {2, decoration_height,
+ client->rect.width - (2 + 2), client->rect.height - 2 - decoration_height};
+ xcb_poly_fill_rectangle(conn, client->frame, client->titlegc, 1, &crect);
+ }
+ }
+
+ mode = container_mode(client->container, false);
+
+ if (client->titlebar_position != TITLEBAR_OFF) {
+ /* Draw the lines */
+ xcb_draw_line(conn, drawable, gc, color->border, offset_x, offset_y, offset_x + client->rect.width, offset_y);
+ xcb_draw_line(conn, drawable, gc, color->border,
+ offset_x + 2, /* x */
+ offset_y + font->height + 3, /* y */
+ offset_x + client->rect.width - 3, /* to_x */
+ offset_y + font->height + 3 /* to_y */);
+ }
+
+ /* If the client has a title, we draw it */
+ if (client->name != NULL &&
+ (mode != MODE_DEFAULT || client->titlebar_position != TITLEBAR_OFF)) {
+ /* Draw the font */
+ uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT;
+ uint32_t values[] = { color->text, color->background, font->id };
+ xcb_change_gc(conn, gc, mask, values);
+
+ /* name_len == -1 means this is a legacy application which does not specify _NET_WM_NAME,
+ and we don’t handle the old window name (COMPOUND_TEXT) but only _NET_WM_NAME, which
+ is UTF-8 */
+ if (client->name_len == -1)
+ xcb_image_text_8(conn, strlen(client->name), drawable, gc, offset_x + 3 /* X */,
+ offset_y + font->height /* Y = baseline of font */, client->name);
+ else
+ xcb_image_text_16(conn, client->name_len, drawable, gc, offset_x + 3 /* X */,
+ offset_y + font->height /* Y = baseline of font */, (xcb_char2b_t*)client->name);
+ }