luaa: add root.cursor()

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-04-03 17:11:51 +02:00
parent e4b9b2b2b4
commit 97baf01cec
1 changed files with 32 additions and 1 deletions

33
luaa.c
View File

@ -49,7 +49,7 @@
#include "selection.h" #include "selection.h"
#include "window.h" #include "window.h"
#include "common/socket.h" #include "common/socket.h"
#include "common/buffer.h" #include "common/xcursor.h"
extern awesome_t globalconf; extern awesome_t globalconf;
@ -126,6 +126,36 @@ luaA_root_buttons(lua_State *L)
return luaA_button_array_get(L, &globalconf.buttons); return luaA_button_array_get(L, &globalconf.buttons);
} }
/** Set the root cursor.
* \param L The Lua VM state.
* \return The number of element pushed on stack.
* \luastack
* \lparam A X cursor name.
*/
static int
luaA_root_cursor(lua_State *L)
{
const char *cursor_name = luaL_checkstring(L, 1);
uint16_t cursor_font = xcursor_font_fromstr(cursor_name);
if(cursor_font)
{
uint32_t change_win_vals[] = { xcursor_new(globalconf.connection, cursor_font) };
for(int screen_nbr = 0;
screen_nbr < xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
screen_nbr++)
xcb_change_window_attributes(globalconf.connection,
xutil_screen_get(globalconf.connection, screen_nbr)->root,
XCB_CW_CURSOR,
change_win_vals);
}
else
luaA_warn(L, "invalid cursor %s", cursor_name);
return 0;
}
/** Quit awesome. /** Quit awesome.
* \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.
@ -712,6 +742,7 @@ luaA_init(void)
{ {
{ "buttons", luaA_root_buttons }, { "buttons", luaA_root_buttons },
{ "keys", luaA_root_keys }, { "keys", luaA_root_keys },
{ "cursor", luaA_root_cursor },
{ NULL, NULL } { NULL, NULL }
}; };