From: Ingo Bürk Date: Sat, 28 Mar 2015 23:09:10 +0000 (+0100) Subject: Draw marks in window decoration X-Git-Tag: 4.11~155^2~3 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1e89a301d5b25a819e8fc5042cc38d497837dcd8;p=i3%2Fi3 Draw marks in window decoration If a window has a mark set, e.g., "example", it will be printed on the right side of the window decorations. The format is "[example]" and the name of the window is truncated if necessary. Marks starting with an underscore ("_") will be ignored. --- diff --git a/src/x.c b/src/x.c index 9dd09117..a3810942 100644 --- a/src/x.c +++ b/src/x.c @@ -531,10 +531,25 @@ void x_draw_decoration(Con *con) { //DLOG("indent_level = %d, indent_mult = %d\n", indent_level, indent_mult); int indent_px = (indent_level * 5) * indent_mult; + int mark_width = 0; + if (con->mark != NULL && (con->mark)[0] != '_') { + char *formatted_mark; + sasprintf(&formatted_mark, "[%s]", con->mark); + i3String *mark = i3string_from_utf8(formatted_mark); + FREE(formatted_mark); + mark_width = predict_text_width(mark) + logical_px(2); + + draw_text(mark, parent->pixmap, parent->pm_gc, + con->deco_rect.x + con->deco_rect.width - mark_width, + con->deco_rect.y + text_offset_y, mark_width - logical_px(2)); + + I3STRING_FREE(mark); + } + draw_text(win->name, parent->pixmap, parent->pm_gc, - con->deco_rect.x + 2 + indent_px, con->deco_rect.y + text_offset_y, - con->deco_rect.width - 2 - indent_px); + con->deco_rect.x + logical_px(2) + indent_px, con->deco_rect.y + text_offset_y, + con->deco_rect.width - logical_px(2) - indent_px - mark_width); after_title: /* Since we don’t clip the text at all, it might in some cases be painted