diff --git a/mouse.c b/mouse.c index 6cec6edd..ab8a958d 100644 --- a/mouse.c +++ b/mouse.c @@ -70,6 +70,17 @@ a_strtocorner(const char *str, size_t len) } } +/** Delete a button. + * \param button The button to destroy. + */ +void +button_delete(button_t **button) +{ + luaL_unref(globalconf.L, LUA_REGISTRYINDEX, (*button)->press); + luaL_unref(globalconf.L, LUA_REGISTRYINDEX, (*button)->release); + p_delete(button); +} + /** Snap an area to the outside of an area. * \param geometry geometry of the area to snap * \param snap_geometry geometry of snapping area diff --git a/structs.h b/structs.h index 979bca6e..a7e0b823 100644 --- a/structs.h +++ b/structs.h @@ -115,7 +115,10 @@ struct button_t /** Lua function to execute on release. */ luaA_ref release; }; -DO_RCNT(button_t, button, p_delete) + +void button_delete(button_t **button); + +DO_RCNT(button_t, button, button_delete) DO_ARRAY(button_t *, button, button_unref) /** Widget */