add mouse.coords_get()

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
This commit is contained in:
Pierre Habouzit 2008-06-19 12:17:30 +02:00
parent f125ad57a9
commit 4360fc51b2
1 changed files with 27 additions and 0 deletions

27
mouse.c
View File

@ -963,6 +963,32 @@ mouse_client_resize(client_t *c, corner_t corner, bool infobox)
}
}
/** Set mouse coordinates.
* \param L The Lua VM state.
*
* \luastack
* \lparam The x coordinate.
* \lparam The y coordinate.
*/
static int
luaA_mouse_coords_get(lua_State *L)
{
int mouse_x, mouse_y;
xcb_window_t root;
root = xutil_screen_get(globalconf.connection, globalconf.default_screen)->root;
if(!mouse_query_pointer(root, &mouse_x, &mouse_y))
return 0;
lua_newtable(L);
lua_pushnumber(L, mouse_x);
lua_setfield(L, -2, "x");
lua_pushnumber(L, mouse_y);
lua_setfield(L, -2, "y");
return 1;
}
/** Set mouse coordinates.
* \param L The Lua VM state.
*
@ -1107,6 +1133,7 @@ const struct luaL_reg awesome_mouse_methods[] =
{ "new", luaA_mouse_new },
{ "screen_get", luaA_mouse_screen_get },
{ "coords_set", luaA_mouse_coords_set },
{ "coords_get", luaA_mouse_coords_get },
{ NULL, NULL }
};
const struct luaL_reg awesome_mouse_meta[] =