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)
30 -- get our orientation right
31 local height = "height"
35 if orientation == "top" or orientation == "bottom" then
42 -- make this more generic (not just width)
43 available = wa[width] - (group.coord - wa[x])
45 -- find our total values
48 local size = group.size
49 for c = group.first,group.last do
50 -- determine the width/height based on the size_hint
51 local i = c - group.first +1
52 local size_hints = cls[c].size_hints
53 local size_hint = size_hints["min_"..width] or size_hints["base_"..width] or 0
54 size_hint = size_hint + cls[c].border_width*2
55 size = math.max(size_hint, size)
57 -- calculate the height
61 min_fact = math.min(fact[i],min_fact)
63 total_fact = total_fact + fact[i]
65 size = math.min(size, available)
70 local unused = wa[height]
71 local stat_coord = wa[x]
73 for c = group.first,group.last do
74 local i = c - group.first +1
76 geom[height] = math.floor(unused * fact[i] / total_fact)
80 coord = coord + geom[height]
81 unused = unused - geom[height]
82 total_fact = total_fact - fact[i]
83 used_size = math.max(used_size, geom[width])
88 -- Top and left clients are shrinked by two steps and
89 -- get moved away from the border. Other clients just
90 -- get shrinked in one direction.
95 if geom[y] == wa[y] then
99 if geom[x] == 0 or geom[x] == wa[x] then
104 geom[height] = geom[height] - 2 * useless_gap
105 geom[y] = geom[y] + useless_gap
107 geom[height] = geom[height] - useless_gap
111 geom[width] = geom[width] - 2 * useless_gap
112 geom[x] = geom[x] + useless_gap
114 geom[width] = geom[width] - useless_gap
117 -- End of useless gap.
119 geom = cls[c]:geometry(geom)
125 local function tile(param, orientation)
126 local t = tag.selected(param.screen)
127 orientation = orientation or "right"
129 -- this handles are different orientations
130 local height = "height"
131 local width = "width"
134 if orientation == "top" or orientation == "bottom" then
141 local cls = param.clients
142 local nmaster = math.min(tag.getnmaster(t), #cls)
143 local nother = math.max(#cls - nmaster,0)
145 local mwfact = tag.getmwfact(t)
146 local wa = param.workarea
147 local ncol = tag.getncol(t)
149 local data = tag.getdata(t).windowfact
153 tag.getdata(t).windowfact = data
157 local place_master = true
158 if orientation == "left" or orientation == "top" then
159 -- if we are on the left or top we need to render the other windows first
163 -- this was easier than writing functions because there is a lot of data we need
165 if place_master and nmaster > 0 then
166 local size = wa[width]
168 size = math.min(wa[width] * mwfact, wa[width] - (coord - wa[x]))
173 coord = coord + tile_group(cls, wa, orientation, data[0], {first=1, last=nmaster, coord = coord, size = size})
176 if not place_master and nother > 0 then
179 -- we have to modify the work area size to consider left and top views
180 local wasize = wa[width]
181 if nmaster > 0 and (orientation == "left" or orientation == "top") then
182 wasize = wa[width] - wa[width]*mwfact
185 -- Try to get equal width among remaining columns
186 local size = math.min( (wasize - (coord - wa[x])) / (ncol - i + 1) )
187 local first = last + 1
188 last = last + math.floor((#cls - last)/(ncol - i + 1))
189 -- tile the column and update our current x coordinate
193 coord = coord + tile_group(cls, wa, orientation, data[i], { first = first, last = last, coord = coord, size = size })
196 place_master = not place_master
201 uselesstile.right = {}
202 uselesstile.right.name = "uselesstile"
203 uselesstile.right.arrange = tile
205 --- The main tile algo, on left.
206 -- @param screen The screen number to tile.
207 uselesstile.left = {}
208 uselesstile.left.name = "uselesstileleft"
209 function uselesstile.left.arrange(p)
210 return tile(p, "left")
213 --- The main tile algo, on bottom.
214 -- @param screen The screen number to tile.
215 uselesstile.bottom = {}
216 uselesstile.bottom.name = "uselesstilebottom"
217 function uselesstile.bottom.arrange(p)
218 return tile(p, "bottom")
221 --- The main tile algo, on top.
222 -- @param screen The screen number to tile.
224 uselesstile.top.name = "uselesstiletop"
225 function uselesstile.top.arrange(p)
226 return tile(p, "top")
229 uselesstile.arrange = uselesstile.right.arrange
230 uselesstile.name = uselesstile.right.name