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
6 * (c) 2013, Luke Bonham
7 * (c) 2012, Josh Komoroske
8 * (c) 2010-2012, Peter Hofmann
12 local beautiful = require("beautiful")
14 local math = { ceil = math.ceil, sqrt = math.sqrt }
15 local tonumber = tonumber
17 local uselessfair = {}
19 local function fair(p, orientation)
20 -- A useless gap (like the dwm patch) can be defined with
21 -- beautiful.useless_gap_width.
22 local useless_gap = tonumber(beautiful.useless_gap_width) or 0
23 if useless_gap < 0 then useless_gap = 0 end
25 -- A global border can be defined with
26 -- beautiful.global_border_width.
27 local global_border = tonumber(beautiful.global_border_width) or 0
28 if global_border < 0 then global_border = 0 end
30 -- Themes border width requires an offset.
31 local bw = tonumber(beautiful.border_width) or 0
33 -- Total window size extend
34 local ext = 2 * bw + useless_gap
36 -- get our orientation right.
40 wa.height = wa.height - 2 * global_border - useless_gap
41 wa.width = wa.width - 2 * global_border - useless_gap
42 wa.x = wa.x + useless_gap + global_border
43 wa.y = wa.y + useless_gap + global_border
46 local cells = math.ceil(math.sqrt(#cls))
47 local strips = math.ceil(#cls / cells)
51 for k, c in ipairs(cls) do
54 if ( orientation == "east" and #cls > 2 )
55 or ( orientation == "south" and #cls <= 2 ) then
56 if #cls < (strips * cells) and strip == strips - 1 then
57 g.width = wa.width / (cells - ((strips * cells) - #cls))
59 g.width = wa.width / cells
61 g.height = wa.height / strips
63 g.x = wa.x + cell * g.width
64 g.y = wa.y + strip * g.height
67 if #cls < (strips * cells) and strip == strips - 1 then
68 g.height = wa.height / (cells - ((strips * cells) - #cls))
70 g.height = wa.height / cells
72 g.width = wa.width / strips
74 g.x = wa.x + strip * g.width
75 g.y = wa.y + cell * g.height
79 g.width = g.width - ext
80 g.height = g.height - ext
93 --- Horizontal fair layout.
94 -- @param screen The screen to arrange.
95 uselessfair.horizontal = {}
96 uselessfair.horizontal.name = "uselessfairh"
97 function uselessfair.horizontal.arrange(p)
98 return fair(p, "east")
101 -- Vertical fair layout.
102 -- @param screen The screen to arrange.
103 uselessfair.name = "uselessfair"
104 function uselessfair.arrange(p)
105 return fair(p, "south")