taglist: call taglist_update only once per main loop

Currently `taglist_update` gets triggered often, because it listens to
a lot of signals.
This patch makes it only call the last one through `timer.delayed_call`.
This commit is contained in:
Daniel Hahler 2015-07-07 18:07:59 +02:00
parent 1924e044f7
commit 5630ad1bb2
1 changed files with 12 additions and 2 deletions

View File

@ -22,6 +22,7 @@ local tag = require("awful.tag")
local beautiful = require("beautiful")
local fixed = require("wibox.layout.fixed")
local surface = require("gears.surface")
local timer = require("gears.timer")
local taglist = { mt = {} }
taglist.filter = {}
@ -158,9 +159,18 @@ function taglist.new(screen, filter, buttons, style, update_function, base_widge
local w = base_widget or fixed.horizontal()
local data = setmetatable({}, { __mode = 'k' })
local queued_update = {}
local u = function (s)
if s == screen then
taglist_update(s, w, buttons, filter, data, style, uf)
if s ~= screen then return end
-- Add a delayed callback for the first update.
if not queued_update[s] then
timer.delayed_call(function()
taglist_update(s, w, buttons, filter, data, style, uf)
queued_update[s] = false
end)
queued_update[s] = true
end
end
local uc = function (c) return u(c.screen) end