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
7 * (c) 2009 Donald Ephraim Curtis
8 * (c) 2008 Julien Danjolu
12 local naughty = require("naughty")
13 local tag = require("awful.tag")
14 local beautiful = require("beautiful")
16 local math = { floor = math.floor,
19 local tonumber = tonumber
21 local uselesstile = {}
23 local function tile_group(cls, wa, orientation, fact, group)
24 -- A useless gap (like the dwm patch) can be defined with
25 -- beautiful.useless_gap_width .
26 local useless_gap = tonumber(beautiful.useless_gap_width) or 0
27 if useless_gap < 0 then useless_gap = 0 end
29 -- A global border can be defined with
30 -- beautiful.global_border_width
31 global_border = tonumber(beautiful.global_border_width) or 0
32 if global_border < 0 then global_border = 0 end
34 -- BW!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
36 -- get our orientation right
37 local height = "height"
41 if orientation == "top" or orientation == "bottom" then
48 -- make this more generic (not just width)
50 available = wa[width] - (group.coord - wa[x]) -- it's truly not here
52 -- find our total values
55 local size = group.size
56 for c = group.first,group.last do
57 -- determine the width/height based on the size_hint
58 local i = c - group.first +1
59 local size_hints = cls[c].size_hints
60 local size_hint = size_hints["min_"..width] or size_hints["base_"..width] or 0
61 size_hint = size_hint + cls[c].border_width*2
62 size = math.max(size_hint, size)
64 -- calculate the height
68 min_fact = math.min(fact[i],min_fact)
70 total_fact = total_fact + fact[i]
72 size = math.min(size, (available - global_border))
76 local unused = wa[height] - (global_border * 2)
77 local stat_coord = wa[x]
79 for c = group.first,group.last do
80 local i = c - group.first +1
81 geom[width] = size - global_border
82 geom[height] = math.floor(unused * fact[i] / total_fact)
83 geom[x] = group.coord + global_border + (useless_gap / 2)
84 geom[y] = coord + global_border + (useless_gap / 2)
86 coord = coord + geom[height]
87 unused = unused - geom[height]
88 total_fact = total_fact - fact[i]
89 used_size = math.max(used_size, geom[width])
94 -- Top and left clients are shrinked by two steps and
95 -- get moved away from the border. Other clients just
96 -- get shrinked in one direction.
101 if geom[y] == wa[y] then
105 if geom[x] == 0 or geom[x] == wa[x] then
110 geom[height] = geom[height] - (2 * useless_gap)
111 geom[y] = geom[y] + useless_gap
113 geom[height] = geom[height] - useless_gap
117 geom[width] = geom[width] - (2 * useless_gap)
118 geom[x] = geom[x] + useless_gap
120 geom[width] = geom[width] - useless_gap
123 -- End of useless gap.
125 geom = cls[c]:geometry(geom)
131 local function tile(param, orientation)
132 local t = tag.selected(param.screen)
133 orientation = orientation or "right"
135 -- this handles are different orientations
136 local height = "height"
137 local width = "width"
140 if orientation == "top" or orientation == "bottom" then
147 -- A global border can be defined with
148 -- beautiful.global_border_width
149 global_border = tonumber(beautiful.global_border_width) or 0
150 if global_border < 0 then global_border = 0 end
152 local cls = param.clients
153 local nmaster = math.min(tag.getnmaster(t), #cls)
154 local nother = math.max(#cls - nmaster,0)
156 local mwfact = tag.getmwfact(t)
157 local wa = param.workarea
158 local ncol = tag.getncol(t)
160 local data = tag.getdata(t).windowfact
164 tag.getdata(t).windowfact = data
168 local place_master = true
169 if orientation == "left" or orientation == "top" then
170 -- if we are on the left or top we need to render the other windows first
174 -- this was easier than writing functions because there is a lot of data we need
176 if place_master and nmaster > 0 then
177 local size = wa[width]
179 size = math.min(wa[width] * mwfact, wa[width] - (coord - wa[x]))
184 coord = coord + tile_group(cls, wa, orientation, data[0], {first=1, last=nmaster, coord = coord, size = size})
187 if not place_master and nother > 0 then
190 -- we have to modify the work area size to consider left and top views
191 local wasize = wa[width]
192 if nmaster > 0 and (orientation == "left" or orientation == "top") then
193 wasize = wa[width] - wa[width]*mwfact
196 -- Try to get equal width among remaining columns
197 local size = math.min((wasize - (coord - wa[x])) / (ncol - i + 1)) --+ (global_border/(ncol))/(ncol+i^2)
198 local first = last + 1
199 last = last + math.floor((#cls - last)/(ncol - i + 1))
200 -- tile the column and update our current x coordinate
204 coord = coord + tile_group(cls, wa, orientation, data[i], { first = first, last = last, coord = coord, size = size })
207 place_master = not place_master
212 uselesstile.right = {}
213 uselesstile.right.name = "uselesstile"
214 uselesstile.right.arrange = tile
216 --- The main tile algo, on left.
217 -- @param screen The screen number to tile.
218 uselesstile.left = {}
219 uselesstile.left.name = "uselesstileleft"
220 function uselesstile.left.arrange(p)
221 return tile(p, "left")
224 --- The main tile algo, on bottom.
225 -- @param screen The screen number to tile.
226 uselesstile.bottom = {}
227 uselesstile.bottom.name = "uselesstilebottom"
228 function uselesstile.bottom.arrange(p)
229 return tile(p, "bottom")
232 --- The main tile algo, on top.
233 -- @param screen The screen number to tile.
235 uselesstile.top.name = "uselesstiletop"
236 function uselesstile.top.arrange(p)
237 return tile(p, "top")
240 uselesstile.arrange = uselesstile.right.arrange
241 uselesstile.name = uselesstile.right.name