From 85986408ee0904af5ff63189e5a0de1df3f3cc26 Mon Sep 17 00:00:00 2001 From: Reginald Kennedy Date: Fri, 20 Jul 2012 01:19:19 +0800 Subject: [PATCH] Use the same font on all bars. Don't close font and color each time bar_setup is called. --- spectrwm.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/spectrwm.c b/spectrwm.c index 1ef4c8d..c98b1a3 100644 --- a/spectrwm.c +++ b/spectrwm.c @@ -1871,31 +1871,27 @@ bar_setup(struct swm_region *r) uint32_t wa[3]; XRenderColor color; - if (bar_font) { - XftColorFree(display, DefaultVisual(display, r->s->idx), - DefaultColormap(display, r->s->idx), &bar_font_color); - XftFontClose(display, bar_font); - bar_font = NULL; - } - if ((r->bar = calloc(1, sizeof(struct swm_bar))) == NULL) err(1, "bar_setup: calloc: failed to allocate memory."); - while ((font = strsep(&bar_fonts, " ,")) != NULL) { - if (*font == '\0') - continue; + if (bar_font == NULL) { + while ((font = strsep(&bar_fonts, " ,")) != NULL) { + if (*font == '\0') + continue; - DNPRINTF(SWM_D_INIT, "bar_setup: try font %s\n", font); - bar_font = XftFontOpenName(display, r->s->idx, font); - if (!bar_font) { - warnx("unable to load font %s", font); - continue; - } else { - DNPRINTF(SWM_D_INIT, "successfully opened font %s\n", - font); - break; + DNPRINTF(SWM_D_INIT, "bar_setup: try font %s\n", font); + bar_font = XftFontOpenName(display, r->s->idx, font); + if (!bar_font) { + warnx("unable to load font %s", font); + continue; + } else { + DNPRINTF(SWM_D_INIT, "successfully opened " + "font %s\n", font); + break; + } } } + if (bar_font == NULL) errx(1, "unable to open a font"); -- 2.39.2