[client] Add titlebar_get()

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-06-04 13:36:13 +02:00
parent 70dbc724bf
commit 80ec848130
4 changed files with 30 additions and 2 deletions

View File

@ -1155,6 +1155,20 @@ luaA_client_titlebar_set(lua_State *L)
return 0; return 0;
} }
/** Get the titlebar of a client.
* \return A titlebar or nil if the client has no titlebar.
*/
static int
luaA_client_titlebar_get(lua_State *L)
{
client_t **c = luaL_checkudata(L, 1, "client");
if((*c)->titlebar)
return luaA_titlebar_userdata_new((*c)->titlebar);
return 0;
}
/** Stop managing a client. /** Stop managing a client.
*/ */
static int static int
@ -1184,6 +1198,7 @@ const struct luaL_reg awesome_client_methods[] =
const struct luaL_reg awesome_client_meta[] = const struct luaL_reg awesome_client_meta[] =
{ {
{ "titlebar_set", luaA_client_titlebar_set }, { "titlebar_set", luaA_client_titlebar_set },
{ "titlebar_get", luaA_client_titlebar_get },
{ "name_get", luaA_client_name_get }, { "name_get", luaA_client_name_get },
{ "name_set", luaA_client_name_set }, { "name_set", luaA_client_name_set },
{ "screen_set", luaA_client_screen_set }, { "screen_set", luaA_client_screen_set },

View File

@ -478,6 +478,18 @@ luaA_titlebar_widget_get(lua_State *L)
return 1; return 1;
} }
/** Create a new titlebar userdata.
* \param t The titlebar.
*/
int
luaA_titlebar_userdata_new(titlebar_t *t)
{
titlebar_t **tb = lua_newuserdata(globalconf.L, sizeof(titlebar_t *));
*tb = t;
titlebar_ref(tb);
return luaA_settype(globalconf.L, "titlebar");
}
static int static int
luaA_titlebar_gc(lua_State *L) luaA_titlebar_gc(lua_State *L)
{ {

View File

@ -30,6 +30,8 @@ void titlebar_update_geometry_floating(client_t *);
void titlebar_update_geometry(client_t *, area_t); void titlebar_update_geometry(client_t *, area_t);
void titlebar_init(client_t *); void titlebar_init(client_t *);
int luaA_titlebar_userdata_new(titlebar_t *);
/** Add the titlebar geometry to a geometry. /** Add the titlebar geometry to a geometry.
* \param t the titlebar * \param t the titlebar
* \param geometry the geometry * \param geometry the geometry

View File

@ -299,8 +299,7 @@ widget_invalidate_bywidget(widget_t *widget)
int int
luaA_widget_userdata_new(widget_t *widget) luaA_widget_userdata_new(widget_t *widget)
{ {
widget_t **w; widget_t **w = lua_newuserdata(globalconf.L, sizeof(widget_t *));
w = lua_newuserdata(globalconf.L, sizeof(widget_t *));
*w = widget; *w = widget;
widget_ref(w); widget_ref(w);
return luaA_settype(globalconf.L, "widget"); return luaA_settype(globalconf.L, "widget");