From 121a229492d0d4c47e128ddfbbe9897cb503e30f Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 18 Aug 2009 16:44:03 +0200 Subject: [PATCH] awful.tag: add attached_add_signal() Signed-off-by: Julien Danjou --- lib/awful/tag.lua.in | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/awful/tag.lua.in b/lib/awful/tag.lua.in index 2f06bc5a..30c9ceaf 100644 --- a/lib/awful/tag.lua.in +++ b/lib/awful/tag.lua.in @@ -284,6 +284,31 @@ function withcurrent(c, startup) end end +local function attached_add_signal_screen(screen, sig, func) + capi.screen[screen]:add_signal("tag::attach", function (s, tag) + tag:add_signal(sig, func) + end) + capi.screen[screen]:add_signal("tag::detach", function (s, tag) + tag:remove_signal(sig, func) + end) + for _, tag in ipairs(capi.screen[screen]:tags()) do + tag:add_signal(sig, func) + end +end + +--- Add a signal to all attached tag and all tag that will be attached in the +-- future. When a tag is detach from the screen, its signal is removed. +-- @param screen The screen concerned, or all if nil. +function attached_add_signal(screen, ...) + if screen then + attached_add_signal_screen(screen, ...) + else + for screen = 1, capi.screen.count() do + attached_add_signal_screen(screen, ...) + end + end +end + -- Register standards signals capi.client.add_signal("manage", withcurrent)