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 local global_border = tonumber(beautiful.global_border_width) or 0
32 if global_border < 0 then global_border = 0 end
34 -- Themes border width requires an offset
35 local bw = tonumber(beautiful.border_width) or 0
37 -- get our orientation right
38 local height = "height"
42 if orientation == "top" or orientation == "bottom" then
49 -- make this more generic (not just width)
51 available = wa[width] - (group.coord - wa[x]) -- it's truly not here
53 -- find our total values
56 local size = group.size
57 for c = group.first,group.last do
58 -- determine the width/height based on the size_hint
59 local i = c - group.first +1
60 local size_hints = cls[c].size_hints
61 local size_hint = size_hints["min_"..width] or size_hints["base_"..width] or 0
62 size_hint = size_hint + cls[c].border_width*2
63 size = math.max(size_hint, size)
65 -- calculate the height
69 min_fact = math.min(fact[i],min_fact)
71 total_fact = total_fact + fact[i]
73 size = math.min(size, (available - global_border))
77 local unused = wa[height] - (global_border * 2)
78 local stat_coord = wa[x]
80 for c = group.first,group.last do
81 local i = c - group.first +1
82 geom[width] = size - global_border - (bw * 2)
83 geom[height] = math.floor(unused * fact[i] / total_fact) - (bw * 2)
84 geom[x] = group.coord + global_border + (useless_gap / 2)
85 geom[y] = coord + global_border + (useless_gap / 2)
87 coord = coord + geom[height]
88 unused = unused - geom[height]
89 total_fact = total_fact - fact[i]
90 used_size = math.max(used_size, geom[width])
95 -- Top and left clients are shrinked by two steps and
96 -- get moved away from the border. Other clients just
97 -- get shrinked in one direction.
102 if geom[y] == wa[y] then
106 if geom[x] == 0 or geom[x] == wa[x] then
111 geom[height] = geom[height] - (2 * useless_gap)
112 geom[y] = geom[y] + useless_gap
114 geom[height] = geom[height] - useless_gap
118 geom[width] = geom[width] - (2 * useless_gap)
119 geom[x] = geom[x] + useless_gap
121 geom[width] = geom[width] - useless_gap
124 -- End of useless gap.
126 geom = cls[c]:geometry(geom)
132 local function tile(param, orientation)
133 local t = tag.selected(param.screen)
134 orientation = orientation or "right"
136 -- this handles are different orientations
137 local height = "height"
138 local width = "width"
141 if orientation == "top" or orientation == "bottom" then
148 local cls = param.clients
149 local nmaster = math.min(tag.getnmaster(t), #cls)
150 local nother = math.max(#cls - nmaster,0)
152 local mwfact = tag.getmwfact(t)
153 local wa = param.workarea
154 local ncol = tag.getncol(t)
156 local data = tag.getdata(t).windowfact
160 tag.getdata(t).windowfact = data
164 local place_master = true
165 if orientation == "left" or orientation == "top" then
166 -- if we are on the left or top we need to render the other windows first
170 -- this was easier than writing functions because there is a lot of data we need
172 if place_master and nmaster > 0 then
173 local size = wa[width]
175 size = math.min(wa[width] * mwfact, wa[width] - (coord - wa[x]))
180 coord = coord + tile_group(cls, wa, orientation, data[0], {first=1, last=nmaster, coord = coord, size = size})
183 if not place_master and nother > 0 then
186 -- we have to modify the work area size to consider left and top views
187 local wasize = wa[width]
188 if nmaster > 0 and (orientation == "left" or orientation == "top") then
189 wasize = wa[width] - wa[width]*mwfact
192 -- Try to get equal width among remaining columns
193 local size = math.min((wasize - (coord - wa[x])) / (ncol - i + 1)) --+ (global_border/(ncol))/(ncol+i^2)
194 local first = last + 1
195 last = last + math.floor((#cls - last)/(ncol - i + 1))
196 -- tile the column and update our current x coordinate
200 coord = coord + tile_group(cls, wa, orientation, data[i], { first = first, last = last, coord = coord, size = size })
203 place_master = not place_master
208 uselesstile.right = {}
209 uselesstile.right.name = "uselesstile"
210 uselesstile.right.arrange = tile
212 --- The main tile algo, on left.
213 -- @param screen The screen number to tile.
214 uselesstile.left = {}
215 uselesstile.left.name = "uselesstileleft"
216 function uselesstile.left.arrange(p)
217 return tile(p, "left")
220 --- The main tile algo, on bottom.
221 -- @param screen The screen number to tile.
222 uselesstile.bottom = {}
223 uselesstile.bottom.name = "uselesstilebottom"
224 function uselesstile.bottom.arrange(p)
225 return tile(p, "bottom")
228 --- The main tile algo, on top.
229 -- @param screen The screen number to tile.
231 uselesstile.top.name = "uselesstiletop"
232 function uselesstile.top.arrange(p)
233 return tile(p, "top")
236 uselesstile.arrange = uselesstile.right.arrange
237 uselesstile.name = uselesstile.right.name