All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
4 Licensed under GNU General Public License v2
5 * (c) 2013, Luke Bonham
6 * (c) 2012, Josh Komoroske
7 * (c) 2010-2012, Peter Hofmann
11 local beautiful = require("beautiful")
13 local math = { ceil = math.ceil, sqrt = math.sqrt }
14 local tonumber = tonumber
16 local uselessfair = {}
18 local function fair(p, orientation)
19 -- A useless gap (like the dwm patch) can be defined with
20 -- beautiful.useless_gap_width.
21 local useless_gap = tonumber(beautiful.useless_gap_width)
31 local cells = math.ceil(math.sqrt(#cls))
32 local strips = math.ceil(#cls / cells)
36 for k, c in ipairs(cls) do
38 -- Save actual grid index for use in the useless_gap
42 if ( orientation == "east" and #cls > 2 )
43 or ( orientation == "south" and #cls <= 2 ) then
44 if #cls < (strips * cells) and strip == strips - 1 then
45 g.width = wa.width / (cells - ((strips * cells) - #cls))
47 g.width = wa.width / cells
49 g.height = wa.height / strips
54 g.x = wa.x + cell * g.width
55 g.y = wa.y + strip * g.height
58 if #cls < (strips * cells) and strip == strips - 1 then
59 g.height = wa.height / (cells - ((strips * cells) - #cls))
61 g.height = wa.height / cells
63 g.width = wa.width / strips
68 g.x = wa.x + strip * g.width
69 g.y = wa.y + cell * g.height
75 -- Top and left clients are shrinked by two steps and
76 -- get moved away from the border. Other clients just
77 -- get shrinked in one direction.
80 g.width = g.width - 2 * useless_gap
81 g.x = g.x + useless_gap
83 g.width = g.width - useless_gap
88 g.height = g.height - 2 * useless_gap
89 g.y = g.y + useless_gap
91 g.height = g.height - useless_gap
94 -- End of useless gap.
107 --- Horizontal fair layout.
108 -- @param screen The screen to arrange.
109 uselessfair.horizontal = {}
110 uselessfair.horizontal.name = "uselessfairh"
111 function uselessfair.horizontal.arrange(p)
112 return fair(p, "east")
115 -- Vertical fair layout.
116 -- @param screen The screen to arrange.
117 uselessfair.name = "uselessfair"
118 function uselessfair.arrange(p)
119 return fair(p, "south")