From a081413339eaab5d6e4de4f6131181dee4db3cbf Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 6 Mar 2019 22:57:34 -0500 Subject: [PATCH] tasklist: Auto-call set_client on all template widgets This commit also update one of the example to remove its now redundant boilerplate code. --- lib/awful/widget/tasklist.lua | 6 ++++++ tests/examples/wibox/awidget/tasklist/windows10.lua | 8 +------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/awful/widget/tasklist.lua b/lib/awful/widget/tasklist.lua index d1141aa38..5fc7699c5 100644 --- a/lib/awful/widget/tasklist.lua +++ b/lib/awful/widget/tasklist.lua @@ -401,6 +401,11 @@ local function tasklist_label(c, args, tb) return text, bg, bg_image, not tasklist_disable_icon and c.icon or nil, other_args end +-- Remove some callback boilerplate from the user provided templates. +local function create_callback(w, t) + common._set_common_property(w, "client", t) +end + local function tasklist_update(s, w, buttons, filter, data, style, update_function, args) local clients = {} @@ -419,6 +424,7 @@ local function tasklist_update(s, w, buttons, filter, data, style, update_functi update_function(w, buttons, label, data, clients, { widget_template = args.widget_template, + create_callback = create_callback, }) end diff --git a/tests/examples/wibox/awidget/tasklist/windows10.lua b/tests/examples/wibox/awidget/tasklist/windows10.lua index 8ba40c9bf..8bf59c19b 100644 --- a/tests/examples/wibox/awidget/tasklist/windows10.lua +++ b/tests/examples/wibox/awidget/tasklist/windows10.lua @@ -52,17 +52,11 @@ end --DOC_HIDE widget = wibox.container.background, }, { - { - id = "clienticon", - widget = awful.widget.clienticon, - }, + awful.widget.clienticon, margins = 5, widget = wibox.container.margin }, nil, - create_callback = function(self, c, index, objects) --luacheck: no unused args - self:get_children_by_id("clienticon")[1].client = c - end, layout = wibox.layout.align.vertical, }, }