wibox.drawable: Add visibility tracking callback
This new function is called whenever the visibility of the drawable changes. Later commits can use this for explicitly tracking the lifetime of drawables instead of using magic weak tables. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
26d3c5eb1a
commit
843d0bdcf5
|
@ -282,6 +282,7 @@ local function new(c, args)
|
|||
position = position
|
||||
}
|
||||
ret = drawable(d, context, "awful.titlebar")
|
||||
ret:_inform_visible(true)
|
||||
local function update_colors()
|
||||
local args_ = bars[position].args
|
||||
ret:set_bg(get_color("bg", c, args_))
|
||||
|
@ -298,6 +299,9 @@ local function new(c, args)
|
|||
-- Update the colors when focus changes
|
||||
c:connect_signal("focus", update_colors)
|
||||
c:connect_signal("unfocus", update_colors)
|
||||
|
||||
-- Inform the drawable when it becomes invisible
|
||||
c:connect_signal("unmanage", function() ret:_inform_visible(false) end)
|
||||
else
|
||||
bars[position].args = args
|
||||
ret = bars[position].drawable
|
||||
|
|
|
@ -266,6 +266,9 @@ function drawable:set_fg(c)
|
|||
self._do_complete_repaint()
|
||||
end
|
||||
|
||||
function drawable:_inform_visible(visible)
|
||||
end
|
||||
|
||||
local function emit_difference(name, list, skip)
|
||||
local function in_table(table, val)
|
||||
for _, v in pairs(table) do
|
||||
|
|
|
@ -169,6 +169,11 @@ local function new(args)
|
|||
ret._drawable = wibox.drawable(w.drawable, { wibox = ret },
|
||||
"wibox drawable (" .. object.modulename(3) .. ")")
|
||||
|
||||
ret._drawable:_inform_visible(w.visible)
|
||||
w:connect_signal("property::visible", function()
|
||||
ret._drawable:_inform_visible(w.visible)
|
||||
end)
|
||||
|
||||
for k, v in pairs(wibox) do
|
||||
if type(v) == "function" then
|
||||
ret[k] = v
|
||||
|
|
Loading…
Reference in New Issue