diff --git a/lib/awful/titlebar.lua b/lib/awful/titlebar.lua index 40aaecbc9..b34cdbede 100644 --- a/lib/awful/titlebar.lua +++ b/lib/awful/titlebar.lua @@ -75,7 +75,7 @@ local function new(c, args) local ret if not bars[position] then - ret = drawable(d, nil) + ret = drawable(d, nil, "awful.titlebar") local function update_colors() local args = bars[position].args ret:set_bg(get_color("bg", c, args)) diff --git a/lib/wibox/drawable.lua b/lib/wibox/drawable.lua index b5ac9ba13..7b023a040 100644 --- a/lib/wibox/drawable.lua +++ b/lib/wibox/drawable.lua @@ -229,7 +229,7 @@ local function setup_signals(_drawable) clone_signal("property::y") end -function drawable.new(d, widget_arg) +function drawable.new(d, widget_arg, drawable_name) local ret = object() ret.drawable = d ret.widget_arg = widget_arg or ret @@ -287,6 +287,15 @@ function drawable.new(d, widget_arg) d:connect_signal("mouse::move", function(_, x, y) handle_motion(ret, x, y) end) d:connect_signal("mouse::leave", function() handle_leave(ret) end) + -- Add __tostring method to metatable. + ret.drawable_name = drawable_name or object.modulename(3) + local mt = {} + local orig_string = tostring(ret) + mt.__tostring = function(o) + return string.format("%s (%s)", ret.drawable_name, orig_string) + end + ret = setmetatable(ret, mt) + -- Make sure the drawable is drawn at least once ret.draw() diff --git a/lib/wibox/init.lua b/lib/wibox/init.lua index de727adb9..efbbef965 100644 --- a/lib/wibox/init.lua +++ b/lib/wibox/init.lua @@ -108,7 +108,8 @@ local function new(args) local ret = object() local w = capi.drawin(args) ret.drawin = w - ret._drawable = wibox.drawable(w.drawable, ret) + ret._drawable = wibox.drawable(w.drawable, ret, + "wibox drawable (" .. object.modulename(3) .. ")") for k, v in pairs(wibox) do if type(v) == "function" then @@ -126,6 +127,15 @@ local function new(args) ret:set_bg(args.bg or beautiful.bg_normal) ret:set_fg(args.fg or beautiful.fg_normal) + -- Add __tostring method to metatable. + local mt = {} + local orig_string = tostring(ret) + mt.__tostring = function(o) + return string.format("wibox: %s (%s)", + tostring(ret._drawable), orig_string) + end + ret = setmetatable(ret, mt) + -- Make sure the wibox is drawn at least once ret.draw() diff --git a/lib/wibox/widget/base.lua b/lib/wibox/widget/base.lua index fa56f0377..1a512eb91 100644 --- a/lib/wibox/widget/base.lua +++ b/lib/wibox/widget/base.lua @@ -110,8 +110,9 @@ function base.make_widget(proxy, widget_name) -- Add __tostring method to metatable. ret.widget_name = widget_name or object.modulename(3) local mt = {} + local orig_string = tostring(ret) mt.__tostring = function(o) - return ret.widget_name + return string.format("%s (%s)", ret.widget_name, orig_string) end return setmetatable(ret, mt) end