From 2af1a800283b20b3fa0c5d0791ee1083fc9d207d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20B=C3=BCrk?= Date: Sun, 29 Mar 2015 00:13:44 +0100 Subject: [PATCH] Introduce a cached boolean for changes to the mark of a window. This is necessary to correctly redraw window decorations when the mark of a window is added or removed. --- include/data.h | 2 ++ src/commands.c | 13 +++++++++++-- src/x.c | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/data.h b/include/data.h index cec571e9..d40ed292 100644 --- a/include/data.h +++ b/include/data.h @@ -543,6 +543,8 @@ struct Con { /* user-definable mark to jump to this container later */ char *mark; + /* cached to decide whether a redraw is needed */ + bool mark_changed; double percent; diff --git a/src/commands.c b/src/commands.c index 2aa1f537..6c24e24d 100644 --- a/src/commands.c +++ b/src/commands.c @@ -1046,6 +1046,7 @@ void cmd_mark(I3_CMD, char *mark, char *toggle) { owindow *current; TAILQ_FOREACH(current, &owindows, owindows) { DLOG("matching: %p / %s\n", current->con, current->con->name); + current->con->mark_changed=true; if (toggle != NULL && current->con->mark && strcmp(current->con->mark, mark) == 0) { DLOG("removing window mark %s\n", mark); FREE(current->con->mark); @@ -1070,8 +1071,10 @@ void cmd_mark(I3_CMD, char *mark, char *toggle) { if (matched) continue; - if (con->mark && strcmp(con->mark, mark) == 0) + if (con->mark && strcmp(con->mark, mark) == 0) { FREE(con->mark); + con->mark_changed = true; + } } cmd_output->needs_tree_render = true; @@ -1087,14 +1090,20 @@ void cmd_unmark(I3_CMD, char *mark) { if (mark == NULL) { Con *con; TAILQ_FOREACH(con, &all_cons, all_cons) { + if (con->mark == NULL) + continue; + FREE(con->mark); + con->mark_changed = true; } DLOG("removed all window marks"); } else { Con *con; TAILQ_FOREACH(con, &all_cons, all_cons) { - if (con->mark && strcmp(con->mark, mark) == 0) + if (con->mark && strcmp(con->mark, mark) == 0) { FREE(con->mark); + con->mark_changed = true; + } } DLOG("removed window mark %s\n", mark); } diff --git a/src/x.c b/src/x.c index a3810942..1d4bfdf1 100644 --- a/src/x.c +++ b/src/x.c @@ -363,6 +363,7 @@ void x_draw_decoration(Con *con) { (con->window == NULL || !con->window->name_x_changed) && !parent->pixmap_recreated && !con->pixmap_recreated && + !con->mark_changed && memcmp(p, con->deco_render_params, sizeof(struct deco_render_params)) == 0) { free(p); goto copy_pixmaps; @@ -381,6 +382,7 @@ void x_draw_decoration(Con *con) { parent->pixmap_recreated = false; con->pixmap_recreated = false; + con->mark_changed = false; /* 2: draw the client.background, but only for the parts around the client_rect */ if (con->window != NULL) {