X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=spectrwm.c;h=22e0f060ee2043fbccf61fffd20ec51705463ff7;hb=d708e9e9feeada0be52fde1bcaba7175edc235a6;hp=1ef4c8d6ab8491d2c6eed9628a3f6ae9cd91d2c1;hpb=c7532ca6f471773d7ea399f30c935fd531b624a8;p=spectrwm.git diff --git a/spectrwm.c b/spectrwm.c index 1ef4c8d..22e0f06 100644 --- a/spectrwm.c +++ b/spectrwm.c @@ -1871,31 +1871,30 @@ 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 != NULL) + return; 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"); @@ -1919,8 +1918,7 @@ bar_setup(struct swm_region *r) wa[0] = r->s->c[SWM_S_COLOR_BAR].pixel; wa[1] = r->s->c[SWM_S_COLOR_BAR_BORDER].pixel; wa[2] = XCB_EVENT_MASK_EXPOSURE; - DNPRINTF(SWM_D_BAR, "bar_setup: create_window: (x,y) w x h: (%d,%d) " - "%d x %d\n", X(r->bar), Y(r->bar), WIDTH(r->bar), HEIGHT(r->bar)); + xcb_create_window(conn, XCB_COPY_FROM_PARENT, r->bar->id, r->s->root, X(r->bar), Y(r->bar), WIDTH(r->bar), HEIGHT(r->bar), bar_border_width, XCB_WINDOW_CLASS_INPUT_OUTPUT,