diff --git a/mouse.c b/mouse.c index b5efbe98..852e4fb0 100644 --- a/mouse.c +++ b/mouse.c @@ -875,6 +875,17 @@ luaA_mouse_new(lua_State *L) return luaA_mouse_userdata_new(button); } +/** Handle mouse garbage collection. + */ +static int +luaA_mouse_gc(lua_State *L) +{ + button_t **b = luaA_checkudata(L, 1, "mouse"); + button_unref(b); + *b = NULL; + return 0; +} + const struct luaL_reg awesome_mouse_methods[] = { { "new", luaA_mouse_new }, @@ -884,6 +895,7 @@ const struct luaL_reg awesome_mouse_methods[] = }; const struct luaL_reg awesome_mouse_meta[] = { + { "__gc", luaA_mouse_gc }, { NULL, NULL } };