diff --git a/lib/awful/layout/init.lua.in b/lib/awful/layout/init.lua.in index fec04ee36..bd9de0d47 100644 --- a/lib/awful/layout/init.lua.in +++ b/lib/awful/layout/init.lua.in @@ -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)