From 9a72062cacbaadb9c34ad54e2804429ed058774a Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 7 May 2016 23:46:57 -0400 Subject: [PATCH] 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. --- lib/wibox/init.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/wibox/init.lua b/lib/wibox/init.lua index 28a191f89..f594acd08 100644 --- a/lib/wibox/init.lua +++ b/lib/wibox/init.lua @@ -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