button: change copy method

We know also copy release.

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-05-08 14:00:43 +02:00
parent fe35104bc2
commit 95180799cc
2 changed files with 6 additions and 27 deletions

View File

@ -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, &copy->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, &copy->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);

View File

@ -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])