- -- make this more generic (not just width)
- available = wa[width] - (group.coord - wa[x])
-
- -- find our total values
- local total_fact = 0
- local min_fact = 1
- local size = group.size
- for c = group.first,group.last do
- -- determine the width/height based on the size_hint
- local i = c - group.first +1
- local size_hints = cls[c].size_hints
- local size_hint = size_hints["min_"..width] or size_hints["base_"..width] or 0
- size_hint = size_hint + cls[c].border_width*2
- size = math.max(size_hint, size)
-
- -- calculate the height
- if not fact[i] then
- fact[i] = min_fact
- else
- min_fact = math.min(fact[i],min_fact)
- end
- total_fact = total_fact + fact[i]
- end
- size = math.min(size, available)
-
- local coord = wa[y]
- local geom = {}
- local used_size = 0
- local unused = wa[height]
- local stat_coord = wa[x]
- --stat_coord = size
- for c = group.first,group.last do
- local i = c - group.first +1
- geom[width] = size
- geom[height] = math.floor(unused * fact[i] / total_fact)
- geom[x] = group.coord
- geom[y] = coord
-
- coord = coord + geom[height]
- unused = unused - geom[height]
- total_fact = total_fact - fact[i]
- used_size = math.max(used_size, geom[width])
-
- -- Useless gap
- if useless_gap > 0
- then
- -- Top and left clients are shrinked by two steps and
- -- get moved away from the border. Other clients just
- -- get shrinked in one direction.
-
- top = false
- left = false
-
- gap_factor = (useless_gap / 100) * 2
-
- if geom[y] == wa[y] then
- top = true
- end
-
- if geom[x] == 0 or geom[x] == wa[x] then
- left = true
- end
-
- if top then
- geom[height] = geom[height] - (2 + gap_factor) * useless_gap
- geom[y] = geom[y] + useless_gap
- else
- geom[height] = geom[height] - (1 + gap_factor) * useless_gap
- end
-
- if left then
- geom[width] = geom[width] - (2 + gap_factor) * useless_gap
- geom[x] = geom[x] + useless_gap
- else
- geom[width] = geom[width] - (1 + gap_factor) * useless_gap
- end
- end
- -- End of useless gap.