/** Mouse library. * \param L The Lua VM state. * \return The number of elements pushed on stack. * \luastack * \lfield coords Mouse coordinates. * \lfield screen Mouse screen number. */ static int luaA_mouse_index(lua_State *L) { const char *attr = luaL_checkstring(L, 2); int16_t mouse_x, mouse_y; screen_t *screen; /* attr is not "screen"?! */ if (A_STRNEQ(attr, "screen")) return 0; if (!mouse_query_pointer_root(&mouse_x, &mouse_y, NULL)) return 0; screen = screen_getbycoord(mouse_x, mouse_y); lua_pushnumber(L, screen_array_indexof(&globalconf.screens, screen) + 1); return 1; }
/** Get the client which is under the pointer. * \param L The Lua VM state. * \return The number of elements pushed on stack. * \luastack * \lreturn A client or nil. */ static int luaA_mouse_object_under_pointer(lua_State *L) { int16_t mouse_x, mouse_y; xcb_window_t child; if(!mouse_query_pointer_root(&mouse_x, &mouse_y, &child, NULL)) return 0; drawin_t *drawin; client_t *client; if((drawin = drawin_getbywin(child))) return luaA_object_push(L, drawin); if((client = client_getbyframewin(child))) return luaA_object_push(globalconf.L, client); return 0; }