From 70c6821997701dc90982094058da10f7748d7293 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Tue, 9 Nov 2021 16:57:09 -0800 Subject: [PATCH] tasklist: Convert to a real widget. Previously, it was monkey-patching the input layout object. This will allow to replace the laoyut at runtime. For example, switching from `fixed.horizontal` to a grid when the number of client gets too large. --- lib/awful/widget/tasklist.lua | 40 ++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/lib/awful/widget/tasklist.lua b/lib/awful/widget/tasklist.lua index 1a4a646d1..41998c777 100644 --- a/lib/awful/widget/tasklist.lua +++ b/lib/awful/widget/tasklist.lua @@ -477,7 +477,7 @@ 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 function tasklist_update(s, self, buttons, filter, data, style, update_function, args) local clients = {} local source = self.source or tasklist.source.all_clients or nil @@ -493,8 +493,8 @@ local function tasklist_update(s, w, buttons, filter, data, style, update_functi local function label(c, tb) return tasklist_label(c, style, tb) end - update_function(w, buttons, label, data, clients, { - widget_template = args.widget_template or default_template, + update_function(self._private.base_layout, buttons, label, data, clients, { + widget_template = self._private.widget_template or default_template, create_callback = create_callback, }) end @@ -503,8 +503,42 @@ end -- -- @property base_layout -- @tparam[opt=wibox.layout.flex.horizontal] wibox.layout base_layout +-- @propemits true false -- @see wibox.layout.flex.horizontal +--- The tasklist screen. +-- +-- @property screen +-- @tparam screen screen +-- @propemits true false + +--- A function to narrow down the list of clients. +-- +-- @property filter +-- @tparam function filter +-- @propemits true false + +--- A function called when the tasklist is refreshed. +-- +-- This is a very low level API, prefer `widget_template` whenever +-- you can. +-- +-- @property update_function +-- @tparam function update_function +-- @propemits true false + +--- A template for creating the client widgets. +-- +-- @property widget_template +-- @tparam table widget_template +-- @propemits true false + +--- A function to gather the clients to display. +-- +-- @property source +-- @tparam function source +-- @propemits true false + function tasklist:set_base_layout(layout) self._private.base_layout = base.make_widget_from_value( layout or flex.horizontal