From 458a770fd7775338997d7ca26121693b25f315a8 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 13 Jul 2009 14:26:18 +0200 Subject: [PATCH] screen: add luaA_pushscreen Signed-off-by: Julien Danjou --- screen.c | 18 +++++++++++++++--- screen.h | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/screen.c b/screen.c index 3687930e..08e54235 100644 --- a/screen.c +++ b/screen.c @@ -338,6 +338,20 @@ screen_client_moveto(client_t *c, screen_t *new_screen, bool dotag, bool doresiz hook_property(client, c, "screen"); } +/** Push a screen onto the stack. + * \param L The Lua VM state. + * \param s The scren to push. + * \return The number of elements pushed on stack. + */ +int +luaA_pushscreen(lua_State *L, screen_t *s) +{ + lua_pushlightuserdata(L, s); + luaL_getmetatable(L, "screen"); + lua_setmetatable(L, -2); + return 1; +} + /** Screen module. * \param L The Lua VM state. * \return The number of elements pushed on stack. @@ -348,10 +362,8 @@ static int luaA_screen_module_index(lua_State *L) { int screen = luaL_checknumber(L, 2) - 1; - luaA_checkscreen(screen); - lua_pushlightuserdata(L, &globalconf.screens.tab[screen]); - return luaA_settype(L, "screen"); + return luaA_pushscreen(L, &globalconf.screens.tab[screen]); } /** Get or set screen tags. diff --git a/screen.h b/screen.h index 0308f69c..69f7fddd 100644 --- a/screen.h +++ b/screen.h @@ -56,6 +56,7 @@ area_t screen_area_get(screen_t *, bool); area_t display_area_get(int); int screen_virttophys(int); void screen_client_moveto(client_t *, screen_t *, bool, bool); +int luaA_pushscreen(lua_State *, screen_t *); #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80