From 6880835c2603d5b2d0a6ac89cf5909dc112df5dc Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 29 Jul 2015 18:55:22 +0200 Subject: [PATCH] tooltip: delay_show: stop timer, handle (non-)stopped timers This splits the logic for `delay_show` out of `show`/`hide`, and handles an already stopped timer. The timer gets also stopped after the tooltip has been displayed. Ref: https://github.com/awesomeWM/awesome/issues/371. --- lib/awful/tooltip.lua | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/lib/awful/tooltip.lua b/lib/awful/tooltip.lua index 4eb6b589a..7b39d5e1e 100644 --- a/lib/awful/tooltip.lua +++ b/lib/awful/tooltip.lua @@ -202,21 +202,34 @@ tooltip.new = function(args) } -- private data - local delay_timeout if args.delay_show then + local delay_timeout + delay_timeout = timer { timeout = args.delay_show } - delay_timeout:connect_signal("timeout", function () show(self) end) + delay_timeout:connect_signal("timeout", function () + show(self) + delay_timeout:stop() + end) + + data[self] = { + show = function() + if not delay_timeout.started then + delay_timeout:start() + end + end, + hide = function() + if delay_timeout.started then + delay_timeout:stop() + end + hide(self) + end, + } + else + data[self] = { + show = function() show(self) end, + hide = function() hide(self) end, + } end - data[self] = { - 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 self.set_text = tooltip.set_text