screen: add index by output name (FS#361)

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-09-21 20:35:14 +02:00
parent c08b90345f
commit 9393b2d111
1 changed files with 8 additions and 0 deletions

View File

@ -442,6 +442,14 @@ luaA_pushscreen(lua_State *L, screen_t *s)
static int static int
luaA_screen_module_index(lua_State *L) luaA_screen_module_index(lua_State *L)
{ {
const char *name;
if((name = lua_tostring(L, 2)))
foreach(screen, globalconf.screens)
foreach(output, screen->outputs)
if(!a_strcmp(output->name, name))
return luaA_pushscreen(L, screen);
int screen = luaL_checknumber(L, 2) - 1; int screen = luaL_checknumber(L, 2) - 1;
luaA_checkscreen(screen); luaA_checkscreen(screen);
return luaA_pushscreen(L, &globalconf.screens.tab[screen]); return luaA_pushscreen(L, &globalconf.screens.tab[screen]);