From 249f11ec821855a89cb74e3b8a2cb41b170b6982 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 26 Dec 2018 23:24:06 -0500 Subject: [PATCH 01/17] drawable: Add property getter/setter support. Just like the wibox and the other APIs --- lib/wibox/drawable.lua | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/lib/wibox/drawable.lua b/lib/wibox/drawable.lua index da231a6e3..b9a82c622 100644 --- a/lib/wibox/drawable.lua +++ b/lib/wibox/drawable.lua @@ -77,11 +77,11 @@ local function do_redraw(self) -- Relayout if self._need_relayout or self._need_complete_repaint then self._need_relayout = false - if self._widget_hierarchy and self.widget then + if self._widget_hierarchy and self._widget then local had_systray = systray_widget and self._widget_hierarchy:get_count(systray_widget) > 0 self._widget_hierarchy:update(context, - self.widget, width, height, self._dirty_area) + self._widget, width, height, self._dirty_area) local has_systray = systray_widget and self._widget_hierarchy:get_count(systray_widget) > 0 if had_systray and not has_systray then @@ -89,9 +89,9 @@ local function do_redraw(self) end else self._need_complete_repaint = true - if self.widget then + if self._widget then self._widget_hierarchy_callback_arg = {} - self._widget_hierarchy = hierarchy.new(context, self.widget, width, height, + self._widget_hierarchy = hierarchy.new(context, self._widget, width, height, self._redraw_callback, self._layout_callback, self._widget_hierarchy_callback_arg) else self._widget_hierarchy = nil @@ -226,13 +226,17 @@ end --- Set the widget that the drawable displays function drawable:set_widget(widget) - self.widget = widget + self._widget = widget -- Make sure the widget gets drawn self._need_relayout = true self.draw() end +function drawable:get_widget() + return rawget(self, "_widget") +end + --- Set the background of the drawable -- @param c The background to use. This must either be a cairo pattern object, -- nil or a string that gears.color() understands. @@ -480,7 +484,22 @@ function drawable.new(d, widget_context_skeleton, drawable_name) -- Make sure the drawable is drawn at least once ret._do_complete_repaint() - return ret + return setmetatable(ret, { + __index = function(self, k) + if rawget(self, "get_"..k) then + return rawget(self, "get_"..k)(self) + else + return rawget(ret, k) + end + end, + __newindex = function(self, k,v) + if rawget(self, "set_"..k) then + rawget(self, "set_"..k)(self, v) + else + rawset(self, k, v) + end + end + }) end -- Redraw all drawables when the wallpaper changes From 349b75994f7687fb2bc32b06dfe3c77efe1f8aeb Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 26 Dec 2018 23:34:17 -0500 Subject: [PATCH 02/17] titlebar/wibox: Support widget definition in set_widget. So now it is mostly identical to `:setup()` beside some legacy difference in how the get_children_by_id is implemented. --- lib/awful/titlebar.lua | 13 +++++++++++++ lib/wibox/drawable.lua | 3 ++- lib/wibox/init.lua | 4 +++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/awful/titlebar.lua b/lib/awful/titlebar.lua index 91edcf746..1b9ae4c4e 100644 --- a/lib/awful/titlebar.lua +++ b/lib/awful/titlebar.lua @@ -492,6 +492,18 @@ local function load_titlebars(c, hide_all, keep) return true end +local function get_children_by_id(self, name) + --TODO v5: Move the ID management to the hierarchy. + if self._drawable._widget + and self._drawable._widget._private + and self._drawable._widget._private.by_id then + return self._drawable.widget._private.by_id[name] + end + + return {} +end + + --- Get a client's titlebar. -- @tparam client c The client for which a titlebar is wanted. -- @tparam[opt={}] table args A table with extra arguments for the titlebar. @@ -556,6 +568,7 @@ local function new(c, args) -- Handle declarative/recursive widget container ret.setup = base.widget.setup + ret.get_children_by_id = get_children_by_id c._private = c._private or {} c._private.titlebars = bars diff --git a/lib/wibox/drawable.lua b/lib/wibox/drawable.lua index b9a82c622..f24832f3c 100644 --- a/lib/wibox/drawable.lua +++ b/lib/wibox/drawable.lua @@ -13,6 +13,7 @@ local capi = { screen = screen } local beautiful = require("beautiful") +local base = require("wibox.widget.base") local cairo = require("lgi").cairo local color = require("gears.color") local object = require("gears.object") @@ -226,7 +227,7 @@ end --- Set the widget that the drawable displays function drawable:set_widget(widget) - self._widget = widget + self._widget = base.make_widget_from_value(widget) -- Make sure the widget gets drawn self._need_relayout = true diff --git a/lib/wibox/init.lua b/lib/wibox/init.lua index 3f68d5cb4..1f4c7ff57 100644 --- a/lib/wibox/init.lua +++ b/lib/wibox/init.lua @@ -39,7 +39,8 @@ local force_forward = { --@DOC_wibox_COMMON@ function wibox:set_widget(widget) - self._drawable:set_widget(widget) + local w = base.make_widget_from_value(widget) + self._drawable:set_widget(w) end function wibox:get_widget() @@ -202,6 +203,7 @@ end function wibox:get_children_by_id(name) --TODO v5: Move the ID management to the hierarchy. if rawget(self, "_by_id") then + --TODO v5: Remove this, it's `if` nearly dead code, keep the `elseif` return rawget(self, "_by_id")[name] elseif self._drawable.widget and self._drawable.widget._private From 82db9180b10a1d54c7e9b84f8bf1b27a3b5a7cfb Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 26 Dec 2018 23:54:10 -0500 Subject: [PATCH 03/17] widget: Mutualize all set_widget implementation to behave the same Now always call both check_widget and make_widget_from_value. This should make it a lot less confusing when randomly trying to create a widget as all ways to do it slowly converge toward an unified one. --- lib/awful/widget/only_on_screen.lua | 8 +------- lib/wibox/container/arcchart.lua | 8 +------- lib/wibox/container/background.lua | 8 +------- lib/wibox/container/constraint.lua | 5 +---- lib/wibox/container/margin.lua | 8 +------- lib/wibox/container/mirror.lua | 8 +------- lib/wibox/container/place.lua | 12 +++++------- lib/wibox/container/radialprogressbar.lua | 8 +------- lib/wibox/container/rotate.lua | 8 +------- lib/wibox/container/scroll.lua | 10 +++++++--- lib/wibox/layout/fixed.lua | 5 +++-- lib/wibox/layout/grid.lua | 4 ++-- lib/wibox/layout/manual.lua | 13 ++++++++++--- lib/wibox/layout/ratio.lua | 5 +++-- lib/wibox/widget/base.lua | 18 ++++++++++++++++++ 15 files changed, 56 insertions(+), 72 deletions(-) diff --git a/lib/awful/widget/only_on_screen.lua b/lib/awful/widget/only_on_screen.lua index 37ce050df..b88ede6f6 100644 --- a/lib/awful/widget/only_on_screen.lua +++ b/lib/awful/widget/only_on_screen.lua @@ -51,13 +51,7 @@ end -- @property widget -- @tparam widget widget The widget -function only_on_screen:set_widget(widget) - if widget then - base.check_widget(widget) - end - self._private.widget = widget - self:emit_signal("widget::layout_changed") -end +only_on_screen.set_widget = base.set_widget_common function only_on_screen:get_widget() return self._private.widget diff --git a/lib/wibox/container/arcchart.lua b/lib/wibox/container/arcchart.lua index 2c5a0551c..73653c44a 100644 --- a/lib/wibox/container/arcchart.lua +++ b/lib/wibox/container/arcchart.lua @@ -192,13 +192,7 @@ end -- @property widget -- @tparam widget widget The widget -function arcchart:set_widget(widget) - if widget then - base.check_widget(widget) - end - self._private.widget = widget - self:emit_signal("widget::layout_changed") -end +arcchart.set_widget = base.set_widget_common function arcchart:get_children() return {self._private.widget} diff --git a/lib/wibox/container/background.lua b/lib/wibox/container/background.lua index b1941b4eb..de0cb2ef3 100644 --- a/lib/wibox/container/background.lua +++ b/lib/wibox/container/background.lua @@ -218,13 +218,7 @@ end -- @tparam widget widget The widget to be disaplayed inside of the background -- area -function background:set_widget(widget) - if widget then - base.check_widget(widget) - end - self._private.widget = widget - self:emit_signal("widget::layout_changed") -end +background.set_widget = base.set_widget_common function background:get_widget() return self._private.widget diff --git a/lib/wibox/container/constraint.lua b/lib/wibox/container/constraint.lua index 756ddb03b..7ebda4d25 100644 --- a/lib/wibox/container/constraint.lua +++ b/lib/wibox/container/constraint.lua @@ -42,10 +42,7 @@ end -- @property widget -- @tparam widget widget The widget -function constraint:set_widget(widget) - self._private.widget = widget - self:emit_signal("widget::layout_changed") -end +constraint.set_widget = base.set_widget_common function constraint:get_widget() return self._private.widget diff --git a/lib/wibox/container/margin.lua b/lib/wibox/container/margin.lua index 715552376..e21cb7fa8 100644 --- a/lib/wibox/container/margin.lua +++ b/lib/wibox/container/margin.lua @@ -73,13 +73,7 @@ end -- @property widget -- @tparam widget widget The widget -function margin:set_widget(widget) - if widget then - base.check_widget(widget) - end - self._private.widget = widget - self:emit_signal("widget::layout_changed") -end +margin.set_widget = base.set_widget_common function margin:get_widget() return self._private.widget diff --git a/lib/wibox/container/mirror.lua b/lib/wibox/container/mirror.lua index fa86ec867..0e50b9d97 100644 --- a/lib/wibox/container/mirror.lua +++ b/lib/wibox/container/mirror.lua @@ -49,13 +49,7 @@ end -- @property widget -- @tparam widget widget The widget -function mirror:set_widget(widget) - if widget then - base.check_widget(widget) - end - self._private.widget = widget - self:emit_signal("widget::layout_changed") -end +mirror.set_widget = base.set_widget_common function mirror:get_widget() return self._private.widget diff --git a/lib/wibox/container/place.lua b/lib/wibox/container/place.lua index fca974191..1eaab15e2 100644 --- a/lib/wibox/container/place.lua +++ b/lib/wibox/container/place.lua @@ -61,13 +61,11 @@ function place:fit(context, width, height) and height or h end -function place:set_widget(widget) - if widget then - base.check_widget(widget) - end - self._private.widget = widget - self:emit_signal("widget::layout_changed") -end +--- The widget to be placed. +-- @property widget +-- @tparam widget widget The widget + +place.set_widget = base.set_widget_common function place:get_widget() return self._private.widget diff --git a/lib/wibox/container/radialprogressbar.lua b/lib/wibox/container/radialprogressbar.lua index b7bfa055f..47eefc679 100644 --- a/lib/wibox/container/radialprogressbar.lua +++ b/lib/wibox/container/radialprogressbar.lua @@ -129,13 +129,7 @@ end -- @property widget -- @tparam widget widget The widget -function radialprogressbar:set_widget(widget) - if widget then - base.check_widget(widget) - end - self._private.widget = widget - self:emit_signal("widget::layout_changed") -end +radialprogressbar.set_widget = base.set_widget_common function radialprogressbar:get_children() return {self._private.widget} diff --git a/lib/wibox/container/rotate.lua b/lib/wibox/container/rotate.lua index 5a3f784cd..43ace693f 100644 --- a/lib/wibox/container/rotate.lua +++ b/lib/wibox/container/rotate.lua @@ -62,13 +62,7 @@ end -- @property widget -- @tparam widget widget The widget -function rotate:set_widget(widget) - if widget then - base.check_widget(widget) - end - self._private.widget = widget - self:emit_signal("widget::layout_changed") -end +rotate.set_widget = base.set_widget_common function rotate:get_widget() return self._private.widget diff --git a/lib/wibox/container/scroll.lua b/lib/wibox/container/scroll.lua index 06413078f..cb1bf4397 100644 --- a/lib/wibox/container/scroll.lua +++ b/lib/wibox/container/scroll.lua @@ -277,10 +277,14 @@ function scroll:set_widget(widget) if widget == self._private.widget then return end - if widget then - base.check_widget(widget) + + local w = base.make_widget_from_value(widget) + + if w then + base.check_widget(w) end - self._private.widget = widget + + self._private.widget = w self:emit_signal("widget::layout_changed") self:emit_signal("widget::redraw_needed") end diff --git a/lib/wibox/layout/fixed.lua b/lib/wibox/layout/fixed.lua index c9d2e74ce..33551a053 100644 --- a/lib/wibox/layout/fixed.lua +++ b/lib/wibox/layout/fixed.lua @@ -70,8 +70,9 @@ function fixed:add(...) local args = { n=select('#', ...), ... } assert(args.n > 0, "need at least one widget to add") for i=1, args.n do - base.check_widget(args[i]) - table.insert(self._private.widgets, args[i]) + local w = base.make_widget_from_value(args[i]) + base.check_widget(w) + table.insert(self._private.widgets, w) end self:emit_signal("widget::layout_changed") end diff --git a/lib/wibox/layout/grid.lua b/lib/wibox/layout/grid.lua index 1322a6e9e..4675717b6 100644 --- a/lib/wibox/layout/grid.lua +++ b/lib/wibox/layout/grid.lua @@ -293,10 +293,9 @@ function grid:add(...) assert(args.n > 0, "need at least one widget to add") local row, column for i=1, args.n do - local w = args[i] -- Get the next empty coordinate to insert the widget row, column = self:get_next_empty(row, column) - self:add_widget_at(w, row, column, 1, 1) + self:add_widget_at(args[i], row, column, 1, 1) end end @@ -317,6 +316,7 @@ function grid:add_widget_at(child, row, col, row_span, col_span) col_span = (col_span and col_span > 0) and col_span or 1 -- check if the object is a widget + child = base.make_widget_from_value(child) base.check_widget(child) -- test if the new widget superpose with existing ones diff --git a/lib/wibox/layout/manual.lua b/lib/wibox/layout/manual.lua index d263141b2..03f8c61a4 100644 --- a/lib/wibox/layout/manual.lua +++ b/lib/wibox/layout/manual.lua @@ -102,9 +102,16 @@ function manual_layout:layout(context, width, height) end function manual_layout:add(...) - local wdgs = {...} + local wdgs = {} local old_count = #self._private.widgets - gtable.merge(self._private.widgets, {...}) + + for _, v in ipairs {...} do + local w = base.make_widget_from_value(v) + base.check_widget(w) + table.insert(wdgs, w) + end + + gtable.merge(self._private.widgets, wdgs) -- Add the points for k, v in ipairs(wdgs) do @@ -166,7 +173,7 @@ function manual_layout:add_at(widget, point) end self._private.pos[#self._private.widgets+1] = point - self:add(widget) + self:add(base.make_widget_from_value(widget)) end --- Move a widget (by index). diff --git a/lib/wibox/layout/ratio.lua b/lib/wibox/layout/ratio.lua index 0e8f18ac6..63550aca3 100644 --- a/lib/wibox/layout/ratio.lua +++ b/lib/wibox/layout/ratio.lua @@ -355,8 +355,9 @@ function ratio:add(...) local args = { n=select('#', ...), ... } assert(args.n > 0, "need at least one widget to add") for i=1, args.n do - base.check_widget(args[i]) - table.insert(self._private.widgets, args[i]) + local w = base.make_widget_from_value(args[i]) + base.check_widget(w) + table.insert(self._private.widgets, w) end normalize(self) diff --git a/lib/wibox/widget/base.lua b/lib/wibox/widget/base.lua index bf4b87f8c..9587c4094 100644 --- a/lib/wibox/widget/base.lua +++ b/lib/wibox/widget/base.lua @@ -155,6 +155,24 @@ function base.widget:get_all_children() return ret end +--- Common implementation of the `:set_widget()` method exposed by many +-- other widgets. +-- +-- Use this if your widget has no custom logic when setting the widget. +-- +-- @usage +-- rawset(my_custom_widget, "set_widget", wibox.widget.base.set_widget_common) +function base.set_widget_common(self, widget) + local w = widget and base.make_widget_from_value(widget) + + if w then + base.check_widget(w) + end + + self._private.widget = w + self:emit_signal("widget::layout_changed") +end + --- Emit a signal and ensure all parent widgets in the hierarchies also -- forward the signal. This is useful to track signals when there is a dynamic -- set of containers and layouts wrapping the widget. From 56b242906de1647e9e9f83b3317d05e9fa445f01 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 26 Dec 2018 21:21:49 -0500 Subject: [PATCH 04/17] rc.lua: Use the buttons property instead of method for the tag/tasklist Begin to bring consistency to these ancient components. --- awesomerc.lua | 75 ++++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/awesomerc.lua b/awesomerc.lua index db05f7da6..e7d5e30e4 100644 --- a/awesomerc.lua +++ b/awesomerc.lua @@ -104,45 +104,46 @@ mytextclock = wibox.widget.textclock() -- Create a wibox for each screen and add it -- @TAGLIST_BUTTON@ -local taglist_buttons = gears.table.join( - awful.button({ }, 1, function(t) t:view_only() end), - awful.button({ modkey }, 1, function(t) - if client.focus then - client.focus:move_to_tag(t) - end - end), - awful.button({ }, 3, awful.tag.viewtoggle), - awful.button({ modkey }, 3, function(t) - if client.focus then - client.focus:toggle_tag(t) - end - end), - awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end), - awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end) - ) +local taglist_buttons = { + awful.button({ }, 1, function(t) t:view_only() end), + awful.button({ modkey }, 1, function(t) + if client.focus then + client.focus:move_to_tag(t) + end + end), + awful.button({ }, 3, awful.tag.viewtoggle), + awful.button({ modkey }, 3, function(t) + if client.focus then + client.focus:toggle_tag(t) + end + end), + awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end), + awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end), +} -- @TASKLIST_BUTTON@ -local tasklist_buttons = gears.table.join( - awful.button({ }, 1, function (c) - if c == client.focus then - c.minimized = true - else - c:emit_signal( - "request::activate", - "tasklist", - {raise = true} - ) - end - end), - awful.button({ }, 3, function() - awful.menu.client_list({ theme = { width = 250 } }) - end), - awful.button({ }, 4, function () - awful.client.focus.byidx(1) - end), - awful.button({ }, 5, function () - awful.client.focus.byidx(-1) - end)) +local tasklist_buttons = { + awful.button({ }, 1, function (c) + if c == client.focus then + c.minimized = true + else + c:emit_signal( + "request::activate", + "tasklist", + {raise = true} + ) + end + end), + awful.button({ }, 3, function() + awful.menu.client_list({ theme = { width = 250 } }) + end), + awful.button({ }, 4, function () + awful.client.focus.byidx(1) + end), + awful.button({ }, 5, function () + awful.client.focus.byidx(-1) + end), +} -- @DOC_WALLPAPER@ screen.connect_signal("request::wallpaper", function(s) From 8eda69adbed0983348f401e7d7c8e7fc1c95f0c0 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 26 Dec 2018 21:24:55 -0500 Subject: [PATCH 05/17] rc.lua: Use the modern layoutbox constructor --- awesomerc.lua | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/awesomerc.lua b/awesomerc.lua index e7d5e30e4..df6ff8318 100644 --- a/awesomerc.lua +++ b/awesomerc.lua @@ -167,12 +167,16 @@ screen.connect_signal("request::desktop_decoration", function(s) s.mypromptbox = awful.widget.prompt() -- Create an imagebox widget which will contain an icon indicating which layout we're using. -- We need one layoutbox per screen. - s.mylayoutbox = awful.widget.layoutbox(s) - s.mylayoutbox:buttons(gears.table.join( - awful.button({ }, 1, function () awful.layout.inc( 1) end), - awful.button({ }, 3, function () awful.layout.inc(-1) end), - awful.button({ }, 4, function () awful.layout.inc( 1) end), - awful.button({ }, 5, function () awful.layout.inc(-1) end))) + s.mylayoutbox = awful.widget.layoutbox { + screen = s, + buttons = { + awful.button({ }, 1, function () awful.layout.inc( 1) end), + awful.button({ }, 3, function () awful.layout.inc(-1) end), + awful.button({ }, 4, function () awful.layout.inc( 1) end), + awful.button({ }, 5, function () awful.layout.inc(-1) end), + } + } + -- Create a taglist widget s.mytaglist = awful.widget.taglist { screen = s, From 951b774a702f6a3e79be9d62586acdb58c0af8b0 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 26 Dec 2018 21:49:56 -0500 Subject: [PATCH 06/17] rc.lua: Use the new API for root.buttons --- awesomerc.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/awesomerc.lua b/awesomerc.lua index df6ff8318..037e44568 100644 --- a/awesomerc.lua +++ b/awesomerc.lua @@ -219,11 +219,11 @@ end) -- {{{ Mouse bindings -- @DOC_ROOT_BUTTONS@ -root.buttons(gears.table.join( +root.buttons = { awful.button({ }, 3, function () mymainmenu:toggle() end), awful.button({ }, 4, awful.tag.viewnext), - awful.button({ }, 5, awful.tag.viewprev) -)) + awful.button({ }, 5, awful.tag.viewprev), +} -- }}} -- {{{ Key bindings From 5f829171c47f9b264ebdffa3c4415506c4eaf442 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 26 Dec 2018 21:51:22 -0500 Subject: [PATCH 07/17] rc.lua: Use the new API for the client buttons --- awesomerc.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/awesomerc.lua b/awesomerc.lua index 037e44568..886cdd363 100644 --- a/awesomerc.lua +++ b/awesomerc.lua @@ -426,7 +426,7 @@ for i = 1, 9 do end -- @DOC_CLIENT_BUTTONS@ -clientbuttons = gears.table.join( +clientbuttons = { awful.button({ }, 1, function (c) c:emit_signal("request::activate", "mouse_click", {raise = true}) end), @@ -437,8 +437,8 @@ clientbuttons = gears.table.join( awful.button({ modkey }, 3, function (c) c:emit_signal("request::activate", "mouse_click", {raise = true}) awful.mouse.client.resize(c) - end) -) + end), +} -- Set keys root.keys(globalkeys) From 4617365ee2458e59fc9a0c0deba906d90655ecb0 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 26 Dec 2018 21:52:09 -0500 Subject: [PATCH 08/17] rc.lua: Use the new client API for the titlebar buttons. --- awesomerc.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/awesomerc.lua b/awesomerc.lua index 886cdd363..d71e6d310 100644 --- a/awesomerc.lua +++ b/awesomerc.lua @@ -527,7 +527,7 @@ end) -- Add a titlebar if titlebars_enabled is set to true in the rules. client.connect_signal("request::titlebars", function(c) -- buttons for the titlebar - local buttons = gears.table.join( + local buttons = { awful.button({ }, 1, function() c:emit_signal("request::activate", "titlebar", {raise = true}) awful.mouse.client.move(c) @@ -535,8 +535,8 @@ client.connect_signal("request::titlebars", function(c) awful.button({ }, 3, function() c:emit_signal("request::activate", "titlebar", {raise = true}) awful.mouse.client.resize(c) - end) - ) + end), + } awful.titlebar(c) : setup { { -- Left From 965d7c1b47fcd4519d09f46319846b56fe735ca9 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 26 Dec 2018 22:01:05 -0500 Subject: [PATCH 09/17] rc.lua: Use the new API to set the client keys --- awesomerc.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/awesomerc.lua b/awesomerc.lua index d71e6d310..918318bf4 100644 --- a/awesomerc.lua +++ b/awesomerc.lua @@ -330,7 +330,7 @@ globalkeys = gears.table.join( ) -- @DOC_CLIENT_KEYBINDINGS@ -clientkeys = gears.table.join( +clientkeys = { awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen @@ -371,8 +371,8 @@ clientkeys = gears.table.join( c.maximized_horizontal = not c.maximized_horizontal c:raise() end , - {description = "(un)maximize horizontally", group = "client"}) -) + {description = "(un)maximize horizontally", group = "client"}), +} -- @DOC_NUMBER_KEYBINDINGS@ -- Bind all key numbers to tags. From 48ac59c0b6b730524265abb4b240f4aa6b8a8e26 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 26 Dec 2018 22:51:35 -0500 Subject: [PATCH 10/17] rc.lua: Use the new keys API for the global keys. --- awesomerc.lua | 99 +++++++++++++++++++++++++++------------------------ 1 file changed, 52 insertions(+), 47 deletions(-) diff --git a/awesomerc.lua b/awesomerc.lua index 918318bf4..4b0ad9b61 100644 --- a/awesomerc.lua +++ b/awesomerc.lua @@ -228,7 +228,7 @@ root.buttons = { -- {{{ Key bindings -- @DOC_GLOBAL_KEYBINDINGS@ -globalkeys = gears.table.join( +globalkeys = { awful.key({ modkey, }, "s", hotkeys_popup.show_help, {description="show help", group="awesome"}), awful.key({ modkey, }, "Left", awful.tag.viewprev, @@ -326,8 +326,8 @@ globalkeys = gears.table.join( {description = "lua execute prompt", group = "awesome"}), -- Menubar awful.key({ modkey }, "p", function() menubar.show() end, - {description = "show the menubar", group = "launcher"}) -) + {description = "show the menubar", group = "launcher"}), +} -- @DOC_CLIENT_KEYBINDINGS@ clientkeys = { @@ -379,49 +379,54 @@ clientkeys = { -- Be careful: we use keycodes to make it work on any keyboard layout. -- This should map on the top row of your keyboard, usually 1 to 9. for i = 1, 9 do - globalkeys = gears.table.join(globalkeys, - -- View tag only. - awful.key({ modkey }, "#" .. i + 9, - function () - local screen = awful.screen.focused() - local tag = screen.tags[i] - if tag then - tag:view_only() - end - end, - {description = "view tag #"..i, group = "tag"}), - -- Toggle tag display. - awful.key({ modkey, "Control" }, "#" .. i + 9, - function () - local screen = awful.screen.focused() - local tag = screen.tags[i] - if tag then - awful.tag.viewtoggle(tag) - end - end, - {description = "toggle tag #" .. i, group = "tag"}), - -- Move client to tag. - awful.key({ modkey, "Shift" }, "#" .. i + 9, - function () - if client.focus then - local tag = client.focus.screen.tags[i] - if tag then - client.focus:move_to_tag(tag) - end - end - end, - {description = "move focused client to tag #"..i, group = "tag"}), - -- Toggle tag on focused client. - awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, - function () - if client.focus then - local tag = client.focus.screen.tags[i] - if tag then - client.focus:toggle_tag(tag) - end - end - end, - {description = "toggle focused client on tag #" .. i, group = "tag"}) + -- View tag only. + table.insert(globalkeys, awful.key({ modkey }, "#" .. i + 9, + function () + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + tag:view_only() + end + end, + {description = "view tag #"..i, group = "tag"}) + ) + + -- Toggle tag display. + table.insert(globalkeys, awful.key({ modkey, "Control" }, "#" .. i + 9, + function () + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + awful.tag.viewtoggle(tag) + end + end, + {description = "toggle tag #" .. i, group = "tag"}) + ) + + -- Move client to tag. + table.insert(globalkeys, awful.key({ modkey, "Shift" }, "#" .. i + 9, + function () + if client.focus then + local tag = client.focus.screen.tags[i] + if tag then + client.focus:move_to_tag(tag) + end + end + end, + {description = "move focused client to tag #"..i, group = "tag"}) + ) + + -- Toggle tag on focused client. + table.insert(globalkeys, awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, + function () + if client.focus then + local tag = client.focus.screen.tags[i] + if tag then + client.focus:toggle_tag(tag) + end + end + end, + {description = "toggle focused client on tag #" .. i, group = "tag"}) ) end @@ -441,7 +446,7 @@ clientbuttons = { } -- Set keys -root.keys(globalkeys) +root.keys = globalkeys -- }}} -- {{{ Rules From f4a0e1fc391e102b4fd63d50b34f769b63dfda76 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 26 Dec 2018 23:33:05 -0500 Subject: [PATCH 11/17] rc.lua: Use `.widget =` instead of `:setup()`. More work on the property vs. r/w methods standardization. --- awesomerc.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/awesomerc.lua b/awesomerc.lua index 4b0ad9b61..f7bc68c1e 100644 --- a/awesomerc.lua +++ b/awesomerc.lua @@ -197,7 +197,7 @@ screen.connect_signal("request::desktop_decoration", function(s) -- @DOC_SETUP_WIDGETS@ -- Add widgets to the wibox - s.mywibox:setup { + s.mywibox.widget = { layout = wibox.layout.align.horizontal, { -- Left widgets layout = wibox.layout.fixed.horizontal, @@ -543,7 +543,7 @@ client.connect_signal("request::titlebars", function(c) end), } - awful.titlebar(c) : setup { + awful.titlebar(c).widget = { { -- Left awful.titlebar.widget.iconwidget(c), buttons = buttons, From b23a2e81c57018b61bce8592087a7aff8e8d6bc2 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Fri, 28 Dec 2018 02:19:26 -0500 Subject: [PATCH 12/17] tests: Stop using the legacy layoutbox constructor. (done in a commit so the CI can test some commits with the old constructor) --- tests/_wibox_helper.lua | 2 +- tests/test-leaks.lua | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/_wibox_helper.lua b/tests/_wibox_helper.lua index d60ad7f8c..9b1a31b64 100644 --- a/tests/_wibox_helper.lua +++ b/tests/_wibox_helper.lua @@ -18,7 +18,7 @@ return { create_wibox = function() local right_layout = wibox.layout.fixed.horizontal() local textclock = wibox.widget.textclock() right_layout:add(textclock) - right_layout:add(awful.widget.layoutbox(1)) + right_layout:add(awful.widget.layoutbox{screen=1}) -- Now bring it all together (with the tasklist in the middle) local layout = wibox.layout.align.horizontal() diff --git a/tests/test-leaks.lua b/tests/test-leaks.lua index fa185575b..8a2357601 100644 --- a/tests/test-leaks.lua +++ b/tests/test-leaks.lua @@ -41,7 +41,7 @@ end -- Use the layoutbox for testing delayed tooltips local function tooltip_delayed() - local l = awful.widget.layoutbox(1) + local l = awful.widget.layoutbox{screen = 1} local t = l._layoutbox_tooltip assert(t) return l, t @@ -63,7 +63,7 @@ collectable(wibox.layout.align.horizontal()) collectable(awful.widget.launcher({ image = cairo.ImageSurface(cairo.Format.ARGB32, 20, 20), command = "bash" })) collectable(awful.widget.prompt()) collectable(wibox.widget.textclock()) -collectable(awful.widget.layoutbox(1)) +collectable(awful.widget.layoutbox{screen=1}) -- Some widgets do things via timer.delayed_call prepare_for_collect = run_delayed_calls From 57f38f48249ecb1a042c6418bdd5792e7e2da0c8 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Fri, 28 Dec 2018 02:20:26 -0500 Subject: [PATCH 13/17] layoutbox: Deprecate the old constructor --- lib/awful/widget/layoutbox.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/awful/widget/layoutbox.lua b/lib/awful/widget/layoutbox.lua index 07b12d629..b2be8684c 100644 --- a/lib/awful/widget/layoutbox.lua +++ b/lib/awful/widget/layoutbox.lua @@ -14,7 +14,7 @@ local tooltip = require("awful.tooltip") local beautiful = require("beautiful") local wibox = require("wibox") local surface = require("gears.surface") --- local gdebug = require("gears.debug") +local gdebug = require("gears.debug") local gtable = require("gears.table") local function get_screen(s) @@ -55,11 +55,11 @@ function layoutbox.new(args) if type(args) == "number" or type(args) == "screen" or args.fake_remove then screen, args = args, {} ---TODO uncomment --- gdebug.deprecate( --- "Use awful.widget.layoutbox{screen=s} instead of awful.widget.layoutbox(screen)", --- {deprecated_in=5} --- ) + + gdebug.deprecate( + "Use awful.widget.layoutbox{screen=s} instead of awful.widget.layoutbox(screen)", + {deprecated_in=5} + ) end assert(type(args) == "table") From cf0385af80a68d4f7a045a1842de699935161921 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Fri, 28 Dec 2018 02:56:09 -0500 Subject: [PATCH 14/17] widget: Add an `:add_button()` method. This is done now because a lot of code in `lib/` add buttons by manually extracting buttons from awful.button. Instead of adding ugly code to prevent using the legacy API, do this. --- docs/common/widget.ldoc | 4 ++++ lib/wibox/widget/base.lua | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/docs/common/widget.ldoc b/docs/common/widget.ldoc index acd6bc7c8..6bea9a920 100644 --- a/docs/common/widget.ldoc +++ b/docs/common/widget.ldoc @@ -48,6 +48,10 @@ -- @param table -- @see awful.button +--- Add a new `awful.button` to this widget. +-- @tparam awful.button button The button to add. +-- @function add_button + --- Emit a signal and ensure all parent widgets in the hierarchies also -- forward the signal. This is useful to track signals when there is a dynamic -- set of containers and layouts wrapping the widget. diff --git a/lib/wibox/widget/base.lua b/lib/wibox/widget/base.lua index 9587c4094..853ec6dac 100644 --- a/lib/wibox/widget/base.lua +++ b/lib/wibox/widget/base.lua @@ -40,6 +40,29 @@ function base.widget:set_visible(b) end end +--- Add a new `awful.button` to this widget. +-- @tparam awful.button button The button to add. +function base.widget:add_button(button) + if not button then return end + + -- Simple case + if not self._private.buttons then + self:set_buttons({button}) + return + end + + -- This could happen if something accidentally uses rawset + assert(self._private.buttons_formatted) + + -- an `awful.button` is a tupple of `capi.button` + self._private.buttons_formatted = gtable.join( + self._private.buttons_formatted, + button + ) + + table.insert(self._private.buttons, button) +end + --- Is the widget visible? -- @treturn boolean -- @method get_visible From ab1e62a3322f86afd7a545d5baf606930c793bd1 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 6 Oct 2019 03:04:51 -0400 Subject: [PATCH 15/17] Remove the instances of :buttons(awful.button()). Having buttons without an awful.util.table.join/gears.table.join has never been officially documented to be supported. I hope there isn't too many of those and they wont try to mix the new and old API syntax, because that will totally break. --- lib/awful/titlebar.lua | 22 +++++++++++++--------- lib/awful/tooltip.lua | 4 +++- lib/awful/widget/button.lua | 7 +++++-- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/lib/awful/titlebar.lua b/lib/awful/titlebar.lua index 1b9ae4c4e..57bc3b011 100644 --- a/lib/awful/titlebar.lua +++ b/lib/awful/titlebar.lua @@ -730,16 +730,20 @@ function titlebar.widget.button(c, name, selector, action) end ret.state = "" if action then - ret:buttons(abutton({ }, 1, nil, function() - ret.state = "" - update() - action(c, selector(c)) - end)) + ret.buttons = { + abutton({ }, 1, nil, function() + ret.state = "" + update() + action(c, selector(c)) + end) + } else - ret:buttons(abutton({ }, 1, nil, function() - ret.state = "" - update() - end)) + ret.buttons = { + abutton({ }, 1, nil, function() + ret.state = "" + update() + end) + } end ret:connect_signal("mouse::enter", function() ret.state = "hover" diff --git a/lib/awful/tooltip.lua b/lib/awful/tooltip.lua index 190e7768b..fc6bd52d9 100644 --- a/lib/awful/tooltip.lua +++ b/lib/awful/tooltip.lua @@ -212,7 +212,9 @@ function tooltip:get_wibox() -- Close the tooltip when clicking it. This gets done on release, to not -- emit the release event on an underlying object, e.g. the titlebar icon. - wb:buttons(a_button({}, 1, nil, self.hide)) + wb.buttons = { + a_button({}, 1, nil, self.hide) + } self._private.wibox = wb diff --git a/lib/awful/widget/button.lua b/lib/awful/widget/button.lua index 4a4b398b7..c71bab851 100644 --- a/lib/awful/widget/button.lua +++ b/lib/awful/widget/button.lua @@ -46,8 +46,11 @@ function button.new(args) orig_set_image(self, img_release) end w:set_image(args.image) - w:buttons(abutton({}, 1, function () orig_set_image(w, img_press) end, - function () orig_set_image(w, img_release) end)) + + w.buttons = { + abutton({}, 1, function () orig_set_image(w, img_press) end, + function () orig_set_image(w, img_release) end) + } w:connect_signal("mouse::leave", function(self) orig_set_image(self, img_release) end) From fa414a86a31d6adb378e52c82e006d81cc95c94e Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Fri, 28 Dec 2018 03:04:42 -0500 Subject: [PATCH 16/17] tests: Test `widget:add_button()` --- tests/test-awful-widget-button.lua | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/test-awful-widget-button.lua b/tests/test-awful-widget-button.lua index 09c608ded..df1a6333c 100644 --- a/tests/test-awful-widget-button.lua +++ b/tests/test-awful-widget-button.lua @@ -2,7 +2,7 @@ local runner = require( "_runner" ) local wibox = require( "wibox" ) local awful = require( "awful" ) local beautiful = require( "beautiful" ) -local gtable = require("gears.table") +local gdebug = require("gears.debug") local steps = {} @@ -64,12 +64,20 @@ table.insert(steps, function() layout = w.widget assert(layout) - button:buttons(gtable.join( - button:buttons(), + -- Test both legacy and new APIs + gdebug.deprecate = function() end + + assert(#button:buttons() == 4) + assert(#button.buttons == 1) + + button:add_button( awful.button({}, 1, nil, function () button:emit_signal_recursive("test::recursive") end) - )) + ) + + assert(#button:buttons() == 8) + assert(#button.buttons == 2) layout:connect_signal("test::recursive", function() got_called = true From 2c08c2fa396d3522041c2f15365c508f00340810 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Fri, 28 Dec 2018 03:06:03 -0500 Subject: [PATCH 17/17] quality: Port all legacy `:buttons()` to `.buttons`. --- lib/awful/hotkeys_popup/widget.lua | 9 +++++---- lib/awful/menu.lua | 5 +++-- lib/awful/widget/button.lua | 14 ++++++------- lib/awful/widget/calendar_popup.lua | 31 ++++++++++++++++------------- lib/awful/widget/common.lua | 2 +- lib/awful/widget/keyboardlayout.lua | 7 +++---- lib/awful/widget/launcher.lua | 7 ++----- lib/naughty/layout/legacy.lua | 24 ++++++++++------------ tests/test-leak-client.lua | 16 +++++++-------- 9 files changed, 57 insertions(+), 58 deletions(-) diff --git a/lib/awful/hotkeys_popup/widget.lua b/lib/awful/hotkeys_popup/widget.lua index a3aeab256..3fc82ce37 100644 --- a/lib/awful/hotkeys_popup/widget.lua +++ b/lib/awful/hotkeys_popup/widget.lua @@ -458,10 +458,11 @@ function widget.new(args) height = height, }) mywibox:set_widget(pages[1]) - mywibox:buttons(gtable.join( - awful.button({ }, 1, function () widget_obj:hide() end), - awful.button({ }, 3, function () widget_obj:hide() end) - )) + + mywibox.buttons = { + awful.button({ }, 1, function () widget_obj:hide() end), + awful.button({ }, 3, function () widget_obj:hide() end) + } function widget_obj.page_next(_self) if _self.current_page == #pages then return end diff --git a/lib/awful/menu.lua b/lib/awful/menu.lua index d6fa20490..ea265f982 100644 --- a/lib/awful/menu.lua +++ b/lib/awful/menu.lua @@ -446,13 +446,14 @@ function menu:add(args, index) -- Create bindings - item._background:buttons(gtable.join( + item._background.buttons = { button({}, 3, function () self:hide() end), button({}, 1, function () local num = gtable.hasitem(self.items, item) self:item_enter(num, { mouse = true }) self:exec(num, { exec = true, mouse = true }) - end ))) + end) + } item._mouse = function () diff --git a/lib/awful/widget/button.lua b/lib/awful/widget/button.lua index c71bab851..dcbaf5b3c 100644 --- a/lib/awful/widget/button.lua +++ b/lib/awful/widget/button.lua @@ -1,12 +1,12 @@ --------------------------------------------------------------------------- -- A simple button widget. --- @usage local button = awful.widget.button() --- button:buttons(gears.table.join( --- button:buttons(), --- awful.button({}, 1, nil, function () --- print("Mouse was clicked") --- end) --- )) +-- +-- button.buttons = { +-- awful.button({}, 1, nil, function () +-- print("Mouse was clicked") +-- end) +-- } +-- -- @author Julien Danjou <julien@danjou.info> -- @copyright 2008-2009 Julien Danjou -- @widgetmod awful.widget.button diff --git a/lib/awful/widget/calendar_popup.lua b/lib/awful/widget/calendar_popup.lua index f7e480f03..709300252 100644 --- a/lib/awful/widget/calendar_popup.lua +++ b/lib/awful/widget/calendar_popup.lua @@ -254,7 +254,8 @@ function calendar_popup:attach(widget, position, args) position = position or "tr" args = args or {} if args.on_hover == nil then args.on_hover=true end - widget:buttons(gears.table.join( + + widget.buttons = { abutton({ }, 1, function () if not self.visible or self._calendar_clicked_on then self:call_calendar(0, position) @@ -264,7 +265,8 @@ function calendar_popup:attach(widget, position, args) end), abutton({ }, 4, function () self:call_calendar(-1) end), abutton({ }, 5, function () self:call_calendar( 1) end) - )) + } + if args.on_hover then widget:connect_signal("mouse::enter", function () if not self._calendar_clicked_on then @@ -330,18 +332,19 @@ local function get_cal_wibox(caltype, args) } ret:set_widget(widget) - ret:buttons(gears.table.join( - abutton({ }, 1, function () - ret.visible=false - ret._calendar_clicked_on=false - end), - abutton({ }, 3, function () - ret.visible=false - ret._calendar_clicked_on=false - end), - abutton({ }, 4, function () ret:call_calendar(-1) end), - abutton({ }, 5, function () ret:call_calendar( 1) end) - )) + ret.buttons = { + abutton({ }, 1, function () + ret.visible=false + ret._calendar_clicked_on=false + end), + abutton({ }, 3, function () + ret.visible=false + ret._calendar_clicked_on=false + end), + abutton({ }, 4, function () ret:call_calendar(-1) end), + abutton({ }, 5, function () ret:call_calendar( 1) end) + } + return ret end diff --git a/lib/awful/widget/common.lua b/lib/awful/widget/common.lua index 3b8dc6a6e..db67b0629 100644 --- a/lib/awful/widget/common.lua +++ b/lib/awful/widget/common.lua @@ -129,7 +129,7 @@ function common.list_update(w, buttons, label, data, objects, args) cache = (args and args.widget_template) and custom_template(args) or default_template() - cache.primary:buttons(common.create_buttons(buttons, o)) + cache.primary.buttons = {common.create_buttons(buttons, o)} if cache.create_callback then cache.create_callback(cache.primary, o, i, objects) diff --git a/lib/awful/widget/keyboardlayout.lua b/lib/awful/widget/keyboardlayout.lua index a87b556a1..99d9e7a9f 100644 --- a/lib/awful/widget/keyboardlayout.lua +++ b/lib/awful/widget/keyboardlayout.lua @@ -8,7 +8,6 @@ local capi = {awesome = awesome} local setmetatable = setmetatable local textbox = require("wibox.widget.textbox") local button = require("awful.button") -local gtable = require("gears.table") local widget_base = require("wibox.widget.base") local gdebug = require("gears.debug") @@ -295,9 +294,9 @@ function keyboardlayout.new() function () update_status(self) end); -- Mouse bindings - self:buttons( - gtable.join(button({ }, 1, self.next_layout)) - ) + self.buttons = { + button({ }, 1, self.next_layout) + } return self end diff --git a/lib/awful/widget/launcher.lua b/lib/awful/widget/launcher.lua index 4c2ff0c47..e6596dee4 100644 --- a/lib/awful/widget/launcher.lua +++ b/lib/awful/widget/launcher.lua @@ -5,7 +5,6 @@ --------------------------------------------------------------------------- local setmetatable = setmetatable -local gtable = require("gears.table") local spawn = require("awful.spawn") local wbutton = require("awful.widget.button") local button = require("awful.button") @@ -22,14 +21,12 @@ function launcher.new(args) local w = wbutton(args) if not w then return end - local b if args.command then - b = gtable.join(w:buttons(), button({}, 1, nil, function () spawn(args.command) end)) + w:add_button(button({}, 1, nil, function () spawn(args.command) end)) elseif args.menu then - b = gtable.join(w:buttons(), button({}, 1, nil, function () args.menu:toggle() end)) + w:add_button(button({}, 1, nil, function () args.menu:toggle() end)) end - w:buttons(b) return w end diff --git a/lib/naughty/layout/legacy.lua b/lib/naughty/layout/legacy.lua index 3f89101fc..ab8d38420 100644 --- a/lib/naughty/layout/legacy.lua +++ b/lib/naughty/layout/legacy.lua @@ -31,7 +31,6 @@ local screen = require("awful.screen") local button = require("awful.button") local beautiful = require("beautiful") local surface = require("gears.surface") -local gtable = require("gears.table") local wibox = require("wibox") local gfs = require("gears.filesystem") local timer = require("gears.timer") @@ -446,14 +445,11 @@ function naughty.default_notification_handler(notification, args) local action_height = h + 2 * margin local action_width = w + 2 * margin - actionmarginbox:buttons(gtable.join( - button({ }, 1, function() - action:invoke(notification) - end), - button({ }, 3, function() - action:invoke(notification) - end) - )) + actionmarginbox.buttons = { + button({ }, 1, function() action:invoke(notification) end), + button({ }, 3, function() action:invoke(notification) end), + } + actionslayout:add(actionmarginbox) actions_total_height = actions_total_height + action_height @@ -584,10 +580,12 @@ function naughty.default_notification_handler(notification, args) notification.box:set_widget(completelayout) -- Setup the mouse events - layout:buttons(gtable.join(button({}, 1, nil, run), - button({}, 3, nil, function() - die(naughty.notification_closed_reason.dismissed_by_user) - end))) + layout.buttons = { + button({}, 1, nil, run), + button({}, 3, nil, function() + die(naughty.notification_closed_reason.dismissed_by_user) + end), + } -- insert the notification to the table table.insert(current_notifications[s][notification.position], notification) diff --git a/tests/test-leak-client.lua b/tests/test-leak-client.lua index 1d67be92a..ca989b231 100644 --- a/tests/test-leak-client.lua +++ b/tests/test-leak-client.lua @@ -7,29 +7,29 @@ local gtable = require("gears.table") -- Create a titlebar and return a table with references to its member widgets. local function create_titlebar(c) local parts = {} - local buttons = gtable.join( + local buttons = { awful.button({ }, 1, function() client.focus = c c:raise() awful.mouse.client.move(c) end), awful.button({ }, 3, function() - client.focus = c - c:raise() - awful.mouse.client.resize(c) - end) - ) + client.focus = c + c:raise() + awful.mouse.client.resize(c) + end) + } -- Widgets that are aligned to the left parts.icon = awful.titlebar.widget.iconwidget(c) local left_layout = wibox.layout.fixed.horizontal(parts.icon) - left_layout:buttons(buttons) + left_layout.buttons = buttons -- The title goes in the middle parts.title = awful.titlebar.widget.titlewidget(c) parts.title:set_align("center") local middle_layout = wibox.layout.flex.horizontal(parts.title) - middle_layout:buttons(buttons) + middle_layout.buttons = buttons parts.floating_button = awful.titlebar.widget.floatingbutton(c) parts.maximized_button = awful.titlebar.widget.maximizedbutton(c)