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 tag = require("awful.tag")
13 local beautiful = require("beautiful")
15 local math = { floor = math.floor,
18 local tonumber = tonumber
20 local uselesstile = {}
22 local function tile_group(cls, wa, orientation, fact, group)
23 -- A useless gap (like the dwm patch) can be defined with
24 -- beautiful.useless_gap_width .
25 local useless_gap = tonumber(beautiful.useless_gap_width) or 0
26 if useless_gap < 0 then useless_gap = 0 end
28 -- A global border can be defined with
29 -- beautiful.global_border_width
30 local global_border = tonumber(beautiful.global_border_width) or 0
31 if global_border < 0 then global_border = 0 end
33 -- Themes border width requires an offset
34 local bw = tonumber(beautiful.border_width) or 0
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 - (bw * 2)
82 geom[height] = math.floor(unused * fact[i] / total_fact) - (bw * 2)
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 local cls = param.clients
148 local nmaster = math.min(tag.getnmaster(t), #cls)
149 local nother = math.max(#cls - nmaster,0)
151 local mwfact = tag.getmwfact(t)
152 local wa = param.workarea
153 local ncol = tag.getncol(t)
155 local data = tag.getdata(t).windowfact
159 tag.getdata(t).windowfact = data
163 local place_master = true
164 if orientation == "left" or orientation == "top" then
165 -- if we are on the left or top we need to render the other windows first
169 -- this was easier than writing functions because there is a lot of data we need
171 if place_master and nmaster > 0 then
172 local size = wa[width]
174 size = math.min(wa[width] * mwfact, wa[width] - (coord - wa[x]))
179 coord = coord + tile_group(cls, wa, orientation, data[0], {first=1, last=nmaster, coord = coord, size = size})
182 if not place_master and nother > 0 then
185 -- we have to modify the work area size to consider left and top views
186 local wasize = wa[width]
187 if nmaster > 0 and (orientation == "left" or orientation == "top") then
188 wasize = wa[width] - wa[width]*mwfact
191 -- Try to get equal width among remaining columns
192 local size = math.min((wasize - (coord - wa[x])) / (ncol - i + 1)) --+ (global_border/(ncol))/(ncol+i^2)
193 local first = last + 1
194 last = last + math.floor((#cls - last)/(ncol - i + 1))
195 -- tile the column and update our current x coordinate
199 coord = coord + tile_group(cls, wa, orientation, data[i], { first = first, last = last, coord = coord, size = size })
202 place_master = not place_master
207 uselesstile.right = {}
208 uselesstile.right.name = "uselesstile"
209 uselesstile.right.arrange = tile
211 --- The main tile algo, on left.
212 -- @param screen The screen number to tile.
213 uselesstile.left = {}
214 uselesstile.left.name = "uselesstileleft"
215 function uselesstile.left.arrange(p)
216 return tile(p, "left")
219 --- The main tile algo, on bottom.
220 -- @param screen The screen number to tile.
221 uselesstile.bottom = {}
222 uselesstile.bottom.name = "uselesstilebottom"
223 function uselesstile.bottom.arrange(p)
224 return tile(p, "bottom")
227 --- The main tile algo, on top.
228 -- @param screen The screen number to tile.
230 uselesstile.top.name = "uselesstiletop"
231 function uselesstile.top.arrange(p)
232 return tile(p, "top")
235 uselesstile.arrange = uselesstile.right.arrange
236 uselesstile.name = uselesstile.right.name