client: client.get() supports screen as argument
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
6666060d87
commit
f57d28d894
16
client.c
16
client.c
|
@ -878,21 +878,35 @@ client_kill(client_t *c)
|
||||||
* \param L The Lua VM state.
|
* \param L The Lua VM state.
|
||||||
* \return The number of elements pushed on stack.
|
* \return The number of elements pushed on stack.
|
||||||
* \luastack
|
* \luastack
|
||||||
|
* \lparam An optional screen nunmber.
|
||||||
* \lreturn A table with all clients.
|
* \lreturn A table with all clients.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
luaA_client_get(lua_State *L)
|
luaA_client_get(lua_State *L)
|
||||||
{
|
{
|
||||||
int i = 1;
|
int i = 1, screen;
|
||||||
client_t *c;
|
client_t *c;
|
||||||
|
|
||||||
|
screen = luaL_optnumber(L, 1, 0) - 1;
|
||||||
|
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
|
|
||||||
|
if(screen == SCREEN_UNDEF)
|
||||||
for(c = globalconf.clients; c; c = c->next)
|
for(c = globalconf.clients; c; c = c->next)
|
||||||
{
|
{
|
||||||
luaA_client_userdata_new(globalconf.L, c);
|
luaA_client_userdata_new(globalconf.L, c);
|
||||||
lua_rawseti(L, -2, i++);
|
lua_rawseti(L, -2, i++);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
luaA_checkscreen(screen);
|
||||||
|
for(c = globalconf.clients; c; c = c->next)
|
||||||
|
if(c->screen == screen)
|
||||||
|
{
|
||||||
|
luaA_client_userdata_new(globalconf.L, c);
|
||||||
|
lua_rawseti(L, -2, i++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue