From: Michael Stapelberg Date: Sun, 15 Dec 2013 10:25:58 +0000 (+0100) Subject: display swallows criteria in placeholder windows X-Git-Tag: 4.8~191 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=076636a8350683861f9555c3339004a0ba1777a8;p=i3%2Fi3 display swallows criteria in placeholder windows --- diff --git a/include/data.h b/include/data.h index ea1d3240..e3f28889 100644 --- a/include/data.h +++ b/include/data.h @@ -374,7 +374,7 @@ struct Match { struct regex *class; struct regex *instance; struct regex *mark; - struct regex *role; + struct regex *window_role; enum { U_DONTCHECK = -1, U_LATEST = 0, diff --git a/src/commands.c b/src/commands.c index c8ec5faf..d8eff106 100644 --- a/src/commands.c +++ b/src/commands.c @@ -339,7 +339,7 @@ void cmd_criteria_add(I3_CMD, char *ctype, char *cvalue) { } if (strcmp(ctype, "window_role") == 0) { - current_match->role = regex_new(cvalue); + current_match->window_role = regex_new(cvalue); return; } diff --git a/src/config_directives.c b/src/config_directives.c index b28ad49d..96d29ee0 100644 --- a/src/config_directives.c +++ b/src/config_directives.c @@ -55,7 +55,7 @@ CFGFUN(criteria_add, const char *ctype, const char *cvalue) { } if (strcmp(ctype, "window_role") == 0) { - current_match->role = regex_new(cvalue); + current_match->window_role = regex_new(cvalue); return; } diff --git a/src/load_layout.c b/src/load_layout.c index 11a8f974..588f2d3b 100644 --- a/src/load_layout.c +++ b/src/load_layout.c @@ -158,7 +158,7 @@ static int json_string(void *ctx, const unsigned char *val, unsigned int len) { } else if (strcasecmp(last_key, "instance") == 0) { current_swallow->instance = regex_new(sval); } else if (strcasecmp(last_key, "window_role") == 0) { - current_swallow->role = regex_new(sval); + current_swallow->window_role = regex_new(sval); } else if (strcasecmp(last_key, "title") == 0) { current_swallow->title = regex_new(sval); } else { diff --git a/src/match.c b/src/match.c index 350a2c11..de3990fa 100644 --- a/src/match.c +++ b/src/match.c @@ -47,7 +47,7 @@ bool match_is_empty(Match *match) { match->application == NULL && match->class == NULL && match->instance == NULL && - match->role == NULL && + match->window_role == NULL && match->urgent == U_DONTCHECK && match->id == XCB_NONE && match->con_id == NULL && @@ -75,7 +75,7 @@ void match_copy(Match *dest, Match *src) { DUPLICATE_REGEX(application); DUPLICATE_REGEX(class); DUPLICATE_REGEX(instance); - DUPLICATE_REGEX(role); + DUPLICATE_REGEX(window_role); } /* @@ -121,9 +121,9 @@ bool match_matches_window(Match *match, i3Window *window) { } } - if (match->role != NULL) { + if (match->window_role != NULL) { if (window->role != NULL && - regex_matches(match->role, window->role)) { + regex_matches(match->window_role, window->role)) { LOG("window_role matches (%s)\n", window->role); } else { return false; @@ -196,7 +196,7 @@ void match_free(Match *match) { regex_free(match->class); regex_free(match->instance); regex_free(match->mark); - regex_free(match->role); + regex_free(match->window_role); /* Second step: free the regex helper struct itself */ FREE(match->title); @@ -204,5 +204,5 @@ void match_free(Match *match) { FREE(match->class); FREE(match->instance); FREE(match->mark); - FREE(match->role); + FREE(match->window_role); } diff --git a/src/restore_layout.c b/src/restore_layout.c index ac2a1e38..b19f7f77 100644 --- a/src/restore_layout.c +++ b/src/restore_layout.c @@ -109,8 +109,43 @@ static void update_placeholder_contents(placeholder_state *state) { xcb_flush(restore_conn); xcb_aux_sync(restore_conn); - // TODO: actually represent the criteria, most likely just line by line from (0, 0) set_font_colors(state->gc, config.client.focused.background, 0); + + Match *swallows; + int n = 0; + TAILQ_FOREACH(swallows, &(state->con->swallow_head), matches) { + char *serialized = NULL; + +#define APPEND_REGEX(re_name) do { \ + if (swallows->re_name != NULL) { \ + sasprintf(&serialized, "%s%s" #re_name "=\"%s\"", \ + (serialized ? serialized : "["), \ + (serialized ? " " : ""), \ + swallows->re_name->pattern); \ + } \ +} while (0) + + APPEND_REGEX(class); + APPEND_REGEX(instance); + APPEND_REGEX(window_role); + APPEND_REGEX(title); + + if (serialized == NULL) { + DLOG("This swallows specification is not serializable?!\n"); + continue; + } + + sasprintf(&serialized, "%s]", serialized); + DLOG("con %p (placeholder 0x%08x) line %d: %s\n", state->con, state->window, n, serialized); + + i3String *str = i3string_from_utf8(serialized); + draw_text(str, state->pixmap, state->gc, 2, (n * (config.font.height + 2)) + 2, state->rect.width - 2); + i3string_free(str); + n++; + free(serialized); + } + + // TODO: render the watch symbol in a bigger font i3String *line = i3string_from_utf8("⌚"); int text_width = predict_text_width(line); int x = (state->rect.width / 2) - (text_width / 2);