[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)
|
if((tag->ncol = ncol) < 1)
|
||||||
tag->ncol = 1;
|
tag->ncol = 1;
|
||||||
|
|
||||||
tag_ref(&tag);
|
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +266,7 @@ static int
|
||||||
luaA_tag_get(lua_State *L)
|
luaA_tag_get(lua_State *L)
|
||||||
{
|
{
|
||||||
int screen = luaL_checknumber(L, 1) - 1;
|
int screen = luaL_checknumber(L, 1) - 1;
|
||||||
tag_t *tag, **tobj;
|
tag_t *tag;
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
luaA_checkscreen(screen);
|
luaA_checkscreen(screen);
|
||||||
|
@ -277,10 +275,7 @@ luaA_tag_get(lua_State *L)
|
||||||
|
|
||||||
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
|
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
|
||||||
{
|
{
|
||||||
tobj = lua_newuserdata(L, sizeof(tag_t *));
|
luaA_tag_userdata_new(tag);
|
||||||
*tobj = tag;
|
|
||||||
tag_ref(&tag);
|
|
||||||
luaA_settype(L, "tag");
|
|
||||||
lua_rawseti(L, -2, i++);
|
lua_rawseti(L, -2, i++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +289,7 @@ luaA_tag_get(lua_State *L)
|
||||||
static int
|
static int
|
||||||
luaA_tag_new(lua_State *L)
|
luaA_tag_new(lua_State *L)
|
||||||
{
|
{
|
||||||
tag_t **tag;
|
tag_t *tag;
|
||||||
int ncol, nmaster;
|
int ncol, nmaster;
|
||||||
const char *name, *lay;
|
const char *name, *lay;
|
||||||
double mwfact;
|
double mwfact;
|
||||||
|
@ -310,13 +305,11 @@ luaA_tag_new(lua_State *L)
|
||||||
|
|
||||||
layout = name_func_lookup(lay, LayoutList);
|
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,
|
return luaA_tag_userdata_new(tag);
|
||||||
layout,
|
|
||||||
mwfact, nmaster, ncol);
|
|
||||||
|
|
||||||
return luaA_settype(L, "tag");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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[] =
|
const struct luaL_reg awesome_tag_methods[] =
|
||||||
{
|
{
|
||||||
{ "new", luaA_tag_new },
|
{ "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_client_with_current_selected(client_t *);
|
||||||
void tag_view_only_byindex(int, int);
|
void tag_view_only_byindex(int, int);
|
||||||
void tag_append_to_screen(tag_t *, int);
|
void tag_append_to_screen(tag_t *, int);
|
||||||
|
int luaA_tag_userdata_new(tag_t *);
|
||||||
|
|
||||||
DO_RCNT(tag_t, tag, tag_delete)
|
DO_RCNT(tag_t, tag, tag_delete)
|
||||||
DO_SLIST(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_data_t *data = w->widget->data;
|
||||||
taglist_drawn_area_t *tda;
|
taglist_drawn_area_t *tda;
|
||||||
area_t *area;
|
area_t *area;
|
||||||
tag_t *tag, **ltag;
|
tag_t *tag;
|
||||||
|
|
||||||
/* Find the good drawn area list */
|
/* Find the good drawn area list */
|
||||||
for(tda = data->drawn_area; tda && tda->statusbar != statusbar; tda = tda->next);
|
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)
|
if(ev->event_x >= AREA_LEFT(*area)
|
||||||
&& ev->event_x < AREA_RIGHT(*area))
|
&& ev->event_x < AREA_RIGHT(*area))
|
||||||
{
|
{
|
||||||
ltag = lua_newuserdata(globalconf.L, sizeof(tag_t *));
|
luaA_tag_userdata_new(tag);
|
||||||
luaA_settype(globalconf.L, "tag");
|
|
||||||
*ltag = tag;
|
|
||||||
tag_ref(ltag);
|
|
||||||
luaA_dofunction(globalconf.L, b->fct, 1);
|
luaA_dofunction(globalconf.L, b->fct, 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -223,10 +220,7 @@ taglist_button_press(widget_node_t *w, statusbar_t *statusbar,
|
||||||
if(ev->event_y >= AREA_LEFT(*area)
|
if(ev->event_y >= AREA_LEFT(*area)
|
||||||
&& ev->event_y < AREA_RIGHT(*area))
|
&& ev->event_y < AREA_RIGHT(*area))
|
||||||
{
|
{
|
||||||
ltag = lua_newuserdata(globalconf.L, sizeof(tag_t *));
|
luaA_tag_userdata_new(tag);
|
||||||
luaA_settype(globalconf.L, "tag");
|
|
||||||
*ltag = tag;
|
|
||||||
tag_ref(ltag);
|
|
||||||
luaA_dofunction(globalconf.L, b->fct, 1);
|
luaA_dofunction(globalconf.L, b->fct, 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -235,10 +229,7 @@ taglist_button_press(widget_node_t *w, statusbar_t *statusbar,
|
||||||
if(statusbar->width - ev->event_y >= AREA_LEFT(*area)
|
if(statusbar->width - ev->event_y >= AREA_LEFT(*area)
|
||||||
&& statusbar->width - ev->event_y < AREA_RIGHT(*area))
|
&& statusbar->width - ev->event_y < AREA_RIGHT(*area))
|
||||||
{
|
{
|
||||||
ltag = lua_newuserdata(globalconf.L, sizeof(tag_t *));
|
luaA_tag_userdata_new(tag);
|
||||||
luaA_settype(globalconf.L, "tag");
|
|
||||||
*ltag = tag;
|
|
||||||
tag_ref(ltag);
|
|
||||||
luaA_dofunction(globalconf.L, b->fct, 1);
|
luaA_dofunction(globalconf.L, b->fct, 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue