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) 2009 Donald Ephraim Curtis
7 * (c) 2008 Julien Danjolu
11 local tag = require("awful.tag")
12 local beautiful = require("beautiful")
14 local math = { floor = math.floor,
17 local tonumber = tonumber
19 local uselesstile = {}
21 local function tile_group(cls, wa, orientation, fact, group)
22 -- A useless gap (like the dwm patch) can be defined with
23 -- beautiful.useless_gap_width .
24 local useless_gap = tonumber(beautiful.useless_gap_width) or 0
26 -- get our orientation right
27 local height = "height"
31 if orientation == "top" or orientation == "bottom" then
38 -- make this more generic (not just width)
39 available = wa[width] - (group.coord - wa[x])
41 -- find our total values
44 local size = group.size
45 for c = group.first,group.last do
46 -- determine the width/height based on the size_hint
47 local i = c - group.first +1
48 local size_hints = cls[c].size_hints
49 local size_hint = size_hints["min_"..width] or size_hints["base_"..width] or 0
50 size_hint = size_hint + cls[c].border_width*2
51 size = math.max(size_hint, size)
53 -- calculate the height
57 min_fact = math.min(fact[i],min_fact)
59 total_fact = total_fact + fact[i]
61 size = math.min(size, available)
66 local unused = wa[height]
67 local stat_coord = wa[x]
69 for c = group.first,group.last do
70 local i = c - group.first +1
72 geom[height] = math.floor(unused * fact[i] / total_fact)
76 coord = coord + geom[height]
77 unused = unused - geom[height]
78 total_fact = total_fact - fact[i]
79 used_size = math.max(used_size, geom[width])
84 -- Top and left clients are shrinked by two steps and
85 -- get moved away from the border. Other clients just
86 -- get shrinked in one direction.
91 if geom[y] == wa[y] then
95 if geom[x] == 0 or geom[x] == wa[x] then
100 geom[height] = geom[height] - 2 * useless_gap
101 geom[y] = geom[y] + useless_gap
103 geom[height] = geom[height] - useless_gap
107 geom[width] = geom[width] - 2 * useless_gap
108 geom[x] = geom[x] + useless_gap
110 geom[width] = geom[width] - useless_gap
113 -- End of useless gap.
115 geom = cls[c]:geometry(geom)
121 local function tile(param, orientation)
122 local t = tag.selected(param.screen)
123 orientation = orientation or "right"
125 -- this handles are different orientations
126 local height = "height"
127 local width = "width"
130 if orientation == "top" or orientation == "bottom" then
137 local cls = param.clients
138 local nmaster = math.min(tag.getnmaster(t), #cls)
139 local nother = math.max(#cls - nmaster,0)
141 local mwfact = tag.getmwfact(t)
142 local wa = param.workarea
143 local ncol = tag.getncol(t)
145 local data = tag.getdata(t).windowfact
149 tag.getdata(t).windowfact = data
153 local place_master = true
154 if orientation == "left" or orientation == "top" then
155 -- if we are on the left or top we need to render the other windows first
159 -- this was easier than writing functions because there is a lot of data we need
161 if place_master and nmaster > 0 then
162 local size = wa[width]
164 size = math.min(wa[width] * mwfact, wa[width] - (coord - wa[x]))
169 coord = coord + tile_group(cls, wa, orientation, data[0], {first=1, last=nmaster, coord = coord, size = size})
172 if not place_master and nother > 0 then
175 -- we have to modify the work area size to consider left and top views
176 local wasize = wa[width]
177 if nmaster > 0 and (orientation == "left" or orientation == "top") then
178 wasize = wa[width] - wa[width]*mwfact
181 -- Try to get equal width among remaining columns
182 local size = math.min( (wasize - (coord - wa[x])) / (ncol - i + 1) )
183 local first = last + 1
184 last = last + math.floor((#cls - last)/(ncol - i + 1))
185 -- tile the column and update our current x coordinate
189 coord = coord + tile_group(cls, wa, orientation, data[i], { first = first, last = last, coord = coord, size = size })
192 place_master = not place_master
197 uselesstile.right = {}
198 uselesstile.right.name = "uselesstile"
199 uselesstile.right.arrange = tile
201 --- The main tile algo, on left.
202 -- @param screen The screen number to tile.
203 uselesstile.left = {}
204 uselesstile.left.name = "uselesstileleft"
205 function uselesstile.left.arrange(p)
206 return tile(p, "left")
209 --- The main tile algo, on bottom.
210 -- @param screen The screen number to tile.
211 uselesstile.bottom = {}
212 uselesstile.bottom.name = "uselesstilebottom"
213 function uselesstile.bottom.arrange(p)
214 return tile(p, "bottom")
217 --- The main tile algo, on top.
218 -- @param screen The screen number to tile.
220 uselesstile.top.name = "uselesstiletop"
221 function uselesstile.top.arrange(p)
222 return tile(p, "top")
225 uselesstile.arrange = uselesstile.right.arrange
226 uselesstile.name = uselesstile.right.name