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:
parent
a559f55c6a
commit
a2cd918603
|
@ -192,6 +192,19 @@ function wibox:set_screen(s)
|
||||||
self._drawable:_force_screen(s)
|
self._drawable:_force_screen(s)
|
||||||
end
|
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
|
for _, k in pairs{ "buttons", "struts", "geometry", "get_xproperty", "set_xproperty" } do
|
||||||
wibox[k] = function(self, ...)
|
wibox[k] = function(self, ...)
|
||||||
return self.drawin[k](self.drawin, ...)
|
return self.drawin[k](self.drawin, ...)
|
||||||
|
|
|
@ -543,7 +543,9 @@ function base.widget:setup(args)
|
||||||
rawset(self, "_by_id", ids)
|
rawset(self, "_by_id", ids)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
--- Create a widget from a declarative description.
|
--- Create a widget from a declarative description.
|
||||||
|
|
Loading…
Reference in New Issue