ta{g,sk}list: check dofunction return value

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-07-29 11:03:57 +02:00
parent 79dc1a9501
commit 84ff146083
2 changed files with 26 additions and 24 deletions

View File

@ -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 */

View File

@ -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)