From a2cd9186036104eeb7086cda0d183c592a49da61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Lepage=20Vall=C3=A9e?= Date: Tue, 1 Jan 2019 15:04:47 -0500 Subject: [PATCH] wibox: Stop monkey-patching the `get_children_by_id` function. (#2513) Before this commit, it was added by `wibox.widget.base` if `:setup()` is used. However it doesn't work for the `awful.popup` because of the extra indirection. This commit stops the monkey-patching and make sure the function always exists. This doesn't prevent it from not working and in the long run this should still be moved into the hierarchy. However for now it makes the situation a lot more consistent and is a quick band-aid without too much controversy. Mitigate #2181 --- lib/wibox/init.lua | 13 +++++++++++++ lib/wibox/widget/base.lua | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/wibox/init.lua b/lib/wibox/init.lua index 00840560..a62c2aee 100644 --- a/lib/wibox/init.lua +++ b/lib/wibox/init.lua @@ -192,6 +192,19 @@ function wibox:set_screen(s) self._drawable:_force_screen(s) end +function wibox:get_children_by_id(name) + --TODO v5: Move the ID management to the hierarchy. + if rawget(self, "_by_id") then + return rawget(self, "_by_id")[name] + elseif 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 + for _, k in pairs{ "buttons", "struts", "geometry", "get_xproperty", "set_xproperty" } do wibox[k] = function(self, ...) return self.drawin[k](self.drawin, ...) diff --git a/lib/wibox/widget/base.lua b/lib/wibox/widget/base.lua index 80853c72..15096b1e 100644 --- a/lib/wibox/widget/base.lua +++ b/lib/wibox/widget/base.lua @@ -543,7 +543,9 @@ function base.widget:setup(args) rawset(self, "_by_id", ids) end - rawset(self, "get_children_by_id", get_children_by_id) + if not rawget(self, "get_children_by_id") then + rawset(self, "get_children_by_id", get_children_by_id) + end end --- Create a widget from a declarative description.