From 826861d9678f75a40a2129ec5a25b3ca5fdca299 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 15 Jan 2012 16:05:11 +0100 Subject: [PATCH] screen: Add screen.by_coords() This idea came from here: http://article.gmane.org/gmane.comp.window-managers.awesome.devel/6759 Signed-off-by: Uli Schlachter --- screen.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/screen.c b/screen.c index 3dc70d49c..eb2890205 100644 --- a/screen.c +++ b/screen.c @@ -662,9 +662,26 @@ luaA_screen_count(lua_State *L) return 1; } +/** Get a screen by coordinates. + * \param L The Lua VM state. + * \return The number of elements pushed on stack. + * + * \luastack + * \lreturn The screen count, at least 1. + */ +static int +luaA_screen_by_coords(lua_State *L) +{ + int x = luaL_checknumber(L, 1); + int y = luaL_checknumber(L, 2); + luaA_pushscreen(L, screen_getbycoord(x, y)); + return 1; +} + const struct luaL_reg awesome_screen_methods[] = { { "count", luaA_screen_count }, + { "by_coords", luaA_screen_by_coords }, { "__index", luaA_screen_module_index }, { NULL, NULL } };