2009-07-12 20:27:41 +02:00
|
|
|
---------------------------------------------------------------------------
|
2014-05-20 12:44:21 +02:00
|
|
|
--- Dwindle and spiral layouts
|
|
|
|
--
|
2009-07-12 20:27:41 +02:00
|
|
|
-- @author Uli Schlachter <psychon@znc.in>
|
|
|
|
-- @copyright 2009 Uli Schlachter
|
|
|
|
-- @copyright 2008 Julien Danjou
|
2014-05-20 12:44:21 +02:00
|
|
|
--
|
2016-12-10 02:24:22 +01:00
|
|
|
-- @module awful.layout
|
2009-07-12 20:27:41 +02:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-- Grab environment we need
|
|
|
|
local ipairs = ipairs
|
2014-01-18 16:12:30 +01:00
|
|
|
local math = math
|
2009-07-12 20:27:41 +02:00
|
|
|
|
2016-08-14 07:34:43 +02:00
|
|
|
--- The spiral layout layoutbox icon.
|
|
|
|
-- @beautiful beautiful.layout_spiral
|
|
|
|
-- @param surface
|
|
|
|
-- @see gears.surface
|
|
|
|
|
|
|
|
--- The dwindle layout layoutbox icon.
|
|
|
|
-- @beautiful beautiful.layout_dwindle
|
|
|
|
-- @param surface
|
|
|
|
-- @see gears.surface
|
|
|
|
|
2012-06-14 02:45:17 +02:00
|
|
|
local spiral = {}
|
2009-07-12 20:27:41 +02:00
|
|
|
|
2022-07-03 08:10:31 +02:00
|
|
|
local function do_spiral(p, is_spiral)
|
2009-07-12 20:27:41 +02:00
|
|
|
local wa = p.workarea
|
|
|
|
local cls = p.clients
|
|
|
|
local n = #cls
|
2014-01-18 16:12:30 +01:00
|
|
|
local old_width, old_height = wa.width, 2 * wa.height
|
2009-07-12 20:27:41 +02:00
|
|
|
|
|
|
|
for k, c in ipairs(cls) do
|
2014-01-18 16:12:30 +01:00
|
|
|
if k % 2 == 0 then
|
|
|
|
wa.width, old_width = math.ceil(old_width / 2), wa.width
|
|
|
|
if k ~= n then
|
|
|
|
wa.height, old_height = math.floor(wa.height / 2), wa.height
|
|
|
|
end
|
|
|
|
else
|
|
|
|
wa.height, old_height = math.ceil(old_height / 2), wa.height
|
|
|
|
if k ~= n then
|
|
|
|
wa.width, old_width = math.floor(wa.width / 2), wa.width
|
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
|
|
|
|
2022-07-03 08:10:31 +02:00
|
|
|
if k % 4 == 0 and is_spiral then
|
2009-08-19 20:37:25 +02:00
|
|
|
wa.x = wa.x - wa.width
|
2014-01-18 16:12:30 +01:00
|
|
|
elseif k % 2 == 0 then
|
|
|
|
wa.x = wa.x + old_width
|
2022-07-03 08:10:31 +02:00
|
|
|
elseif k % 4 == 3 and k < n and is_spiral then
|
2014-01-18 16:12:30 +01:00
|
|
|
wa.x = wa.x + math.ceil(old_width / 2)
|
2009-08-19 20:37:22 +02:00
|
|
|
end
|
2009-08-19 20:37:23 +02:00
|
|
|
|
2022-07-03 08:10:31 +02:00
|
|
|
if k % 4 == 1 and k ~= 1 and is_spiral then
|
2009-08-19 20:37:25 +02:00
|
|
|
wa.y = wa.y - wa.height
|
2014-01-18 16:12:30 +01:00
|
|
|
elseif k % 2 == 1 and k ~= 1 then
|
|
|
|
wa.y = wa.y + old_height
|
2022-07-03 08:10:31 +02:00
|
|
|
elseif k % 4 == 0 and k < n and is_spiral then
|
2014-01-18 16:12:30 +01:00
|
|
|
wa.y = wa.y + math.ceil(old_height / 2)
|
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,
|
2015-02-15 17:25:11 +01:00
|
|
|
width = wa.width,
|
|
|
|
height = wa.height
|
2010-05-28 19:43:46 +02:00
|
|
|
}
|
2015-02-15 17:25:11 +01:00
|
|
|
p.geometries[c] = g
|
2009-07-12 20:27:41 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-12-10 02:24:22 +01:00
|
|
|
--- Dwindle layout.
|
|
|
|
-- @clientlayout awful.layout.suit.spiral.dwindle
|
2021-12-21 06:54:15 +01:00
|
|
|
-- @usebeautiful beautiful.layout_dwindle
|
2012-06-14 02:45:17 +02:00
|
|
|
spiral.dwindle = {}
|
|
|
|
spiral.dwindle.name = "dwindle"
|
|
|
|
function spiral.dwindle.arrange(p)
|
|
|
|
return do_spiral(p, false)
|
2009-07-12 20:27:41 +02:00
|
|
|
end
|
|
|
|
|
2016-12-10 02:24:22 +01:00
|
|
|
--- Spiral layout.
|
|
|
|
-- @clientlayout awful.layout.suit.spiral.name
|
2021-12-21 06:54:15 +01:00
|
|
|
-- @usebeautiful beautiful.layout_spiral
|
2012-06-14 02:45:17 +02:00
|
|
|
spiral.name = "spiral"
|
|
|
|
function spiral.arrange(p)
|
|
|
|
return do_spiral(p, true)
|
2009-07-12 20:27:41 +02:00
|
|
|
end
|
|
|
|
|
2012-06-14 02:45:17 +02:00
|
|
|
return spiral
|
|
|
|
|
2011-09-11 16:50:01 +02:00
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|