naughty: use timer
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
1c8be5b620
commit
e899ca7696
|
@ -14,7 +14,8 @@ local capi = { screen = screen,
|
||||||
dbus = dbus,
|
dbus = dbus,
|
||||||
widget = widget,
|
widget = widget,
|
||||||
wibox = wibox,
|
wibox = wibox,
|
||||||
image = image }
|
image = image,
|
||||||
|
timer = timer }
|
||||||
local hooks = require("awful.hooks")
|
local hooks = require("awful.hooks")
|
||||||
local button = require("awful.button")
|
local button = require("awful.button")
|
||||||
local util = require("awful.util")
|
local util = require("awful.util")
|
||||||
|
@ -175,7 +176,7 @@ function destroy(notification)
|
||||||
if notification and notification.box.screen then
|
if notification and notification.box.screen then
|
||||||
local scr = notification.box.screen
|
local scr = notification.box.screen
|
||||||
table.remove(notifications[notification.box.screen][notification.position], notification.idx)
|
table.remove(notifications[notification.box.screen][notification.position], notification.idx)
|
||||||
hooks.timer.unregister(notification.die)
|
notification.timer:stop()
|
||||||
notification.box.screen = nil
|
notification.box.screen = nil
|
||||||
arrange(scr)
|
arrange(scr)
|
||||||
return true
|
return true
|
||||||
|
@ -293,9 +294,12 @@ function notify(args)
|
||||||
if title then title = title .. "\n" else title = "" end
|
if title then title = title .. "\n" else title = "" end
|
||||||
|
|
||||||
-- hook destroy
|
-- hook destroy
|
||||||
|
local timer_die = capi.timer { timeout = timeout }
|
||||||
local die = function () destroy(notification) end
|
local die = function () destroy(notification) end
|
||||||
hooks.timer.register(timeout, die)
|
timer_die:add_signal("timeout", die)
|
||||||
|
timer_die:start()
|
||||||
notification.die = die
|
notification.die = die
|
||||||
|
notification.timer = timer_die
|
||||||
|
|
||||||
local run = function ()
|
local run = function ()
|
||||||
if args.run then
|
if args.run then
|
||||||
|
@ -307,7 +311,7 @@ function notify(args)
|
||||||
|
|
||||||
local hover_destroy = function ()
|
local hover_destroy = function ()
|
||||||
if hover_timeout == 0 then die()
|
if hover_timeout == 0 then die()
|
||||||
else hooks.timer.register(hover_timeout, die) end
|
else timer_die:stop() end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- create textbox
|
-- create textbox
|
||||||
|
|
Loading…
Reference in New Issue