Allow multiple marks on windows.

This patch allows multiple marks to be set on a single window. The restriction that a mark may
only be on one window at a time is still upheld as this is necessary for commands like
"move window to mark" to make sense.

relates to #2014
This commit is contained in:
Ingo Bürk
2015-10-19 18:10:20 +02:00
parent 0425f48835
commit 9bb2f038ab
12 changed files with 238 additions and 70 deletions

38
src/x.c
View File

@ -545,18 +545,34 @@ void x_draw_decoration(Con *con) {
int indent_px = (indent_level * 5) * indent_mult;
int mark_width = 0;
if (config.show_marks && con->mark != NULL && (con->mark)[0] != '_') {
char *formatted_mark;
sasprintf(&formatted_mark, "[%s]", con->mark);
i3String *mark = i3string_from_utf8(formatted_mark);
if (config.show_marks && !TAILQ_EMPTY(&(con->marks_head))) {
char *formatted_mark = sstrdup("");
bool had_visible_mark = false;
mark_t *mark;
TAILQ_FOREACH(mark, &(con->marks_head), marks) {
if (mark->name[0] == '_')
continue;
had_visible_mark = true;
char *buf;
sasprintf(&buf, "%s[%s]", formatted_mark, mark->name);
free(formatted_mark);
formatted_mark = buf;
}
if (had_visible_mark) {
i3String *mark = i3string_from_utf8(formatted_mark);
mark_width = predict_text_width(mark);
draw_text(mark, parent->pixmap, parent->pm_gc, NULL,
con->deco_rect.x + con->deco_rect.width - mark_width - logical_px(2),
con->deco_rect.y + text_offset_y, mark_width);
I3STRING_FREE(mark);
}
FREE(formatted_mark);
mark_width = predict_text_width(mark);
draw_text(mark, parent->pixmap, parent->pm_gc, NULL,
con->deco_rect.x + con->deco_rect.width - mark_width - logical_px(2),
con->deco_rect.y + text_offset_y, mark_width);
I3STRING_FREE(mark);
}
i3String *title = win->title_format == NULL ? win->name : window_parse_title_format(win);