wibox: Turn into "real" objects.
Before this commit, it was necessary to call 'rawset' to be able to add new fields to the wibox. This is no longer required. This solution was choosen because wibox is itself a base class of menus and wibars. Those classes can now add new properties without hacks.
This commit is contained in:
parent
43ef623dc6
commit
9a72062cac
|
@ -26,6 +26,11 @@ wibox.widget = require("wibox.widget")
|
|||
wibox.drawable = require("wibox.drawable")
|
||||
wibox.hierarchy = require("wibox.hierarchy")
|
||||
|
||||
local force_forward = {
|
||||
shape_bounding = true,
|
||||
shape_clip = true,
|
||||
}
|
||||
|
||||
--- Set the widget that the wibox displays
|
||||
function wibox:set_widget(widget)
|
||||
self._drawable:set_widget(widget)
|
||||
|
@ -340,10 +345,18 @@ local function new(args)
|
|||
-- Make sure the wibox is drawn at least once
|
||||
ret.draw()
|
||||
|
||||
-- Redirect all non-existing indexes to the "real" drawin
|
||||
-- If a value is not found, look in the drawin
|
||||
setmetatable(ret, {
|
||||
__index = w,
|
||||
__newindex = w
|
||||
__newindex = function(self, k,v)
|
||||
if wibox["set_"..k] then
|
||||
wibox["set_"..k](v)
|
||||
elseif w[k] ~= nil or force_forward[k] then
|
||||
w[k] = v
|
||||
else
|
||||
rawset(self, k, v)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
return ret
|
||||
|
|
Loading…
Reference in New Issue