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")
|
|
|
|
|
2009-08-19 20:37:24 +02:00
|
|
|
local function spiral(p, spiral)
|
2009-07-12 20:27:41 +02:00
|
|
|
local wa = p.workarea
|
|
|
|
local cls = p.clients
|
|
|
|
local n = #cls
|
|
|
|
|
|
|
|
for k, c in ipairs(cls) do
|
2009-08-19 20:37:22 +02:00
|
|
|
if k < n then
|
|
|
|
if k % 2 == 0 then
|
2009-08-19 20:37:25 +02:00
|
|
|
wa.height = wa.height / 2
|
2009-08-19 20:37:22 +02:00
|
|
|
else
|
2009-08-19 20:37:25 +02:00
|
|
|
wa.width = wa.width / 2
|
2009-07-12 20:27:41 +02:00
|
|
|
end
|
2009-08-19 20:37:22 +02:00
|
|
|
end
|
2009-08-19 20:37:23 +02:00
|
|
|
|
2009-08-19 20:37:24 +02:00
|
|
|
if k % 4 == 0 and spiral then
|
2009-08-19 20:37:25 +02:00
|
|
|
wa.x = wa.x - wa.width
|
2009-08-19 20:37:23 +02:00
|
|
|
elseif k % 2 == 0 or
|
2009-08-19 20:37:24 +02:00
|
|
|
(k % 4 == 3 and k < n and spiral) then
|
2009-08-19 20:37:25 +02:00
|
|
|
wa.x = wa.x + wa.width
|
2009-08-19 20:37:22 +02:00
|
|
|
end
|
2009-08-19 20:37:23 +02:00
|
|
|
|
2009-08-19 20:37:24 +02:00
|
|
|
if k % 4 == 1 and k ~= 1 and spiral then
|
2009-08-19 20:37:25 +02:00
|
|
|
wa.y = wa.y - wa.height
|
2009-08-19 20:37:23 +02:00
|
|
|
elseif k % 2 == 1 and k ~= 1 or
|
2009-08-19 20:37:24 +02:00
|
|
|
(k % 4 == 0 and k < n and spiral) then
|
2009-08-19 20:37:25 +02:00
|
|
|
wa.y = wa.y + wa.height
|
2009-07-12 20:27:41 +02:00
|
|
|
end
|
2009-08-19 20:37:23 +02:00
|
|
|
|
2010-05-28 19:43:46 +02:00
|
|
|
local g = {
|
|
|
|
x = wa.x,
|
|
|
|
y = wa.y,
|
|
|
|
width = wa.width - 2 * c.border_width,
|
|
|
|
height = wa.height - 2 * c.border_width
|
|
|
|
}
|
|
|
|
c:geometry(g)
|
2009-07-12 20:27:41 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Dwindle layout
|
|
|
|
dwindle = {}
|
|
|
|
dwindle.name = "dwindle"
|
|
|
|
function dwindle.arrange(p)
|
2009-08-19 20:37:24 +02:00
|
|
|
return spiral(p, false)
|
2009-07-12 20:27:41 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Spiral layout
|
|
|
|
name = "spiral"
|
|
|
|
function arrange(p)
|
2009-08-19 20:37:24 +02:00
|
|
|
return spiral(p, true)
|
2009-07-12 20:27:41 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|