awful.tag: Save dynamic_cache as a tag property
Instead of using magic with a weak table, the code now saves this cache as a property under the tag object. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
4ef63d9416
commit
bf97cb6bfe
|
@ -35,7 +35,6 @@ local tag = {object = {}, mt = {} }
|
||||||
-- Private data
|
-- Private data
|
||||||
local data = {}
|
local data = {}
|
||||||
data.history = {}
|
data.history = {}
|
||||||
data.dynamic_cache = setmetatable({}, { __mode = 'k' })
|
|
||||||
data.tags = setmetatable({}, { __mode = 'k' })
|
data.tags = setmetatable({}, { __mode = 'k' })
|
||||||
|
|
||||||
-- History functions
|
-- History functions
|
||||||
|
@ -710,11 +709,11 @@ function tag.object.set_layout(t, layout)
|
||||||
and getmetatable(layout)
|
and getmetatable(layout)
|
||||||
and getmetatable(layout).__call
|
and getmetatable(layout).__call
|
||||||
) then
|
) then
|
||||||
if not data.dynamic_cache[t] then
|
if not t.dynamic_layout_cache then
|
||||||
data.dynamic_cache[t] = {}
|
t.dynamic_layout_cache = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
local instance = data.dynamic_cache[t][layout] or layout(t)
|
local instance = t.dynamic_layout_cache[layout] or layout(t)
|
||||||
|
|
||||||
-- Always make sure the layout is notified it is enabled
|
-- Always make sure the layout is notified it is enabled
|
||||||
if tag.getproperty(t, "screen").selected_tag == t and instance.wake_up then
|
if tag.getproperty(t, "screen").selected_tag == t and instance.wake_up then
|
||||||
|
@ -723,7 +722,7 @@ function tag.object.set_layout(t, layout)
|
||||||
|
|
||||||
-- Avoid creating the same layout twice, use layout:reset() to reset
|
-- Avoid creating the same layout twice, use layout:reset() to reset
|
||||||
if instance.is_dynamic then
|
if instance.is_dynamic then
|
||||||
data.dynamic_cache[t][layout] = instance
|
t.dynamic_layout_cache[layout] = instance
|
||||||
end
|
end
|
||||||
|
|
||||||
layout = instance
|
layout = instance
|
||||||
|
|
Loading…
Reference in New Issue