X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=spectrwm.c;h=4b71a4f2ca73b0d6115838f1b0f88466b342feea;hb=bfbcbe5c62a1dedad9cd7b9a6c984cc330012a4e;hp=2852769b38a09f8fc8a70901f05f11b4ccc6d0cb;hpb=9e2f9895c3abc9a7277899c01b096f3a460cedec;p=spectrwm.git diff --git a/spectrwm.c b/spectrwm.c index 2852769..4b71a4f 100644 --- a/spectrwm.c +++ b/spectrwm.c @@ -1304,7 +1304,7 @@ socket_setnonblock(int fd) } void -bar_print(struct swm_region *r, char *s) +bar_print(struct swm_region *r, const char *s) { int x = 0; size_t len; @@ -1369,6 +1369,26 @@ bar_title_name(char *s, size_t sz, struct swm_region *r) } void +bar_class_title_name(char *s, size_t sz, struct swm_region *r) +{ + if (r == NULL || r->ws == NULL || r->ws->focus == NULL) + return; + + bar_class_name(s, sz, r); + strlcat(s, ":", sz); + bar_title_name(s, sz, r); +} + +void +bar_window_float(char *s, size_t sz, struct swm_region *r) +{ + if (r == NULL || r ->ws == NULL || r->ws->focus == NULL) + return; + if (r->ws->focus->floating) + strlcat(s, "(f)", sz); +} + +void bar_window_name(char *s, size_t sz, struct swm_region *r) { unsigned char *title; @@ -1378,10 +1398,7 @@ bar_window_name(char *s, size_t sz, struct swm_region *r) if ((title = get_win_name(r->ws->focus->id)) == NULL) return; - if (r->ws->focus->floating) - strlcat(s, "(f) ", sz); strlcat(s, (char *)title, sz); - XFree(title); } @@ -1429,7 +1446,7 @@ bar_workspace_name(char *s, size_t sz, struct swm_region *r) /* build the default bar format according to the defined enabled options */ void -bar_fmt(char *fmtexp, char *fmtnew, struct swm_region *r, size_t sz) +bar_fmt(const char *fmtexp, char *fmtnew, struct swm_region *r, size_t sz) { /* if format provided, just copy the buffers */ if (bar_format != NULL) { @@ -1459,18 +1476,25 @@ bar_fmt(char *fmtexp, char *fmtnew, struct swm_region *r, size_t sz) if (urgent_enabled) strlcat(fmtnew, "* +U* ", sz); - if (title_class_enabled) + if (title_class_enabled) { strlcat(fmtnew, "+C", sz); - if (title_name_enabled) { - /* add a colon if showing the class and something is focused */ - if (title_class_enabled && r != NULL && r->ws != NULL && - r->ws->focus != NULL) - strlcat(fmtnew, ":", sz); - strlcat(fmtnew, "+T ", sz); + if (title_name_enabled == 0) + strlcat(fmtnew, " ", sz); } - if (window_name_enabled) - strlcat(fmtnew, "+64W ", sz); + /* checks needed by the colon and floating strlcat(3) calls below */ + if (r != NULL && r->ws != NULL && r->ws->focus != NULL) { + if (title_name_enabled) { + if (title_class_enabled) + strlcat(fmtnew, ":", sz); + strlcat(fmtnew, "+T ", sz); + } + if (window_name_enabled) { + if (r->ws->focus->floating) + strlcat(fmtnew, "+F ", sz); + strlcat(fmtnew, "+64W ", sz); + } + } /* finally add the action script output and the version */ strlcat(fmtnew, " +A +V", sz); @@ -1520,12 +1544,18 @@ bar_replace_seq(char *fmt, char *fmtrep, struct swm_region *r, size_t *offrep, case 'D': bar_workspace_name(tmp, sizeof tmp, r); break; + case 'F': + bar_window_float(tmp, sizeof tmp, r); + break; case 'I': snprintf(tmp, sizeof tmp, "%d", r->ws->idx + 1); break; case 'N': snprintf(tmp, sizeof tmp, "%d", r->s->idx + 1); break; + case 'P': + bar_class_title_name(tmp, sizeof tmp, r); + break; case 'S': snprintf(tmp, sizeof tmp, "%s", r->ws->stacker); break;