From 81019487f051b841f54bd7236c620a5bbec1af40 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Tue, 29 Dec 2015 07:45:01 -0500 Subject: [PATCH] awful.client.idx: Avoid error when called with a floating client Before, it was the caller job to make sure the client wasn't floating. This limitation is unecessary. awful.client.idx now return nil instead of an error. awful.rules setting the master width factor are now foolproof. --- lib/awful/client.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/awful/client.lua b/lib/awful/client.lua index 517cd307..2d2585a4 100644 --- a/lib/awful/client.lua +++ b/lib/awful/client.lua @@ -780,6 +780,7 @@ function client.idx(c) local c = c or capi.client.focus if not c then return end + -- Only check the tiled clients, the others un irrelevant local clients = client.tiled(c.screen) local idx = nil for k, cl in ipairs(clients) do @@ -791,6 +792,10 @@ function client.idx(c) local t = tag.selected(c.screen) local nmaster = tag.getnmaster(t) + + -- This will happen for floating or maximized clients + if not idx then return nil end + if idx <= nmaster then return {idx = idx, col=0, num=nmaster} end @@ -834,9 +839,12 @@ function client.setwfact(wfact, c) local c = c or capi.client.focus if not c or not c:isvisible() then return end - local t = tag.selected(c.screen) local w = client.idx(c) + if not w then return end + + local t = tag.selected(c.screen) + local cls = client.tiled(tag.getscreen(t)) local nmaster = tag.getnmaster(t)