]> git.sur5r.net Git - i3/i3/commitdiff
Use the configured font to draw the decorations.
authorFernando Tarlá Cardoso Lemos <fernandotcl@gmail.com>
Sun, 14 Nov 2010 23:14:49 +0000 (21:14 -0200)
committerMichael Stapelberg <michael@stapelberg.de>
Mon, 15 Nov 2010 11:24:16 +0000 (12:24 +0100)
src/x.c

diff --git a/src/x.c b/src/x.c
index 5c854d0187226bc7bac2661ad62b20b716b6e721..1ee23e64ab45b4b73a306c4530eaf2f129f83505 100644 (file)
--- a/src/x.c
+++ b/src/x.c
@@ -299,8 +299,11 @@ void x_draw_decoration(Con *con) {
             con->deco_rect.y + con->deco_rect.height - 1); /* to_y */
 
     /* 5: draw the title */
-    xcb_change_gc_single(conn, parent->gc, XCB_GC_BACKGROUND, color->background);
-    xcb_change_gc_single(conn, parent->gc, XCB_GC_FOREGROUND, color->text);
+    i3Font *font = load_font(conn, config.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, parent->gc, mask, values);
+    int text_offset_y = font->height + (con->deco_rect.height - font->height) / 2 - 1;
 
     struct Window *win = con->window;
     if (win == NULL || win->name_x == NULL) {
@@ -312,7 +315,7 @@ void x_draw_decoration(Con *con) {
             parent->frame,
             parent->gc,
             con->deco_rect.x + 2,
-            con->deco_rect.y + 14, /* TODO: hardcoded */
+            con->deco_rect.y + text_offset_y,
             "another container"
         );
         return;
@@ -342,7 +345,7 @@ void x_draw_decoration(Con *con) {
             parent->frame,
             parent->gc,
             con->deco_rect.x + 2 + indent_px,
-            con->deco_rect.y + 14, /* TODO: hardcoded */
+            con->deco_rect.y + text_offset_y,
             (xcb_char2b_t*)win->name_x
         );
     else
@@ -352,7 +355,7 @@ void x_draw_decoration(Con *con) {
             parent->frame,
             parent->gc,
             con->deco_rect.x + 2 + indent_px,
-            con->deco_rect.y + 14, /* TODO: hardcoded */
+            con->deco_rect.y + text_offset_y,
             win->name_x
         );
 }