From 1e89a301d5b25a819e8fc5042cc38d497837dcd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20B=C3=BCrk?= Date: Sun, 29 Mar 2015 00:09:10 +0100 Subject: [PATCH] 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. --- src/x.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) 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