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
This commit is contained in:
Emmanuel Lepage Vallée 2019-01-01 15:04:47 -05:00 committed by GitHub
parent a559f55c6a
commit a2cd918603
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -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, ...)

View File

@ -543,7 +543,9 @@ function base.widget:setup(args)
rawset(self, "_by_id", ids)
end
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.