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, gap)
24 -- Themes border width requires an offset
25 local bw = tonumber(beautiful.border_width) or 0
27 -- get our orientation right
28 local height = "height"
32 if orientation == "top" or orientation == "bottom" then
39 -- make this more generic (not just width)
41 available = wa[width] - (group.coord - wa[x]) -- it's truly not here
43 -- find our total values
46 local size = group.size
47 for c = group.first,group.last do
48 -- determine the width/height based on the size_hint
49 local i = c - group.first +1
50 local size_hints = cls[c].size_hints
51 local size_hint = size_hints["min_"..width] or size_hints["base_"..width] or 0
52 size_hint = size_hint + cls[c].border_width*2
53 size = math.max(size_hint, size)
55 -- calculate the height
59 min_fact = math.min(fact[i],min_fact)
61 total_fact = total_fact + fact[i]
63 size = math.min(size, available)
67 local unused = wa[height]
68 local stat_coord = wa[x]
70 for c = group.first,group.last do
71 local i = c - group.first +1
72 geom[width] = size - (bw * 2)
73 geom[height] = math.floor(unused * fact[i] / total_fact) - (bw * 2)
77 coord = coord + geom[height] + 2 * bw
78 unused = unused - geom[height] - 2 * bw
79 total_fact = total_fact - fact[i]
80 used_size = math.max(used_size, geom[width] + 2 * bw)
82 -- Useless gap correction
83 geom.width = geom.width - gap
84 geom.height = geom.height - gap
86 geom = cls[c]:geometry(geom)
92 local function tile(param, orientation)
93 local t = tag.selected(param.screen)
94 orientation = orientation or "right"
96 -- A useless gap (like the dwm patch) can be defined with
97 -- beautiful.useless_gap_width .
98 local useless_gap = tonumber(beautiful.useless_gap_width) or 0
99 if useless_gap < 0 then useless_gap = 0 end
101 -- A global border can be defined with
102 -- beautiful.global_border_width
103 local global_border = tonumber(beautiful.global_border_width) or 0
104 if global_border < 0 then global_border = 0 end
106 -- this handles are different orientations
107 local height = "height"
108 local width = "width"
111 if orientation == "top" or orientation == "bottom" then
118 local cls = param.clients
119 local nmaster = math.min(tag.getnmaster(t), #cls)
120 local nother = math.max(#cls - nmaster,0)
122 local mwfact = tag.getmwfact(t)
123 local wa = param.workarea
124 local ncol = tag.getncol(t)
126 -- Workarea size correction
127 wa.height = wa.height - 2 * global_border - useless_gap
128 wa.width = wa.width - 2 * global_border - useless_gap
129 wa.x = wa.x + useless_gap + global_border
130 wa.y = wa.y + useless_gap + global_border
132 local data = tag.getdata(t).windowfact
136 tag.getdata(t).windowfact = data
140 local place_master = true
141 if orientation == "left" or orientation == "top" then
142 -- if we are on the left or top we need to render the other windows first
146 -- this was easier than writing functions because there is a lot of data we need
148 if place_master and nmaster > 0 then
149 local size = wa[width]
151 size = math.min(wa[width] * mwfact, wa[width] - (coord - wa[x]))
156 coord = coord + tile_group(cls, wa, orientation, data[0], {first=1, last=nmaster, coord = coord, size = size}, useless_gap)
159 if not place_master and nother > 0 then
162 -- we have to modify the work area size to consider left and top views
163 local wasize = wa[width]
164 if nmaster > 0 and (orientation == "left" or orientation == "top") then
165 wasize = wa[width] - wa[width]*mwfact
168 -- Try to get equal width among remaining columns
169 local size = math.min((wasize - (coord - wa[x])) / (ncol - i + 1)) --+ (global_border/(ncol))/(ncol+i^2)
170 local first = last + 1
171 last = last + math.floor((#cls - last)/(ncol - i + 1))
172 -- tile the column and update our current x coordinate
176 coord = coord + tile_group(cls, wa, orientation, data[i], { first = first, last = last, coord = coord, size = size }, useless_gap)
179 place_master = not place_master
184 uselesstile.right = {}
185 uselesstile.right.name = "uselesstile"
186 uselesstile.right.arrange = tile
188 --- The main tile algo, on left.
189 -- @param screen The screen number to tile.
190 uselesstile.left = {}
191 uselesstile.left.name = "uselesstileleft"
192 function uselesstile.left.arrange(p)
193 return tile(p, "left")
196 --- The main tile algo, on bottom.
197 -- @param screen The screen number to tile.
198 uselesstile.bottom = {}
199 uselesstile.bottom.name = "uselesstilebottom"
200 function uselesstile.bottom.arrange(p)
201 return tile(p, "bottom")
204 --- The main tile algo, on top.
205 -- @param screen The screen number to tile.
207 uselesstile.top.name = "uselesstiletop"
208 function uselesstile.top.arrange(p)
209 return tile(p, "top")
212 uselesstile.arrange = uselesstile.right.arrange
213 uselesstile.name = uselesstile.right.name