Fallback to comparing layout names in awful.layout.inc

This helps in cases where you have accidentally cloned an entry from
`layouts`.

Previously, no current index would be found and the function would
silently fail.

Signed-off-by: Daniel Hahler <git@thequod.de>
This commit is contained in:
Daniel Hahler 2014-03-14 17:21:11 +01:00 committed by Uli Schlachter
parent 11f7b5aa3d
commit 31e3399abe
1 changed files with 10 additions and 1 deletions

View File

@ -43,13 +43,22 @@ function layout.inc(layouts, i, s)
if t then
local curlayout = layout.get(s)
local curindex
local rev_layouts = {}
for k, v in ipairs(layouts) do
if v == curlayout then
curindex = k
break
end
end
if not curindex then
-- Safety net: handle cases where another reference of the layout
-- might be given (e.g. when (accidentally) cloning it).
for k, v in ipairs(layouts) do
if v.name == curlayout.name then
curindex = k
break
end
end
end
if curindex then
local newindex = util.cycle(#layouts, curindex + i)
layout.set(layouts[newindex], t)