Merge pull request #1236 from Elv13/fix_new_tag_rule

rules.new_tag: Fix when the tag screen doesn't match the client
This commit is contained in:
Emmanuel Lepage Vallée 2016-12-01 19:53:17 -05:00 committed by GitHub
commit 883b5934c0
3 changed files with 44 additions and 5 deletions

View File

@ -312,8 +312,9 @@ end
--- Create a new tag based on a rule.
-- @tparam client c The client
-- @tparam boolean|function|string value The value.
-- @tparam table props The properties.
-- @treturn tag The new tag
function rules.high_priority_properties.new_tag(c, value)
function rules.high_priority_properties.new_tag(c, value, props)
local ty = type(value)
local t = nil
@ -324,8 +325,16 @@ function rules.high_priority_properties.new_tag(c, value)
-- Create a tag named after "value"
t = atag.add(value, {screen=c.screen, volatile=true})
elseif ty == "table" then
-- Assume a table of tags properties
t = atag.add(value.name or c.class or "N/A", value)
-- Assume a table of tags properties. Set the right screen, but
-- avoid editing the original table
local values = value.screen and value or util.table.clone(value)
values.screen = values.screen or c.screen
t = atag.add(value.name or c.class or "N/A", values)
-- In case the tag has been forced to another screen, move the client
c.screen = t.screen
props.screen = t.screen -- In case another rule query it
else
assert(false)
end
@ -409,7 +418,7 @@ function rules.execute(c, props, callbacks)
value = value(c, props)
end
handler(c, value)
handler(c, value, props)
end
end

View File

@ -195,7 +195,7 @@ start_awesome() {
# Count errors.
errors=0
# Seconds after when awesome gets killed.
timeout_stale=120 # FIXME This should be no more than 60s
timeout_stale=180 # FIXME This should be no more than 60s
for f in $tests; do
echo "== Running $f =="

View File

@ -209,6 +209,36 @@ table.insert(multi_screen_steps, function()
return true
end)
-- Test the `new_tag` rule
table.insert(multi_screen_steps, function()
for _, c in ipairs(client.get()) do
c:kill()
end
for i=1, screen.count() do
local s = screen[i]
test_client("screen"..i, nil, {
new_tag = {
name = "NEW_AT_"..i,
screen = s,
}
})
end
return true
end)
table.insert(multi_screen_steps, function()
if #client.get() ~= screen.count() then return end
for _, c in ipairs(client.get()) do
assert(#c:tags() == 1)
assert(c.first_tag.name == "NEW_AT_"..c.screen.index)
end
return true
end)
require("_multi_screen")(steps, multi_screen_steps)
require("_runner").run_steps(steps)