widget: widget are now full Lua object

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-04-09 15:12:17 +02:00
parent 541d4f565f
commit b1a59aca07
11 changed files with 118 additions and 119 deletions

38
event.c
View File

@ -121,7 +121,6 @@ event_handle_button(void *data, xcb_connection_t *connection, xcb_button_press_e
int screen; int screen;
const int nb_screen = xcb_setup_roots_length(xcb_get_setup(connection)); const int nb_screen = xcb_setup_roots_length(xcb_get_setup(connection));
client_t *c; client_t *c;
widget_t *w;
wibox_t *wibox; wibox_t *wibox;
/* ev->state is /* ev->state is
@ -168,10 +167,11 @@ event_handle_button(void *data, xcb_connection_t *connection, xcb_button_press_e
} }
/* then try to match a widget binding */ /* then try to match a widget binding */
if((w = widget_getbycoords(wibox->position, &wibox->widgets, widget_t *w = widget_getbycoords(wibox->position, &wibox->widgets,
wibox->sw.geometry.width, wibox->sw.geometry.width,
wibox->sw.geometry.height, wibox->sw.geometry.height,
&ev->event_x, &ev->event_y))) &ev->event_x, &ev->event_y);
if(w)
{ {
b = &w->buttons; b = &w->buttons;
@ -427,16 +427,18 @@ event_handle_motionnotify(void *data __attribute__ ((unused)),
xcb_motion_notify_event_t *ev) xcb_motion_notify_event_t *ev)
{ {
wibox_t *wibox; wibox_t *wibox;
widget_t *w;
event_handle_mousegrabber(ev->root_x, ev->root_y, ev->state); event_handle_mousegrabber(ev->root_x, ev->root_y, ev->state);
if((wibox = wibox_getbywin(ev->event)) if((wibox = wibox_getbywin(ev->event)))
&& (w = widget_getbycoords(wibox->position, &wibox->widgets, {
wibox->sw.geometry.width, widget_t *w = widget_getbycoords(wibox->position, &wibox->widgets,
wibox->sw.geometry.height, wibox->sw.geometry.width,
&ev->event_x, &ev->event_y))) wibox->sw.geometry.height,
event_handle_widget_motionnotify(wibox, &wibox->mouse_over, w); &ev->event_x, &ev->event_y);
if(w)
event_handle_widget_motionnotify(wibox, &wibox->mouse_over, w);
}
return 0; return 0;
} }
@ -495,7 +497,6 @@ event_handle_enternotify(void *data __attribute__ ((unused)),
xcb_enter_notify_event_t *ev) xcb_enter_notify_event_t *ev)
{ {
client_t *c; client_t *c;
widget_t *w;
wibox_t *wibox; wibox_t *wibox;
if(ev->mode != XCB_NOTIFY_MODE_NORMAL) if(ev->mode != XCB_NOTIFY_MODE_NORMAL)
@ -503,10 +504,11 @@ event_handle_enternotify(void *data __attribute__ ((unused)),
if((wibox = wibox_getbywin(ev->event))) if((wibox = wibox_getbywin(ev->event)))
{ {
if((w = widget_getbycoords(wibox->position, &wibox->widgets, widget_t *w = widget_getbycoords(wibox->position, &wibox->widgets,
wibox->sw.geometry.width, wibox->sw.geometry.width,
wibox->sw.geometry.height, wibox->sw.geometry.height,
&ev->event_x, &ev->event_y))) &ev->event_x, &ev->event_y);
if(w)
event_handle_widget_motionnotify(wibox, &wibox->mouse_over, w); event_handle_widget_motionnotify(wibox, &wibox->mouse_over, w);
if(wibox->mouse_enter != LUA_REFNIL) if(wibox->mouse_enter != LUA_REFNIL)
@ -515,13 +517,11 @@ event_handle_enternotify(void *data __attribute__ ((unused)),
if((c = client_getbytitlebarwin(ev->event)) if((c = client_getbytitlebarwin(ev->event))
|| (c = client_getbywin(ev->event))) || (c = client_getbywin(ev->event)))
{
if(globalconf.hooks.mouse_enter != LUA_REFNIL) if(globalconf.hooks.mouse_enter != LUA_REFNIL)
{ {
luaA_client_userdata_new(globalconf.L, c); luaA_client_userdata_new(globalconf.L, c);
luaA_dofunction(globalconf.L, globalconf.hooks.mouse_enter, 1, 0); luaA_dofunction(globalconf.L, globalconf.hooks.mouse_enter, 1, 0);
} }
}
return 0; return 0;
} }

4
luaa.c
View File

@ -534,7 +534,7 @@ luaA_wtable_newindex(lua_State *L)
/* get current key value in content table */ /* get current key value in content table */
lua_rawget(L, lua_upvalueindex(1)); lua_rawget(L, lua_upvalueindex(1));
/* if value is a widget, notify change */ /* if value is a widget, notify change */
if(lua_istable(L, -1) || luaA_toudata(L, -1, "widget")) if(lua_istable(L, -1) || luaA_toudata2(L, -1, "widget"))
invalid = true; invalid = true;
lua_pop(L, 1); /* remove value */ lua_pop(L, 1); /* remove value */
@ -545,7 +545,7 @@ luaA_wtable_newindex(lua_State *L)
luaA_table2wtable(L); luaA_table2wtable(L);
invalid = true; invalid = true;
} }
else if(!invalid && luaA_toudata(L, 3, "widget")) else if(!invalid && luaA_toudata2(L, 3, "widget"))
invalid = true; invalid = true;
/* upvalue 1 is content table */ /* upvalue 1 is content table */

View File

@ -482,7 +482,7 @@ luaA_mouse_object_under_pointer(lua_State *L)
if(widget) if(widget)
{ {
luaA_widget_userdata_new(L, widget); widget_push(L, widget);
return 2; return 2;
} }
return 1; return 1;

View File

@ -120,8 +120,8 @@ ARRAY_TYPE(wibox_t *, wibox)
/** Widget */ /** Widget */
struct widget_t struct widget_t
{ {
/** Ref count */ /** Lua references */
int refcount; luaA_ref_array_t refs;
/** Widget type is constructor */ /** Widget type is constructor */
widget_constructor_t *type; widget_constructor_t *type;
/** Widget destructor */ /** Widget destructor */

View File

@ -1101,7 +1101,10 @@ luaA_wibox_newindex(lua_State *L)
luaA_warn(L, "table is looping, cannot use this as widget table"); luaA_warn(L, "table is looping, cannot use this as widget table");
return 0; return 0;
} }
/* register object */
luaA_register(L, 3, &(*wibox)->widgets_table); luaA_register(L, 3, &(*wibox)->widgets_table);
/* duplicate table because next function will eat it */
lua_pushvalue(L, -1);
/* recompute widget node list */ /* recompute widget node list */
wibox_widgets_table_build(L, *wibox); wibox_widgets_table_build(L, *wibox);
luaA_table2wtable(L); luaA_table2wtable(L);

View File

@ -29,24 +29,33 @@
#include "wibox.h" #include "wibox.h"
#include "common/atoms.h" #include "common/atoms.h"
DO_LUA_NEW(extern, widget_t, widget, "widget", widget_ref)
DO_LUA_GC(widget_t, widget, "widget", widget_unref)
DO_LUA_EQ(widget_t, widget, "widget")
#include "widgetgen.h" #include "widgetgen.h"
/** Delete a widget structure. DO_LUA_TOSTRING(widget_t, widget, "widget")
* \param widget The widget to destroy.
/** Collect a widget structure.
* \param L The Lua VM state.
* \return 0
*/
static int
luaA_widget_gc(lua_State *L)
{
widget_t *widget = luaL_checkudata(L, 1, "widget");
if(widget->destructor)
widget->destructor(widget);
button_array_wipe(&widget->buttons);
luaL_unref(globalconf.L, LUA_REGISTRYINDEX, widget->mouse_enter);
luaL_unref(globalconf.L, LUA_REGISTRYINDEX, widget->mouse_leave);
return 0;
}
/** Delete a widget node structure.
* \param node The node to destroy.
*/ */
void void
widget_delete(widget_t **widget) widget_node_delete(widget_node_t *node)
{ {
if((*widget)->destructor) widget_unref(globalconf.L, node->widget);
(*widget)->destructor(*widget);
button_array_wipe(&(*widget)->buttons);
luaL_unref(globalconf.L, LUA_REGISTRYINDEX, (*widget)->mouse_enter);
luaL_unref(globalconf.L, LUA_REGISTRYINDEX, (*widget)->mouse_leave);
p_delete(widget);
} }
/** Get a widget node from a wibox by coords. /** Get a widget node from a wibox by coords.
@ -80,14 +89,11 @@ widget_getbycoords(position_t position, widget_node_array_t *widgets,
default: default:
break; break;
} }
for(int i = 0; i < widgets->len; i++) foreach(w, *widgets)
{ if(w->widget->isvisible
widget_node_t *w = &widgets->tab[i]; && *x >= w->geometry.x && *x < w->geometry.x + w->geometry.width
if(w->widget->isvisible &&
*x >= w->geometry.x && *x < w->geometry.x + w->geometry.width
&& *y >= w->geometry.y && *y < w->geometry.y + w->geometry.height) && *y >= w->geometry.y && *y < w->geometry.y + w->geometry.height)
return w->widget; return w->widget;
}
return NULL; return NULL;
} }
@ -103,21 +109,22 @@ luaA_table2widgets(lua_State *L, widget_node_array_t *widgets)
{ {
lua_pushnil(L); lua_pushnil(L);
while(luaA_next(L, -2)) while(luaA_next(L, -2))
{
luaA_table2widgets(L, widgets); luaA_table2widgets(L, widgets);
lua_pop(L, 1); /* remove value */ /* remove the table */
} lua_pop(L, 1);
} }
else else
{ {
widget_t **widget = luaA_toudata(L, -1, "widget"); widget_t *widget = luaA_toudata2(L, -1, "widget");
if(widget) if(widget)
{ {
widget_node_t w; widget_node_t w;
p_clear(&w, 1); p_clear(&w, 1);
w.widget = widget_ref(widget); w.widget = widget_ref(L);
widget_node_array_append(widgets, w); widget_node_array_append(widgets, w);
} }
else
lua_pop(L, 1); /* remove value */
} }
} }
@ -186,7 +193,8 @@ widget_render(wibox_t *wibox)
/* compute geometry */ /* compute geometry */
for(int i = 0; i < widgets->len; i++) for(int i = 0; i < widgets->len; i++)
if(widgets->tab[i].widget->align == AlignLeft && widgets->tab[i].widget->isvisible) if(widgets->tab[i].widget->align == AlignLeft
&& widgets->tab[i].widget->isvisible)
{ {
widgets->tab[i].geometry = widgets->tab[i].widget->geometry(widgets->tab[i].widget, widgets->tab[i].geometry = widgets->tab[i].widget->geometry(widgets->tab[i].widget,
wibox->screen, ctx->height, wibox->screen, ctx->height,
@ -360,7 +368,7 @@ luaA_widget_new(lua_State *L)
if((wc = name_func_lookup(type, len, WidgetList))) if((wc = name_func_lookup(type, len, WidgetList)))
{ {
w = p_new(widget_t, 1); w = widget_new(L);
wc(w); wc(w);
} }
else else
@ -380,7 +388,7 @@ luaA_widget_new(lua_State *L)
w->mouse_enter = w->mouse_leave = LUA_REFNIL; w->mouse_enter = w->mouse_leave = LUA_REFNIL;
return luaA_widget_userdata_new(L, w); return 1;
} }
/** Get or set mouse buttons bindings to a widget. /** Get or set mouse buttons bindings to a widget.
@ -394,8 +402,8 @@ luaA_widget_new(lua_State *L)
static int static int
luaA_widget_buttons(lua_State *L) luaA_widget_buttons(lua_State *L)
{ {
widget_t **widget = luaA_checkudata(L, 1, "widget"); widget_t *widget = luaL_checkudata(L, 1, "widget");
button_array_t *buttons = &(*widget)->buttons; button_array_t *buttons = &widget->buttons;
if(lua_gettop(L) == 2) if(lua_gettop(L) == 2)
{ {
@ -419,7 +427,7 @@ static int
luaA_widget_index(lua_State *L) luaA_widget_index(lua_State *L)
{ {
size_t len; size_t len;
widget_t **widget = luaA_checkudata(L, 1, "widget"); widget_t *widget = luaL_checkudata(L, 1, "widget");
const char *buf = luaL_checklstring(L, 2, &len); const char *buf = luaL_checklstring(L, 2, &len);
awesome_token_t token; awesome_token_t token;
@ -429,20 +437,20 @@ luaA_widget_index(lua_State *L)
switch((token = a_tokenize(buf, len))) switch((token = a_tokenize(buf, len)))
{ {
case A_TK_ALIGN: case A_TK_ALIGN:
lua_pushstring(L, draw_align_tostr((*widget)->align)); lua_pushstring(L, draw_align_tostr(widget->align));
return 1; return 1;
case A_TK_VISIBLE: case A_TK_VISIBLE:
lua_pushboolean(L, (*widget)->isvisible); lua_pushboolean(L, widget->isvisible);
return 1; return 1;
case A_TK_MOUSE_ENTER: case A_TK_MOUSE_ENTER:
if((*widget)->mouse_enter != LUA_REFNIL) if(widget->mouse_enter != LUA_REFNIL)
lua_rawgeti(L, LUA_REGISTRYINDEX, (*widget)->mouse_enter); lua_rawgeti(L, LUA_REGISTRYINDEX, widget->mouse_enter);
else else
return 0; return 0;
return 1; return 1;
case A_TK_MOUSE_LEAVE: case A_TK_MOUSE_LEAVE:
if((*widget)->mouse_leave != LUA_REFNIL) if(widget->mouse_leave != LUA_REFNIL)
lua_rawgeti(L, LUA_REGISTRYINDEX, (*widget)->mouse_leave); lua_rawgeti(L, LUA_REGISTRYINDEX, widget->mouse_leave);
else else
return 0; return 0;
return 1; return 1;
@ -450,7 +458,7 @@ luaA_widget_index(lua_State *L)
break; break;
} }
return (*widget)->index ? (*widget)->index(L, token) : 0; return widget->index ? widget->index(L, token) : 0;
} }
/** Generic widget newindex. /** Generic widget newindex.
@ -461,7 +469,7 @@ static int
luaA_widget_newindex(lua_State *L) luaA_widget_newindex(lua_State *L)
{ {
size_t len; size_t len;
widget_t **widget = luaA_checkudata(L, 1, "widget"); widget_t *widget = luaL_checkudata(L, 1, "widget");
const char *buf = luaL_checklstring(L, 2, &len); const char *buf = luaL_checklstring(L, 2, &len);
awesome_token_t token; awesome_token_t token;
@ -469,22 +477,22 @@ luaA_widget_newindex(lua_State *L)
{ {
case A_TK_ALIGN: case A_TK_ALIGN:
buf = luaL_checklstring(L, 3, &len); buf = luaL_checklstring(L, 3, &len);
(*widget)->align = draw_align_fromstr(buf, len); widget->align = draw_align_fromstr(buf, len);
break; break;
case A_TK_VISIBLE: case A_TK_VISIBLE:
(*widget)->isvisible = luaA_checkboolean(L, 3); widget->isvisible = luaA_checkboolean(L, 3);
break; break;
case A_TK_MOUSE_ENTER: case A_TK_MOUSE_ENTER:
luaA_registerfct(L, 3, &(*widget)->mouse_enter); luaA_registerfct(L, 3, &widget->mouse_enter);
return 0; return 0;
case A_TK_MOUSE_LEAVE: case A_TK_MOUSE_LEAVE:
luaA_registerfct(L, 3, &(*widget)->mouse_leave); luaA_registerfct(L, 3, &widget->mouse_leave);
return 0; return 0;
default: default:
return (*widget)->newindex ? (*widget)->newindex(L, token) : 0; return widget->newindex ? widget->newindex(L, token) : 0;
} }
widget_invalidate_bywidget(*widget); widget_invalidate_bywidget(widget);
return 0; return 0;
} }
@ -500,7 +508,6 @@ const struct luaL_reg awesome_widget_meta[] =
{ "__index", luaA_widget_index }, { "__index", luaA_widget_index },
{ "__newindex", luaA_widget_newindex }, { "__newindex", luaA_widget_newindex },
{ "__gc", luaA_widget_gc }, { "__gc", luaA_widget_gc },
{ "__eq", luaA_widget_eq },
{ "__tostring", luaA_widget_tostring }, { "__tostring", luaA_widget_tostring },
{ NULL, NULL } { NULL, NULL }
}; };

View File

@ -24,22 +24,19 @@
#include "mouse.h" #include "mouse.h"
LUA_OBJECT_FUNCS(widget_t, widget, "widget");
struct widget_node_t struct widget_node_t
{ {
/** The widget */ /** The widget object */
widget_t *widget; widget_t *widget;
/** The geometry where the widget was drawn */ /** The geometry where the widget was drawn */
area_t geometry; area_t geometry;
}; };
void widget_delete(widget_t **);
DO_RCNT(widget_t, widget, widget_delete)
widget_t *widget_getbycoords(position_t, widget_node_array_t *, int, int, int16_t *, int16_t *); widget_t *widget_getbycoords(position_t, widget_node_array_t *, int, int, int16_t *, int16_t *);
void widget_render(wibox_t *); void widget_render(wibox_t *);
int luaA_widget_userdata_new(lua_State *, widget_t *);
void luaA_table2widgets(lua_State *, widget_node_array_t *); void luaA_table2widgets(lua_State *, widget_node_array_t *);
void widget_invalidate_bywidget(widget_t *); void widget_invalidate_bywidget(widget_t *);
@ -51,15 +48,7 @@ widget_constructor_t widget_graph;
widget_constructor_t widget_systray; widget_constructor_t widget_systray;
widget_constructor_t widget_imagebox; widget_constructor_t widget_imagebox;
/** Delete a widget node structure. void widget_node_delete(widget_node_t *);
* \param node The node to destroy.
*/
static inline void
widget_node_delete(widget_node_t *node)
{
widget_unref(&node->widget);
}
ARRAY_FUNCS(widget_node_t, widget_node, widget_node_delete) ARRAY_FUNCS(widget_node_t, widget_node, widget_node_delete)
#endif #endif

