X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=spectrwm.c;h=796153b47edfa3db573b016ad62abfcf9b179884;hb=3ce4ba02b4120821833b08ca9f7829c6b723c3e4;hp=f6f8c9e1e5832caeef977ff444e2b5e7e8803fb5;hpb=999734e3800aa7448312aa3055780c8915163de2;p=spectrwm.git diff --git a/spectrwm.c b/spectrwm.c index f6f8c9e..796153b 100644 --- a/spectrwm.c +++ b/spectrwm.c @@ -475,7 +475,6 @@ struct swm_screen { GC bar_gc; }; struct swm_screen *screens; -int num_screens; /* args to functions */ union arg { @@ -1354,32 +1353,24 @@ void bar_class_name(char *s, ssize_t sz, struct ws_win *cur_focus) { int do_class, do_name; - Status status; - XClassHint *xch = NULL; + XClassHint *ch; - if ((title_name_enabled == 1 || title_class_enabled == 1) && - cur_focus != NULL) { - if ((xch = XAllocClassHint()) == NULL) - goto out; - status = XGetClassHint(display, cur_focus->id, xch); - if (status == BadWindow || status == BadAlloc) - goto out; - do_class = (title_class_enabled && xch->res_class != NULL); - do_name = (title_name_enabled && xch->res_name != NULL); - if (do_class) - strlcat(s, xch->res_class, sz); - if (do_class && do_name) - strlcat(s, ":", sz); - if (do_name) - strlcat(s, xch->res_name, sz); - strlcat(s, " ", sz); - } -out: - if (xch) { - XFree(xch->res_name); - XFree(xch->res_class); - XFree(xch); - } + if (title_name_enabled == 0 && title_class_enabled == 0) + return; + if (cur_focus == NULL) + return; + + ch = &cur_focus->ch; + do_class = (title_class_enabled && ch->res_class != NULL); + do_name = (title_name_enabled && ch->res_name != NULL); + + if (do_class) + strlcat(s, ch->res_class, sz); + if (do_class && do_name) + strlcat(s, ":", sz); + if (do_name) + strlcat(s, ch->res_name, sz); + strlcat(s, " ", sz); } void