From 5630ad1bb2fc8094e2670591cac48daedd0225d7 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Tue, 7 Jul 2015 18:07:59 +0200 Subject: [PATCH] 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`. --- lib/awful/widget/taglist.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/awful/widget/taglist.lua b/lib/awful/widget/taglist.lua index 6df04577d..4aed1caae 100644 --- a/lib/awful/widget/taglist.lua +++ b/lib/awful/widget/taglist.lua @@ -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