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.
This commit is contained in:
Ingo Bürk 2015-03-29 00:13:44 +01:00
parent 1e89a301d5
commit 2af1a80028
3 changed files with 15 additions and 2 deletions

View File

@ -543,6 +543,8 @@ struct Con {
/* user-definable mark to jump to this container later */ /* user-definable mark to jump to this container later */
char *mark; char *mark;
/* cached to decide whether a redraw is needed */
bool mark_changed;
double percent; double percent;

View File

@ -1046,6 +1046,7 @@ void cmd_mark(I3_CMD, char *mark, char *toggle) {
owindow *current; owindow *current;
TAILQ_FOREACH(current, &owindows, owindows) { TAILQ_FOREACH(current, &owindows, owindows) {
DLOG("matching: %p / %s\n", current->con, current->con->name); 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) { if (toggle != NULL && current->con->mark && strcmp(current->con->mark, mark) == 0) {
DLOG("removing window mark %s\n", mark); DLOG("removing window mark %s\n", mark);
FREE(current->con->mark); FREE(current->con->mark);
@ -1070,8 +1071,10 @@ void cmd_mark(I3_CMD, char *mark, char *toggle) {
if (matched) if (matched)
continue; continue;
if (con->mark && strcmp(con->mark, mark) == 0) if (con->mark && strcmp(con->mark, mark) == 0) {
FREE(con->mark); FREE(con->mark);
con->mark_changed = true;
}
} }
cmd_output->needs_tree_render = true; cmd_output->needs_tree_render = true;
@ -1087,14 +1090,20 @@ void cmd_unmark(I3_CMD, char *mark) {
if (mark == NULL) { if (mark == NULL) {
Con *con; Con *con;
TAILQ_FOREACH(con, &all_cons, all_cons) { TAILQ_FOREACH(con, &all_cons, all_cons) {
if (con->mark == NULL)
continue;
FREE(con->mark); FREE(con->mark);
con->mark_changed = true;
} }
DLOG("removed all window marks"); DLOG("removed all window marks");
} else { } else {
Con *con; Con *con;
TAILQ_FOREACH(con, &all_cons, all_cons) { 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); FREE(con->mark);
con->mark_changed = true;
}
} }
DLOG("removed window mark %s\n", mark); DLOG("removed window mark %s\n", mark);
} }

View File

@ -363,6 +363,7 @@ void x_draw_decoration(Con *con) {
(con->window == NULL || !con->window->name_x_changed) && (con->window == NULL || !con->window->name_x_changed) &&
!parent->pixmap_recreated && !parent->pixmap_recreated &&
!con->pixmap_recreated && !con->pixmap_recreated &&
!con->mark_changed &&
memcmp(p, con->deco_render_params, sizeof(struct deco_render_params)) == 0) { memcmp(p, con->deco_render_params, sizeof(struct deco_render_params)) == 0) {
free(p); free(p);
goto copy_pixmaps; goto copy_pixmaps;
@ -381,6 +382,7 @@ void x_draw_decoration(Con *con) {
parent->pixmap_recreated = false; parent->pixmap_recreated = false;
con->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 */ /* 2: draw the client.background, but only for the parts around the client_rect */
if (con->window != NULL) { if (con->window != NULL) {