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 gap_factor = (useless_gap / 100) * 2
93 if geom[y] == wa[y] then
97 if geom[x] == 0 or geom[x] == wa[x] then
102 geom[height] = geom[height] - (2 + gap_factor) * useless_gap
103 geom[y] = geom[y] + useless_gap
105 geom[height] = geom[height] - (1 + gap_factor) * useless_gap
109 geom[width] = geom[width] - (2 + gap_factor) * useless_gap
110 geom[x] = geom[x] + useless_gap
112 geom[width] = geom[width] - (1 + gap_factor) * useless_gap
115 -- End of useless gap.
117 geom = cls[c]:geometry(geom)
123 local function tile(param, orientation)
124 local t = tag.selected(param.screen)
125 orientation = orientation or "right"
127 -- this handles are different orientations
128 local height = "height"
129 local width = "width"
132 if orientation == "top" or orientation == "bottom" then
139 local cls = param.clients
140 local nmaster = math.min(tag.getnmaster(t), #cls)
141 local nother = math.max(#cls - nmaster,0)
143 local mwfact = tag.getmwfact(t)
144 local wa = param.workarea
145 local ncol = tag.getncol(t)
147 local data = tag.getdata(t).windowfact
151 tag.getdata(t).windowfact = data
155 local place_master = true
156 if orientation == "left" or orientation == "top" then
157 -- if we are on the left or top we need to render the other windows first
161 -- this was easier than writing functions because there is a lot of data we need
163 if place_master and nmaster > 0 then
164 local size = wa[width]
166 size = math.min(wa[width] * mwfact, wa[width] - (coord - wa[x]))
171 coord = coord + tile_group(cls, wa, orientation, data[0], {first=1, last=nmaster, coord = coord, size = size})
174 if not place_master and nother > 0 then
177 -- we have to modify the work area size to consider left and top views
178 local wasize = wa[width]
179 if nmaster > 0 and (orientation == "left" or orientation == "top") then
180 wasize = wa[width] - wa[width]*mwfact
183 -- Try to get equal width among remaining columns
184 local size = math.min( (wasize - (coord - wa[x])) / (ncol - i + 1) )
185 local first = last + 1
186 last = last + math.floor((#cls - last)/(ncol - i + 1))
187 -- tile the column and update our current x coordinate
191 coord = coord + tile_group(cls, wa, orientation, data[i], { first = first, last = last, coord = coord, size = size })
194 place_master = not place_master
199 uselesstile.right = {}
200 uselesstile.right.name = "uselesstile"
201 uselesstile.right.arrange = tile
203 --- The main tile algo, on left.
204 -- @param screen The screen number to tile.
205 uselesstile.left = {}
206 uselesstile.left.name = "uselesstileleft"
207 function uselesstile.left.arrange(p)
208 return tile(p, "left")
211 --- The main tile algo, on bottom.
212 -- @param screen The screen number to tile.
213 uselesstile.bottom = {}
214 uselesstile.bottom.name = "uselesstilebottom"
215 function uselesstile.bottom.arrange(p)
216 return tile(p, "bottom")
219 --- The main tile algo, on top.
220 -- @param screen The screen number to tile.
222 uselesstile.top.name = "uselesstiletop"
223 function uselesstile.top.arrange(p)
224 return tile(p, "top")
227 uselesstile.arrange = uselesstile.right.arrange
228 uselesstile.name = uselesstile.right.name