[tag] Add luaA_tag_userdata_new() function
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
4a17da051f
commit
4e4a7d2703
30
tag.c
30
tag.c
|
@ -77,8 +77,6 @@ tag_new(const char *name, layout_t *layout, double mwfact, int nmaster, int ncol
|
|||
if((tag->ncol = ncol) < 1)
|
||||
tag->ncol = 1;
|
||||
|
||||
tag_ref(&tag);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
@ -268,7 +266,7 @@ static int
|
|||
luaA_tag_get(lua_State *L)
|
||||
{
|
||||
int screen = luaL_checknumber(L, 1) - 1;
|
||||
tag_t *tag, **tobj;
|
||||
tag_t *tag;
|
||||
int i = 1;
|
||||
|
||||
luaA_checkscreen(screen);
|
||||
|
@ -277,10 +275,7 @@ luaA_tag_get(lua_State *L)
|
|||
|
||||
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
|
||||
{
|
||||
tobj = lua_newuserdata(L, sizeof(tag_t *));
|
||||
*tobj = tag;
|
||||
tag_ref(&tag);
|
||||
luaA_settype(L, "tag");
|
||||
luaA_tag_userdata_new(tag);
|
||||
lua_rawseti(L, -2, i++);
|
||||
}
|
||||
|
||||
|
@ -294,7 +289,7 @@ luaA_tag_get(lua_State *L)
|
|||
static int
|
||||
luaA_tag_new(lua_State *L)
|
||||
{
|
||||
tag_t **tag;
|
||||
tag_t *tag;
|
||||
int ncol, nmaster;
|
||||
const char *name, *lay;
|
||||
double mwfact;
|
||||
|
@ -310,13 +305,11 @@ luaA_tag_new(lua_State *L)
|
|||
|
||||
layout = name_func_lookup(lay, LayoutList);
|
||||
|
||||
tag = lua_newuserdata(L, sizeof(tag_t *));
|
||||
tag = tag_new(name,
|
||||
layout,
|
||||
mwfact, nmaster, ncol);
|
||||
|
||||
*tag = tag_new(name,
|
||||
layout,
|
||||
mwfact, nmaster, ncol);
|
||||
|
||||
return luaA_settype(L, "tag");
|
||||
return luaA_tag_userdata_new(tag);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -462,6 +455,15 @@ luaA_tag_layout_set(lua_State *L)
|
|||
|
||||
}
|
||||
|
||||
int
|
||||
luaA_tag_userdata_new(tag_t *t)
|
||||
{
|
||||
tag_t **lt = lua_newuserdata(globalconf.L, sizeof(tag_t *));
|
||||
*lt = t;
|
||||
tag_ref(lt);
|
||||
return luaA_settype(globalconf.L, "tag");
|
||||
}
|
||||
|
||||
const struct luaL_reg awesome_tag_methods[] =
|
||||
{
|
||||
{ "new", luaA_tag_new },
|
||||
|
|
1
tag.h
1
tag.h
|
@ -45,6 +45,7 @@ bool is_client_tagged(client_t *, tag_t *);
|
|||
void tag_client_with_current_selected(client_t *);
|
||||
void tag_view_only_byindex(int, int);
|
||||
void tag_append_to_screen(tag_t *, int);
|
||||
int luaA_tag_userdata_new(tag_t *);
|
||||
|
||||
DO_RCNT(tag_t, tag, tag_delete)
|
||||
DO_SLIST(tag_t, tag, tag_delete)
|
||||
|
|
|
@ -196,7 +196,7 @@ taglist_button_press(widget_node_t *w, statusbar_t *statusbar,
|
|||
taglist_data_t *data = w->widget->data;
|
||||
taglist_drawn_area_t *tda;
|
||||
area_t *area;
|
||||
tag_t *tag, **ltag;
|
||||
tag_t *tag;
|
||||
|
||||
/* Find the good drawn area list */
|
||||
for(tda = data->drawn_area; tda && tda->statusbar != statusbar; tda = tda->next);
|
||||
|
@ -211,10 +211,7 @@ taglist_button_press(widget_node_t *w, statusbar_t *statusbar,
|
|||
if(ev->event_x >= AREA_LEFT(*area)
|
||||
&& ev->event_x < AREA_RIGHT(*area))
|
||||
{
|
||||
ltag = lua_newuserdata(globalconf.L, sizeof(tag_t *));
|
||||
luaA_settype(globalconf.L, "tag");
|
||||
*ltag = tag;
|
||||
tag_ref(ltag);
|
||||
luaA_tag_userdata_new(tag);
|
||||
luaA_dofunction(globalconf.L, b->fct, 1);
|
||||
}
|
||||
break;
|
||||
|
@ -223,10 +220,7 @@ taglist_button_press(widget_node_t *w, statusbar_t *statusbar,
|
|||
if(ev->event_y >= AREA_LEFT(*area)
|
||||
&& ev->event_y < AREA_RIGHT(*area))
|
||||
{
|
||||
ltag = lua_newuserdata(globalconf.L, sizeof(tag_t *));
|
||||
luaA_settype(globalconf.L, "tag");
|
||||
*ltag = tag;
|
||||
tag_ref(ltag);
|
||||
luaA_tag_userdata_new(tag);
|
||||
luaA_dofunction(globalconf.L, b->fct, 1);
|
||||
}
|
||||
break;
|
||||
|
@ -235,10 +229,7 @@ taglist_button_press(widget_node_t *w, statusbar_t *statusbar,
|
|||
if(statusbar->width - ev->event_y >= AREA_LEFT(*area)
|
||||
&& statusbar->width - ev->event_y < AREA_RIGHT(*area))
|
||||
{
|
||||
ltag = lua_newuserdata(globalconf.L, sizeof(tag_t *));
|
||||
luaA_settype(globalconf.L, "tag");
|
||||
*ltag = tag;
|
||||
tag_ref(ltag);
|
||||
luaA_tag_userdata_new(tag);
|
||||
luaA_dofunction(globalconf.L, b->fct, 1);
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue