Merge pull request #123 from blueyed/tooltip-add-delay_show

awful.tooltip: add "delay_show" arg
This commit is contained in:
Daniel Hahler 2015-02-19 22:38:38 +01:00
commit 696f93f4d5
1 changed files with 15 additions and 2 deletions

View File

@ -164,6 +164,8 @@ end
-- @tparam function args.timer_function A function to dynamically change the
-- tooltip text.
-- @tparam table args.objects A list of objects linked to the tooltip.
-- @tparam number args.delay_show Delay showing the tooltip by this many
-- seconds.
-- @return The created tooltip.
-- @see add_to_object
-- @see set_timeout
@ -176,9 +178,20 @@ tooltip.new = function(args)
}
-- private data
local delay_timeout
if args.delay_show then
delay_timeout = timer { timeout = args.delay_show }
delay_timeout:connect_signal("timeout", function () show(self) end)
end
data[self] = {
show = function() show(self) end,
hide = function() hide(self) end
show = function()
if delay_timeout then delay_timeout:start()
else show(self) end
end,
hide = function()
if delay_timeout then delay_timeout:stop() end
hide(self)
end,
}
-- export functions