rules.tags: Behave like rules.tag

One did try to match tag by name and the other didn't.

While at it, also ensure that the screen is consistent.
This commit is contained in:
Emmanuel Lepage Vallee 2016-12-11 22:47:15 -05:00
parent c96aa9866e
commit 4b61dbba82
1 changed files with 22 additions and 4 deletions

View File

@ -376,13 +376,31 @@ function rules.extra_properties.placement(c, value)
end end
end end
function rules.extra_properties.tags(c, value) function rules.extra_properties.tags(c, value, props)
local current = c:tags() local current = c:tags()
local tags, s = {}, nil
for _, t in ipairs(value) do
if type(t) == "string" then
t = atag.find_by_name(c.screen, t)
end
if t and ((not s) or t.screen == s) then
table.insert(tags, t)
s = s or t.screen
end
end
if s and s ~= c.screen then
c.screen = s
props.screen = s -- In case another rule query it
end
if #current == 0 or (value[1] and value[1].screen ~= current[1].screen) then if #current == 0 or (value[1] and value[1].screen ~= current[1].screen) then
c:tags(value) c:tags(tags)
else else
c:tags(util.table.merge(current, value)) c:tags(util.table.merge(current, tags))
end end
end end
@ -477,7 +495,7 @@ function rules.execute(c, props, callbacks)
if not ignore then if not ignore then
if rules.extra_properties[property] then if rules.extra_properties[property] then
rules.extra_properties[property](c, value) rules.extra_properties[property](c, value, props)
elseif type(c[property]) == "function" then elseif type(c[property]) == "function" then
c[property](c, value) c[property](c, value)
else else