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:
parent
034a93d691
commit
d716476872
|
@ -27,32 +27,22 @@ local function spiral(p, dwindle)
|
|||
else
|
||||
nw = nw / 2
|
||||
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
|
||||
if k % 4 == 1 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
|
||||
|
||||
if k % 4 == 0 and not dwindle then
|
||||
nx = nx - nw
|
||||
elseif k % 2 == 0 or
|
||||
(k % 4 == 3 and k < n and not dwindle) then
|
||||
nx = nx + nw
|
||||
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
|
||||
if k == 1 then
|
||||
ny = wa.y
|
||||
end
|
||||
|
||||
local geom = { x = nx, y = ny, width = nw, height = nh }
|
||||
c:geometry(geom)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue