From 9166584b9647927034672e34e6aaab9c554bf604 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 28 Sep 2009 11:24:39 +0200 Subject: [PATCH] awful.tag: fix view{only,more} Now they do not select multiple tags at once, and they do not flicker. Signed-off-by: Julien Danjou --- lib/awful/tag.lua.in | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/awful/tag.lua.in b/lib/awful/tag.lua.in index aecd5861b..d3544cf13 100644 --- a/lib/awful/tag.lua.in +++ b/lib/awful/tag.lua.in @@ -252,10 +252,17 @@ end --- View only a tag. -- @param t The tag object. function viewonly(t) - local tags = capi.screen[t.screen or capi.mouse.screen]:tags() + local tags = capi.screen[t.screen]:tags() + -- First, untag everyone except the viewed tag. for _, tag in pairs(tags) do - tag.selected = (t == tag) + if tag ~= t then + tag.selected = false + end end + -- Then, set this one to selected. + -- We need to do that in 2 operations so we avoid flickering and several tag + -- selected at the same time. + t.selected = true capi.screen[t.screen]:emit_signal("tag::history::update") end @@ -264,8 +271,13 @@ end -- @param screen Optional screen number of the tags. function viewmore(tags, screen) local screen_tags = capi.screen[screen or capi.mouse.screen]:tags() - for _, tag in pairs(screen_tags) do - tag.selected = (util.table.hasitem(tags, tag) ~= nil) + for _, tag in ipairs(screen_tags) do + if not util.table.hasitem(tags, tag) then + tag.selected = false + end + end + for _, tag in ipairs(tags) do + tag.selected = true end capi.screen[screen]:emit_signal("tag::history::update") end