From 1924e044f7d941c738b260f462c122c930d44cf5 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Tue, 7 Jul 2015 18:07:59 +0200 Subject: [PATCH] tasklist: call tasklist_update only once per main loop Currently `tasklist_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/tasklist.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/awful/widget/tasklist.lua b/lib/awful/widget/tasklist.lua index 3c2e9fb7..9f9d19a0 100644 --- a/lib/awful/widget/tasklist.lua +++ b/lib/awful/widget/tasklist.lua @@ -19,6 +19,7 @@ local client = require("awful.client") local util = require("awful.util") local tag = require("awful.tag") local flex = require("wibox.layout.flex") +local timer = require("gears.timer") local tasklist = { mt = {} } @@ -146,7 +147,18 @@ function tasklist.new(screen, filter, buttons, style, update_function, base_widg local w = base_widget or flex.horizontal() local data = setmetatable({}, { __mode = 'k' }) - local u = function () tasklist_update(screen, w, buttons, filter, data, style, uf) end + + local queued_update = false + local u = function () + -- Add a delayed callback for the first update. + if not queued_update then + timer.delayed_call(function() + tasklist_update(screen, w, buttons, filter, data, style, uf) + queued_update = nil + end) + queued_update = true + end + end tag.attached_connect_signal(screen, "property::selected", u) tag.attached_connect_signal(screen, "property::activated", u) capi.client.connect_signal("property::urgent", u)