layout: spiral: refactoring

Look at the problem as "in which cases do we add or remove nw or nh?"
rather than "what do we do when k = ...?".

Signed-off-by: Fabienne Ducroquet <fabiduc@gmail.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Fabienne Ducroquet 2009-08-19 20:37:23 +02:00 committed by Julien Danjou
parent 034a93d691
commit d716476872
1 changed files with 12 additions and 22 deletions

View File

@ -27,32 +27,22 @@ local function spiral(p, dwindle)
else else
nw = nw / 2 nw = nw / 2
end end
if k % 4 == 3 and not dwindle then
nx = nx + nw
elseif k % 4 == 0 and not dwindle then
ny = ny + nh
end end
end
if k % 4 == 1 then if k % 4 == 0 and not dwindle then
if dwindle then
ny = ny + nh
else
ny = ny - nh
end
elseif k % 4 == 2 then
nx = nx + nw
elseif k % 4 == 3 then
ny = ny + nh
elseif k % 4 == 0 then
if dwindle then
nx = nx + nw
else
nx = nx - nw nx = nx - nw
elseif k % 2 == 0 or
(k % 4 == 3 and k < n and not dwindle) then
nx = nx + nw
end end
if k % 4 == 1 and k ~= 1 and not dwindle then
ny = ny - nh
elseif k % 2 == 1 and k ~= 1 or
(k % 4 == 0 and k < n and not dwindle) then
ny = ny + nh
end end
if k == 1 then
ny = wa.y
end
local geom = { x = nx, y = ny, width = nw, height = nh } local geom = { x = nx, y = ny, width = nw, height = nh }
c:geometry(geom) c:geometry(geom)
end end