awful.hooks.timer: fix timer removal

Signed-off-by: Gregor Best <farhaven@googlemail.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Gregor Best 2009-02-06 15:08:47 +01:00 committed by Julien Danjou
parent dd2c62721c
commit bc1a2f5448
1 changed files with 7 additions and 1 deletions

View File

@ -54,7 +54,7 @@ for name, hook in pairs(capi.hooks) do
_M[name] = {} _M[name] = {}
if name == 'timer' then if name == 'timer' then
_M[name].register = function (time, f, runnow) _M[name].register = function (time, f, runnow)
if type(time) ~= 'number' or type(f) ~= 'function' or time <= 0 then if type(time) ~= 'number' or type(f) ~= 'function' or time < 0 then
return return
end end
local new_timer local new_timer
@ -94,6 +94,12 @@ for name, hook in pairs(capi.hooks) do
break break
end end
end end
local delays = { }
for k, h in ipairs(_M[name].callbacks) do
table.insert(delays, h.timer)
end
table.sort(delays)
hook(delays[1])
end end
end end
elseif name == "dbus" then elseif name == "dbus" then