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) or 0
27 local cells = math.ceil(math.sqrt(#cls))
28 local strips = math.ceil(#cls / cells)
32 for k, c in ipairs(cls) do
34 -- Save actual grid index for use in the useless_gap
38 if ( orientation == "east" and #cls > 2 )
39 or ( orientation == "south" and #cls <= 2 ) then
40 if #cls < (strips * cells) and strip == strips - 1 then
41 g.width = wa.width / (cells - ((strips * cells) - #cls))
43 g.width = wa.width / cells
45 g.height = wa.height / strips
50 g.x = wa.x + cell * g.width
51 g.y = wa.y + strip * g.height
54 if #cls < (strips * cells) and strip == strips - 1 then
55 g.height = wa.height / (cells - ((strips * cells) - #cls))
57 g.height = wa.height / cells
59 g.width = wa.width / strips
64 g.x = wa.x + strip * g.width
65 g.y = wa.y + cell * g.height
71 -- Top and left clients are shrinked by two steps and
72 -- get moved away from the border. Other clients just
73 -- get shrinked in one direction.
76 g.width = g.width - 2 * useless_gap
77 g.x = g.x + useless_gap
79 g.width = g.width - useless_gap
84 g.height = g.height - 2 * useless_gap
85 g.y = g.y + useless_gap
87 g.height = g.height - useless_gap
90 -- End of useless gap.
103 --- Horizontal fair layout.
104 -- @param screen The screen to arrange.
105 uselessfair.horizontal = {}
106 uselessfair.horizontal.name = "uselessfairh"
107 function uselessfair.horizontal.arrange(p)
108 return fair(p, "east")
111 -- Vertical fair layout.
112 -- @param screen The screen to arrange.
113 uselessfair.name = "uselessfair"
114 function uselessfair.arrange(p)
115 return fair(p, "south")