From cd2e961fcb644287cdd899d8446894a207a355a7 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 13 Oct 2021 20:22:27 -0700 Subject: [PATCH 1/6] layoutlist: Remove the duplicate `buttons` property from doc. --- lib/awful/widget/layoutlist.lua | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/lib/awful/widget/layoutlist.lua b/lib/awful/widget/layoutlist.lua index 301724dc9..4d4f5946d 100644 --- a/lib/awful/widget/layoutlist.lua +++ b/lib/awful/widget/layoutlist.lua @@ -201,17 +201,6 @@ local layoutlist = {} -- @property filter -- @param[opt=awful.widget.layoutlist.source.for_screen] function ---- The layoutlist buttons. --- --- The default is: --- --- gears.table.join( --- awful.button({ }, 1, awful.layout.set) --- ) --- --- @property buttons --- @param table - --- The default foreground (text) color. -- @beautiful beautiful.layoutlist_fg_normal -- @tparam[opt=nil] string|pattern fg_normal From 9c042fcb79bb4fc52c8c536f50cc9d3235965361 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 13 Oct 2021 20:32:29 -0700 Subject: [PATCH 2/6] layoutlist: Fix an assert when `buttons` are specified. Fix #3388 --- lib/awful/widget/layoutlist.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/awful/widget/layoutlist.lua b/lib/awful/widget/layoutlist.lua index 4d4f5946d..9702a469a 100644 --- a/lib/awful/widget/layoutlist.lua +++ b/lib/awful/widget/layoutlist.lua @@ -297,7 +297,10 @@ end function layoutlist:set_buttons(buttons) self._private.buttons = buttons - update(self) + + if self._private.layout then + update(self) + end end function layoutlist:get_buttons() @@ -365,7 +368,6 @@ end -- function to generate the list of layouts. -- @tparam[opt] table args.widget_template A custom widget to be used for each action. -- @tparam[opt=ascreen.focused()] screen args.screen A screen --- @tparam[opt=nil] table args.buttons The list of `awful.buttons`. -- @tparam[opt={}] table args.style Extra look and feel parameters -- @tparam boolean args.style.disable_icon -- @tparam boolean args.style.disable_name From 1d5af8e8ad943fa8c030b44234f5cdc190d31259 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 13 Oct 2021 20:43:16 -0700 Subject: [PATCH 3/6] widget.common: Allow buttons to be replaced later. So far, they could only be set in the constructor. --- lib/awful/widget/common.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/awful/widget/common.lua b/lib/awful/widget/common.lua index 138a8c6bb..c45143fa4 100644 --- a/lib/awful/widget/common.lua +++ b/lib/awful/widget/common.lua @@ -125,6 +125,11 @@ function common.list_update(w, buttons, label, data, objects, args) for i, o in ipairs(objects) do local cache = data[o] + -- Allow the buttons to be replaced. + if cache and cache._buttons ~= buttons then + cache = nil + end + if not cache then cache = (args and args.widget_template) and custom_template(args) or default_template() @@ -139,6 +144,7 @@ function common.list_update(w, buttons, label, data, objects, args) args.create_callback(cache.primary, o, i, objects) end + cache._buttons = buttons data[o] = cache elseif cache.update_callback then cache.update_callback(cache.primary, o, i, objects) From 01020a197d1ab4c24c4811403564b465766d79f7 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 13 Oct 2021 20:51:56 -0700 Subject: [PATCH 4/6] layoutlist: Support scrollwheel by default. It acts like the default `rc.lua` tag/tasklist widgets. Idea from https://github.com/awesomeWM/awesome/issues/3388 --- lib/awful/widget/layoutlist.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/awful/widget/layoutlist.lua b/lib/awful/widget/layoutlist.lua index 9702a469a..122573374 100644 --- a/lib/awful/widget/layoutlist.lua +++ b/lib/awful/widget/layoutlist.lua @@ -36,9 +36,11 @@ local surface = require("gears.surface") local module = {} -local default_buttons = gtable.join( - abutton({ }, 1, function(a) a.callback() end) -) +local default_buttons = { + abutton({ }, 1, function(a) a.callback( ) end), + abutton({ }, 4, function() alayout.inc(-1) end), + abutton({ }, 5, function() alayout.inc( 1) end), +} local function wb_label(item, _, textbox) local selected = alayout.get(item.screen) == item.layout From 213bfbc9bdb5c78f43f66d65b4c6c1184bc81349 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 13 Oct 2021 20:56:55 -0700 Subject: [PATCH 5/6] doc: Fix a syntax issue in the layoutbox doc. --- lib/awful/widget/layoutlist.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/awful/widget/layoutlist.lua b/lib/awful/widget/layoutlist.lua index 122573374..a9c8ccaca 100644 --- a/lib/awful/widget/layoutlist.lua +++ b/lib/awful/widget/layoutlist.lua @@ -10,7 +10,7 @@ -- --@DOC_awful_widget_layoutlist_popup_EXAMPLE@ -- --- This example extends 'awful.widget.layoutbox' to show a layout list popup: +-- This example extends `awful.widget.layoutbox` to show a layout list popup: -- --@DOC_awful_widget_layoutlist_bar_EXAMPLE@ -- From 2a65d8ade12affb058bb90941e3f4829cce8ecc3 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 13 Oct 2021 21:18:22 -0700 Subject: [PATCH 6/6] tests: Fix the layoutlist popup example. `gears.table.cycle_value` returns 2 values. That accidentally passed the second one to `awful.layout.set`, which didn't like it at all. --- tests/examples/awful/widget/layoutlist/popup.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/examples/awful/widget/layoutlist/popup.lua b/tests/examples/awful/widget/layoutlist/popup.lua index 3aab72907..8eddca029 100644 --- a/tests/examples/awful/widget/layoutlist/popup.lua +++ b/tests/examples/awful/widget/layoutlist/popup.lua @@ -59,16 +59,18 @@ local modkey = "mod4" --DOC_HIDE start_callback = function() layout_popup.visible = true end, stop_callback = function() layout_popup.visible = false end, export_keybindings = true, - release_event = "release", + stop_event = "release", stop_key = {"Escape", "Super_L", "Super_R"}, keybindings = { {{ modkey } , " " , function() - awful.layout.set(gears.table.cycle_value(ll.layouts, ll.current_layout, 1)) + awful.layout.set((gears.table.cycle_value(ll.layouts, ll.current_layout, 1))) end}, {{ modkey, "Shift" } , " " , function() - awful.layout.set(gears.table.cycle_value(ll.layouts, ll.current_layout, -1), nil) + awful.layout.set((gears.table.cycle_value(ll.layouts, ll.current_layout, -1)), nil) end}, } } + layout_popup.visible = true --DOC_HIDE + --DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80