View File

@ -298,8 +298,8 @@ graph_draw(widget_t *widget, draw_context_t *ctx,
static int static int
luaA_graph_plot_properties_set(lua_State *L) luaA_graph_plot_properties_set(lua_State *L)
{ {
widget_t **widget = luaA_checkudata(L, 1, "widget"); widget_t *widget = luaL_checkudata(L, 1, "widget");
graph_data_t *d = (*widget)->data; graph_data_t *d = widget->data;
float max_value; float max_value;
const char *title, *buf; const char *title, *buf;
size_t len; size_t len;
@ -347,7 +347,7 @@ luaA_graph_plot_properties_set(lua_State *L)
for(i = 0; i <= reqs_nbr; i++) for(i = 0; i <= reqs_nbr; i++)
xcolor_init_reply(reqs[i]); xcolor_init_reply(reqs[i]);
widget_invalidate_bywidget(*widget); widget_invalidate_bywidget(widget);
return 0; return 0;
} }
@ -363,8 +363,8 @@ luaA_graph_plot_properties_set(lua_State *L)
static int static int
luaA_graph_plot_data_add(lua_State *L) luaA_graph_plot_data_add(lua_State *L)
{ {
widget_t **widget = luaA_checkudata(L, 1, "widget"); widget_t *widget = luaL_checkudata(L, 1, "widget");
graph_data_t *d = (*widget)->data; graph_data_t *d = widget->data;
plot_t *plot = NULL; plot_t *plot = NULL;
const char *title = luaL_checkstring(L, 2); const char *title = luaL_checkstring(L, 2);
float value; float value;
@ -420,7 +420,7 @@ luaA_graph_plot_data_add(lua_State *L)
plot->lines[plot->index] = d->box_height; plot->lines[plot->index] = d->box_height;
} }
widget_invalidate_bywidget(*widget); widget_invalidate_bywidget(widget);
return 0; return 0;
} }
@ -440,8 +440,8 @@ luaA_graph_plot_data_add(lua_State *L)
static int static int
luaA_graph_index(lua_State *L, awesome_token_t token) luaA_graph_index(lua_State *L, awesome_token_t token)
{ {
widget_t **widget = luaA_checkudata(L, 1, "widget"); widget_t *widget = luaL_checkudata(L, 1, "widget");
graph_data_t *d = (*widget)->data; graph_data_t *d = widget->data;
switch(token) switch(token)
{ {
@ -492,8 +492,8 @@ static int
luaA_graph_newindex(lua_State *L, awesome_token_t token) luaA_graph_newindex(lua_State *L, awesome_token_t token)
{ {
size_t len; size_t len;
widget_t **widget = luaA_checkudata(L, 1, "widget"); widget_t *widget = luaL_checkudata(L, 1, "widget");
graph_data_t *d = (*widget)->data; graph_data_t *d = widget->data;
const char *buf; const char *buf;
int width; int width;
position_t pos; position_t pos;
@ -559,7 +559,7 @@ luaA_graph_newindex(lua_State *L, awesome_token_t token)
return 0; return 0;
} }
widget_invalidate_bywidget(*widget); widget_invalidate_bywidget(widget);
return 0; return 0;
} }

View File

@ -132,8 +132,8 @@ imagebox_destructor(widget_t *w)
static int static int
luaA_imagebox_index(lua_State *L, awesome_token_t token) luaA_imagebox_index(lua_State *L, awesome_token_t token)
{ {
widget_t **widget = luaA_checkudata(L, 1, "widget"); widget_t *widget = luaL_checkudata(L, 1, "widget");
imagebox_data_t *d = (*widget)->data; imagebox_data_t *d = widget->data;
switch(token) switch(token)
{ {
@ -164,8 +164,8 @@ luaA_imagebox_index(lua_State *L, awesome_token_t token)
static int static int
luaA_imagebox_newindex(lua_State *L, awesome_token_t token) luaA_imagebox_newindex(lua_State *L, awesome_token_t token)
{ {
widget_t **widget = luaA_checkudata(L, 1, "widget"); widget_t *widget = luaL_checkudata(L, 1, "widget");
imagebox_data_t *d = (*widget)->data; imagebox_data_t *d = widget->data;
switch(token) switch(token)
{ {
@ -193,7 +193,7 @@ luaA_imagebox_newindex(lua_State *L, awesome_token_t token)
return 0; return 0;
} }
widget_invalidate_bywidget(*widget); widget_invalidate_bywidget(widget);
return 0; return 0;
} }

View File

@ -434,10 +434,10 @@ static int
luaA_progressbar_bar_properties_set(lua_State *L) luaA_progressbar_bar_properties_set(lua_State *L)
{ {
size_t len; size_t len;
widget_t **widget = luaA_checkudata(L, 1, "widget"); widget_t *widget = luaL_checkudata(L, 1, "widget");
const char *buf, *title = luaL_checkstring(L, 2); const char *buf, *title = luaL_checkstring(L, 2);
bar_t *bar; bar_t *bar;
progressbar_data_t *d = (*widget)->data; progressbar_data_t *d = widget->data;
xcolor_init_request_t reqs[6]; xcolor_init_request_t reqs[6];
int i, reqs_nbr = -1; int i, reqs_nbr = -1;
@ -483,7 +483,7 @@ luaA_progressbar_bar_properties_set(lua_State *L)
for(i = 0; i <= reqs_nbr; i++) for(i = 0; i <= reqs_nbr; i++)
xcolor_init_reply(reqs[i]); xcolor_init_reply(reqs[i]);
widget_invalidate_bywidget(*widget); widget_invalidate_bywidget(widget);
return 0; return 0;
} }
@ -499,9 +499,9 @@ luaA_progressbar_bar_properties_set(lua_State *L)
static int static int
luaA_progressbar_bar_data_add(lua_State *L) luaA_progressbar_bar_data_add(lua_State *L)
{ {
widget_t **widget = luaA_checkudata(L, 1, "widget"); widget_t *widget = luaL_checkudata(L, 1, "widget");
const char *title = luaL_checkstring(L, 2); const char *title = luaL_checkstring(L, 2);
progressbar_data_t *d = (*widget)->data; progressbar_data_t *d = widget->data;
bar_t *bar; bar_t *bar;
bar = progressbar_bar_get(&d->bars, title); bar = progressbar_bar_get(&d->bars, title);
@ -509,7 +509,7 @@ luaA_progressbar_bar_data_add(lua_State *L)
bar->value = luaL_checknumber(L, 3); bar->value = luaL_checknumber(L, 3);
bar->value = MAX(bar->min_value, MIN(bar->max_value, bar->value)); bar->value = MAX(bar->min_value, MIN(bar->max_value, bar->value));
widget_invalidate_bywidget(*widget); widget_invalidate_bywidget(widget);
return 0; return 0;
} }
@ -533,8 +533,8 @@ luaA_progressbar_bar_data_add(lua_State *L)
static int static int
luaA_progressbar_index(lua_State *L, awesome_token_t token) luaA_progressbar_index(lua_State *L, awesome_token_t token)
{ {
widget_t **widget = luaA_checkudata(L, 1, "widget"); widget_t *widget = luaL_checkudata(L, 1, "widget");
progressbar_data_t *d = (*widget)->data; progressbar_data_t *d = widget->data;
switch(token) switch(token)
{ {
@ -583,8 +583,8 @@ luaA_progressbar_index(lua_State *L, awesome_token_t token)
static int static int
luaA_progressbar_newindex(lua_State *L, awesome_token_t token) luaA_progressbar_newindex(lua_State *L, awesome_token_t token)
{ {
widget_t **widget = luaA_checkudata(L, 1, "widget"); widget_t *widget = luaL_checkudata(L, 1, "widget");
progressbar_data_t *d = (*widget)->data; progressbar_data_t *d = widget->data;
switch(token) switch(token)
{ {
@ -616,7 +616,7 @@ luaA_progressbar_newindex(lua_State *L, awesome_token_t token)
return 0; return 0;
} }
widget_invalidate_bywidget(*widget); widget_invalidate_bywidget(widget);
return 0; return 0;
} }

View File

@ -139,13 +139,13 @@ textbox_destructor(widget_t *w)
static int static int
luaA_textbox_margin(lua_State *L) luaA_textbox_margin(lua_State *L)
{ {
widget_t **widget = luaA_checkudata(L, 1, "widget"); widget_t *widget = luaL_checkudata(L, 1, "widget");
textbox_data_t *d = (*widget)->data; textbox_data_t *d = widget->data;
if(lua_gettop(L) == 2) if(lua_gettop(L) == 2)
{ {
d->margin = luaA_getopt_padding(L, 3, &d->margin); d->margin = luaA_getopt_padding(L, 3, &d->margin);
widget_invalidate_bywidget(*widget); widget_invalidate_bywidget(widget);
} }
return luaA_pushpadding(L, &d->margin); return luaA_pushpadding(L, &d->margin);
@ -172,8 +172,8 @@ luaA_textbox_margin(lua_State *L)
static int static int
luaA_textbox_index(lua_State *L, awesome_token_t token) luaA_textbox_index(lua_State *L, awesome_token_t token)
{ {
widget_t **widget = luaA_checkudata(L, 1, "widget"); widget_t *widget = luaL_checkudata(L, 1, "widget");
textbox_data_t *d = (*widget)->data; textbox_data_t *d = widget->data;
switch(token) switch(token)
{ {
@ -251,9 +251,9 @@ static int
luaA_textbox_newindex(lua_State *L, awesome_token_t token) luaA_textbox_newindex(lua_State *L, awesome_token_t token)
{ {
size_t len = 0; size_t len = 0;
widget_t **widget = luaA_checkudata(L, 1, "widget"); widget_t *widget = luaL_checkudata(L, 1, "widget");
const char *buf = NULL; const char *buf = NULL;
textbox_data_t *d = (*widget)->data; textbox_data_t *d = widget->data;
switch(token) switch(token)
{ {
@ -353,7 +353,7 @@ luaA_textbox_newindex(lua_State *L, awesome_token_t token)
return 0; return 0;
} }
widget_invalidate_bywidget(*widget); widget_invalidate_bywidget(widget);
return 0; return 0;
} }