From 21f726c3ce87d2bfa05c2b18033577877f5126d4 Mon Sep 17 00:00:00 2001 From: Charlotte Meyer Date: Tue, 31 Dec 2019 13:46:21 +0000 Subject: [PATCH] Change on_cursor_button's callbacks parameter to a table --- kiwmi/luak.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/kiwmi/luak.c b/kiwmi/luak.c index 3492bb2..f8d9ce9 100644 --- a/kiwmi/luak.c +++ b/kiwmi/luak.c @@ -191,13 +191,22 @@ on_cursor_button_notify(struct wl_listener *listener, void *data) lua_rawgeti(L, LUA_REGISTRYINDEX, lc->callback_ref); - lua_pushinteger(L, event->state); - lua_pushinteger(L, event->button); - lua_pushinteger(L, event->time_msec); - lua_pushlightuserdata(L, event->device); // TODO: make un-opaque + lua_newtable(L); - if (lua_pcall(L, 4, 0, 0)) { - wlr_log(WLR_ERROR, "%s", lua_tostring(L, 1)); + lua_pushlightuserdata(L, event->device); // TODO: make un-opaque + lua_setfield(L, -2, "device"); + + lua_pushinteger(L, event->time_msec); + lua_setfield(L, -2, "time"); + + lua_pushinteger(L, event->button); + lua_setfield(L, -2, "button"); + + lua_pushinteger(L, event->state); + lua_setfield(L, -2, "state"); + + if (lua_pcall(L, 1, 0, 0)) { + wlr_log(WLR_ERROR, "%s", lua_tostring(L, -1)); } }