2009-07-12 20:27:41 +02:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
-- @author Uli Schlachter <psychon@znc.in>
|
|
|
|
-- @copyright 2009 Uli Schlachter
|
|
|
|
-- @copyright 2008 Julien Danjou
|
|
|
|
-- @release @AWESOME_VERSION@
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-- Grab environment we need
|
|
|
|
local ipairs = ipairs
|
|
|
|
|
|
|
|
module("awful.layout.suit.spiral")
|
|
|
|
|
|
|
|
local function spiral(p, dwindle)
|
|
|
|
local wa = p.workarea
|
|
|
|
local cls = p.clients
|
|
|
|
|
|
|
|
local n = #cls
|
|
|
|
local nx = wa.x
|
|
|
|
local ny = wa.y
|
|
|
|
local nw = wa.width
|
|
|
|
local nh = wa.height
|
|
|
|
|
|
|
|
for k, c in ipairs(cls) do
|
2009-08-19 20:37:21 +02:00
|
|
|
if (k % 2 == 0 and nh / 2 > 2 * c.border_width)
|
|
|
|
or (k % 2 == 1 and nw / 2 > 2 * c.border_width) then
|
|
|
|
if k < n then
|
|
|
|
if k % 2 == 0 then
|
2009-07-12 20:27:41 +02:00
|
|
|
nh = nh / 2
|
|
|
|
else
|
|
|
|
nw = nw / 2
|
|
|
|
end
|
2009-08-19 20:37:21 +02:00
|
|
|
if k % 4 == 3 and not dwindle then
|
2009-07-12 20:27:41 +02:00
|
|
|
nx = nx + nw
|
2009-08-19 20:37:21 +02:00
|
|
|
elseif k % 4 == 0 and not dwindle then
|
2009-07-12 20:27:41 +02:00
|
|
|
ny = ny + nh
|
|
|
|
end
|
|
|
|
end
|
2009-08-19 20:37:21 +02:00
|
|
|
if k % 4 == 1 then
|
2009-07-12 20:27:41 +02:00
|
|
|
if dwindle then
|
|
|
|
ny = ny + nh
|
|
|
|
else
|
|
|
|
ny = ny - nh
|
|
|
|
end
|
2009-08-19 20:37:21 +02:00
|
|
|
elseif k % 4 == 2 then
|
2009-07-12 20:27:41 +02:00
|
|
|
nx = nx + nw
|
2009-08-19 20:37:21 +02:00
|
|
|
elseif k % 4 == 3 then
|
2009-07-12 20:27:41 +02:00
|
|
|
ny = ny + nh
|
2009-08-19 20:37:21 +02:00
|
|
|
elseif k % 4 == 0 then
|
2009-07-12 20:27:41 +02:00
|
|
|
if dwindle then
|
|
|
|
nx = nx + nw
|
|
|
|
else
|
|
|
|
nx = nx - nw
|
|
|
|
end
|
|
|
|
end
|
2009-08-19 20:37:21 +02:00
|
|
|
if k == 1 then
|
2009-07-12 20:27:41 +02:00
|
|
|
ny = wa.y
|
|
|
|
end
|
|
|
|
end
|
|
|
|
local geom = { x = nx, y = ny, width = nw, height = nh }
|
|
|
|
c:geometry(geom)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Dwindle layout
|
|
|
|
dwindle = {}
|
|
|
|
dwindle.name = "dwindle"
|
|
|
|
function dwindle.arrange(p)
|
|
|
|
return spiral(p, true)
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Spiral layout
|
|
|
|
name = "spiral"
|
|
|
|
function arrange(p)
|
|
|
|
return spiral(p, false)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|