wibox: rebuild table at every draw

This will be necessary for using the new Lua layout system.

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-01-16 11:10:27 +01:00
parent 855e2b9cdf
commit 2ca7149501
3 changed files with 12 additions and 26 deletions

29
wibox.c
View File

@ -499,19 +499,6 @@ luaA_wibox_new(lua_State *L)
return 1;
}
/** Rebuild wibox widgets list.
* \param L The Lua VM state.
* \param wibox The wibox.
*/
static void
wibox_widgets_table_build(lua_State *L, wibox_t *wibox)
{
widget_node_array_wipe(&wibox->widgets);
widget_node_array_init(&wibox->widgets);
luaA_table2widgets(L, &wibox->widgets);
wibox_need_update(wibox);
}
/** Check if a wibox widget table has an item.
* \param L The Lua VM state.
* \param wibox The wibox.
@ -541,8 +528,8 @@ luaA_wibox_invalidate_byitem(lua_State *L, const void *item)
wibox_t *wibox = *w;
if(luaA_wibox_hasitem(L, wibox, item))
{
/* recompute widget node list */
wibox_widgets_table_build(L, wibox);
/* update wibox */
wibox_need_update(wibox);
lua_pop(L, 1); /* remove widgets table */
}
@ -553,8 +540,8 @@ luaA_wibox_invalidate_byitem(lua_State *L, const void *item)
client_t *c = *_c;
if(c->titlebar && luaA_wibox_hasitem(L, c->titlebar, item))
{
/* recompute widget node list */
wibox_widgets_table_build(L, c->titlebar);
/* update wibox */
wibox_need_update(c->titlebar);
lua_pop(L, 1); /* remove widgets table */
}
}
@ -848,12 +835,8 @@ luaA_wibox_newindex(lua_State *L)
luaA_warn(L, "table is looping, cannot use this as widget table");
return 0;
}
/* register object */
luaA_register(L, 3, &wibox->widgets_table);
/* duplicate table because next function will eat it */
lua_pushvalue(L, -1);
/* recompute widget node list */
wibox_widgets_table_build(L, wibox);
luaA_register(L, 3, &(wibox->widgets_table));
wibox_need_update(wibox);
luaA_table2wtable(L);
break;
case A_TK_OPACITY:

View File

@ -103,7 +103,7 @@ widget_getbycoords(orientation_t orientation, widget_node_array_t *widgets,
* \param L The Lua VM state.
* \param widgets The linked list of widget node.
*/
void
static void
luaA_table2widgets(lua_State *L, widget_node_array_t *widgets)
{
if(lua_istable(L, -1))
@ -193,6 +193,11 @@ widget_render(wibox_t *wibox)
widget_node_array_t *widgets = &wibox->widgets;
widget_node_array_wipe(widgets);
widget_node_array_init(widgets);
lua_rawgeti(globalconf.L, LUA_REGISTRYINDEX, wibox->widgets_table);
luaA_table2widgets(globalconf.L, widgets);
/* compute geometry */
for(int i = 0; i < widgets->len; i++)
if(widgets->tab[i].widget->align == AlignLeft

View File

@ -73,8 +73,6 @@ struct widget_node_t
widget_t *widget_getbycoords(orientation_t, widget_node_array_t *, int, int, int16_t *, int16_t *);
void widget_render(wibox_t *);
void luaA_table2widgets(lua_State *, widget_node_array_t *);
void widget_invalidate_bywidget(widget_t *);
void widget_invalidate_bytype(widget_constructor_t *);