/** Get or set the mouse coords. * \param L The Lua VM state. * \return The number of elements pushed on stack. */ static int luaA_mouse_coords(lua_State *L) { uint16_t mask; int x, y; int16_t mouse_x, mouse_y; if(lua_gettop(L) >= 1) { luaA_checktable(L, 1); bool ignore_enter_notify = (lua_gettop(L) == 2 && luaA_checkboolean(L, 2)); if(!mouse_query_pointer_root(&mouse_x, &mouse_y, NULL, &mask)) return 0; x = luaA_getopt_number(L, 1, "x", mouse_x); y = luaA_getopt_number(L, 1, "y", mouse_y); if(ignore_enter_notify) client_ignore_enterleave_events(); mouse_warp_pointer(globalconf.screen->root, x, y); if(ignore_enter_notify) client_restore_enterleave_events(); lua_pop(L, 1); } if(!mouse_query_pointer_root(&mouse_x, &mouse_y, NULL, &mask)) return 0; return luaA_mouse_pushstatus(L, mouse_x, mouse_y, mask); }
/** Handle mouse motion events. * \param L Lua stack to push the pointer motion. * \param x The received mouse event x component. * \param y The received mouse event y component. * \param mask The received mouse event bit mask. */ void mousegrabber_handleevent(lua_State *L, int x, int y, uint16_t mask) { luaA_mouse_pushstatus(L, x, y, mask); }