From 5d0fc566e996c59ebf917daf16afcec4ec31f41e Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 14 Feb 2015 20:37:30 +0100 Subject: [PATCH] awful.tooltip: add "delay_show" arg This will wrap the show and hide methods using gears.timeout. --- lib/awful/tooltip.lua.in | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/awful/tooltip.lua.in b/lib/awful/tooltip.lua.in index 341426fea..b84fc8ec5 100644 --- a/lib/awful/tooltip.lua.in +++ b/lib/awful/tooltip.lua.in @@ -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