From 31e3399abeca0be72722819ddfc26840c2f9df5a Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 14 Mar 2014 17:21:11 +0100 Subject: [PATCH] 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 --- lib/awful/layout/init.lua.in | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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)