diff --git a/widgets/taglist.c b/widgets/taglist.c index 5ba353d02..8f6f0d96e 100644 --- a/widgets/taglist.c +++ b/widgets/taglist.c @@ -105,23 +105,24 @@ taglist_draw(draw_context_t *ctx, int screen, widget_node_t *w, tag_t *tag = tags->tab[i]; luaA_tag_userdata_new(globalconf.L, tag); - luaA_dofunction(globalconf.L, data->label, 1, 1); + if(luaA_dofunction(globalconf.L, data->label, 1, 1)) + { + if(lua_isstring(globalconf.L, -1)) + text[i] = lua_tolstring(globalconf.L, -1, &len[i]); - if(lua_isstring(globalconf.L, -1)) - text[i] = lua_tolstring(globalconf.L, -1, &len[i]); + lua_pop(globalconf.L, 1); - lua_pop(globalconf.L, 1); + draw_parser_data_init(&pdata[i]); + area = draw_text_extents(ctx->connection, ctx->phys_screen, + globalconf.font, text[i], len[i], &pdata[i]); - draw_parser_data_init(&pdata[i]); - area = draw_text_extents(ctx->connection, ctx->phys_screen, - globalconf.font, text[i], len[i], &pdata[i]); + if(pdata[i].bg_image) + area.width = MAX(area.width, pdata[i].bg_resize ? w->area.height : pdata[i].bg_image->width); - if(pdata[i].bg_image) - area.width = MAX(area.width, pdata[i].bg_resize ? w->area.height : pdata[i].bg_image->width); + w->area.width += area.width; - w->area.width += area.width; - - area_array_append(&tda->areas, area); + area_array_append(&tda->areas, area); + } } /* Now that we have widget width we can compute widget x coordinate */ diff --git a/widgets/tasklist.c b/widgets/tasklist.c index 698095bb4..17abde747 100644 --- a/widgets/tasklist.c +++ b/widgets/tasklist.c @@ -143,20 +143,21 @@ tasklist_draw(draw_context_t *ctx, int screen, lua_pushnumber(globalconf.L, screen + 1); /* call label function with client as argument and wait for one * result */ - luaA_dofunction(globalconf.L, d->label, 2, 1); - - /* If we got a string as returned value, we got something to write: - * a label. So we store it in a client_label_t structure, pushed - * into the client_label_array_t which is owned by the object. */ - if(lua_isstring(globalconf.L, -1)) + if(luaA_dofunction(globalconf.L, d->label, 2, 1)) { - client_label_t cl; - cl.client = c; - cl.label = a_strdup(lua_tolstring(globalconf.L, -1, &cl.label_len)); - client_label_array_append(&odata->client_labels, cl); - } + /* If we got a string as returned value, we got something to write: + * a label. So we store it in a client_label_t structure, pushed + * into the client_label_array_t which is owned by the object. */ + if(lua_isstring(globalconf.L, -1)) + { + client_label_t cl; + cl.client = c; + cl.label = a_strdup(lua_tolstring(globalconf.L, -1, &cl.label_len)); + client_label_array_append(&odata->client_labels, cl); + } - lua_pop(globalconf.L, 1); + lua_pop(globalconf.L, 1); + } } if(!odata->client_labels.len)