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 -- get our orientation right.
37 wa.height = wa.height - ((global_border * 2) + (bw * 2))
38 wa.width = wa.width - ((global_border * 2) + (bw * 2))
41 local cells = math.ceil(math.sqrt(#cls))
42 local strips = math.ceil(#cls / cells)
46 for k, c in ipairs(cls) do
48 -- Save actual grid index for use in the useless_gap
52 if ( orientation == "east" and #cls > 2 )
53 or ( orientation == "south" and #cls <= 2 ) then
54 if #cls < (strips * cells) and strip == strips - 1 then
55 g.width = wa.width / (cells - ((strips * cells) - #cls))
57 g.width = wa.width / cells
59 g.height = wa.height / strips
64 g.x = wa.x + cell * g.width + global_border
65 g.y = wa.y + strip * g.height + global_border
68 if #cls < (strips * cells) and strip == strips - 1 then
69 g.height = wa.height / (cells - ((strips * cells) - #cls))
71 g.height = wa.height / cells
73 g.width = wa.width / strips
78 g.x = wa.x + strip * g.width + global_border
79 g.y = wa.y + cell * g.height + global_border
86 -- All clients tile evenly.
87 g.width = g.width - useless_gap
88 g.x = g.x + (useless_gap / 2)
89 g.height = g.height - useless_gap
90 g.y = g.y + (useless_gap / 2)
93 -- End of useless gap.
106 --- Horizontal fair layout.
107 -- @param screen The screen to arrange.
108 uselessfair.horizontal = {}
109 uselessfair.horizontal.name = "uselessfairh"
110 function uselessfair.horizontal.arrange(p)
111 return fair(p, "east")
114 -- Vertical fair layout.
115 -- @param screen The screen to arrange.
116 uselessfair.name = "uselessfair"
117 function uselessfair.arrange(p)
118 return fair(p, "south")