From 95180799ccc695badf8762d3949dc990bdeaa464 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 8 May 2009 14:00:43 +0200 Subject: [PATCH] button: change copy method We know also copy release. Signed-off-by: Julien Danjou --- button.c | 26 +------------------------- lib/awful/widget/common.lua.in | 7 +++++-- 2 files changed, 6 insertions(+), 27 deletions(-) diff --git a/button.c b/button.c index 0efc28241..f6fbf018a 100644 --- a/button.c +++ b/button.c @@ -60,33 +60,9 @@ static int luaA_button_new(lua_State *L) { xcb_button_t xbutton; - button_t *button, *orig; + button_t *button; luaA_ref press = LUA_REFNIL, release = LUA_REFNIL; - if((orig = luaA_toudata(L, 2, "button"))) - { - button_t *copy = button_new(L); - copy->mod = orig->mod; - copy->button = orig->button; - if(orig->press != LUA_REFNIL) - { - lua_rawgeti(L, LUA_REGISTRYINDEX, orig->press); - luaA_registerfct(L, -1, ©->press); - lua_pop(L, 1); - } - else - copy->press = LUA_REFNIL; - if(orig->release != LUA_REFNIL) - { - lua_rawgeti(L, LUA_REGISTRYINDEX, orig->release); - luaA_registerfct(L, -1, ©->release); - lua_pop(L, 1); - } - else - copy->release = LUA_REFNIL; - return 1; - } - luaA_checktable(L, 2); /* arg 3 is mouse button */ xbutton = luaL_checknumber(L, 3); diff --git a/lib/awful/widget/common.lua.in b/lib/awful/widget/common.lua.in index d2b5aa91a..a301b086d 100644 --- a/lib/awful/widget/common.lua.in +++ b/lib/awful/widget/common.lua.in @@ -58,8 +58,11 @@ function list_update(w, buttons, label, data, widgets, objects) -- argument for kb, b in ipairs(buttons) do -- Copy object - data[o][kb] = capi.button(b) - data[o][kb].press = function () b.press(o) end + local bpress, brelease = b.press, b.release + local press, release + if bpress then press = function() bpress(o) end end + if brelease then release = function () brelease(o) end end + data[o][kb] = capi.button(b.modifiers, b.button, press, release) end end w[k]:buttons(data[o])