Merge pull request #137 from blueyed/fix-urgent-tags

awful.tag: fix call to update_urgent from client_untagged
This commit is contained in:
Emmanuel Lepage Vallée 2015-02-18 21:04:42 +00:00
commit e36b2549e7
1 changed files with 19 additions and 20 deletions

View File

@ -69,13 +69,13 @@ end
--- Swap 2 tags --- Swap 2 tags
-- @param tag1 The first tag -- @param tag1 The first tag
-- @param tag2 The second tag -- @param tag2 The second tag
function tag.swap(tag1,tag2) function tag.swap(tag1, tag2)
local idx1, idx2 = tag.getidx(tag1),tag.getidx(tag2) local idx1, idx2 = tag.getidx(tag1), tag.getidx(tag2)
local src2, src1 = tag.getscreen(tag2),tag.getscreen(tag1) local src2, src1 = tag.getscreen(tag2), tag.getscreen(tag1)
tag.setscreen(tag2,src1) tag.setscreen(tag2, src1)
tag.move(idx1,tag2) tag.move(idx1, tag2)
tag.setscreen(tag1,scr2) tag.setscreen(tag1, scr2)
tag.move(idx2,tag1) tag.move(idx2, tag1)
end end
--- Add a tag. --- Add a tag.
@ -191,7 +191,7 @@ function tag.delete(target_tag, fallback_tag)
target_tag.activated = false target_tag.activated = false
-- Update all indexes -- Update all indexes
for i=idx+1,#tags do for i=idx+1, #tags do
tag.setproperty(tags[i], "index", i-1) tag.setproperty(tags[i], "index", i-1)
end end
@ -318,7 +318,7 @@ function tag.setscreen(t, s)
end end
-- Update all indexes -- Update all indexes
for _,screen in ipairs {old_screen,s} do for _,screen in ipairs {old_screen, s} do
for i,t in ipairs(tag.gettags(screen)) do for i,t in ipairs(tag.gettags(screen)) do
tag.setproperty(t, "index", i) tag.setproperty(t, "index", i)
end end
@ -326,7 +326,7 @@ function tag.setscreen(t, s)
-- Restore the old screen history if the tag was selected -- Restore the old screen history if the tag was selected
if sel then if sel then
tag.history.restore(old_screen,1) tag.history.restore(old_screen, 1)
end end
end end
@ -633,32 +633,31 @@ capi.client.connect_signal("manage", function(c)
end) end)
-- Keep track of the number of urgent clients. -- Keep track of the number of urgent clients.
local function update_urgent(c,t) local function update_urgent(c, t, modif)
local modif = c.urgent == true and 1 or -1 local count = tag.getproperty(t, "urgent_count") or 0
local count = tag.getproperty(t,"urgent_count") or 0
count = (count + modif) >= 0 and (count + modif) or 0 count = (count + modif) >= 0 and (count + modif) or 0
tag.setproperty(t,"urgent" , count > 0) tag.setproperty(t, "urgent" , count > 0)
tag.setproperty(t,"urgent_count", count ) tag.setproperty(t, "urgent_count", count )
end end
-- Update the urgent counter when a client is tagged. -- Update the urgent counter when a client is tagged.
local function client_tagged(c,t) local function client_tagged(c, t)
if c.urgent then if c.urgent then
update_urgent(c,t) update_urgent(c, t, 1)
end end
end end
-- Update the urgent counter when a client is untagged. -- Update the urgent counter when a client is untagged.
local function client_untagged(c,t) local function client_untagged(c, t)
if c.urgent then if c.urgent then
update_urgent(c,t) update_urgent(c, t, -1)
end end
end end
-- Count the urgent clients. -- Count the urgent clients.
local function urgent_callback(c) local function urgent_callback(c)
for k,t in ipairs(c:tags()) do for k,t in ipairs(c:tags()) do
update_urgent(c,t) update_urgent(c, t, c.urgent and 1 or -1)
end end
end end