mirror of https://github.com/lcpz/lain.git
Vertical client resizing fix
This commit is contained in:
parent
7f203ab08d
commit
d93913253e
|
@ -35,19 +35,18 @@ local function swap(geometry)
|
||||||
return { x = geometry.y, y = geometry.x, width = geometry.height, height = geometry.width }
|
return { x = geometry.y, y = geometry.x, width = geometry.height, height = geometry.width }
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Find geometry for column/row tiling
|
-- Find geometry for secondary windows column
|
||||||
local function cut_area(wa, total, index, is_horizontal)
|
local function cut_column(wa, n, index)
|
||||||
local wa = is_horizontal and swap(wa) or wa
|
local width = wa.width / n
|
||||||
local height = wa.height / total
|
local area = { x = wa.x + (index - 1) * width, y = wa.y, width = width, height = wa.height }
|
||||||
|
|
||||||
local area = {
|
return area
|
||||||
x = wa.x,
|
end
|
||||||
y = wa.y + (index - 1) * height,
|
|
||||||
width = wa.width,
|
|
||||||
height = height
|
|
||||||
}
|
|
||||||
|
|
||||||
if is_horizontal then area = swap(area) end
|
-- Find geometry for certain window in column
|
||||||
|
local function cut_row(wa, factor, index, used)
|
||||||
|
local height = wa.height * factor.window[index] / factor.total
|
||||||
|
local area = { x = wa.x, y = wa.y + used, width = wa.width, height = height }
|
||||||
|
|
||||||
return area
|
return area
|
||||||
end
|
end
|
||||||
|
@ -60,11 +59,33 @@ local function size_correction(c, geometry, useless_gap)
|
||||||
geometry.y = geometry.y + useless_gap / 2
|
geometry.y = geometry.y + useless_gap / 2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Check size factor for group of clients and calculate total
|
||||||
|
local function calc_factor(n, winfactors)
|
||||||
|
local factor = { window = winfactors, total = 0, min = 1 }
|
||||||
|
|
||||||
|
for i = 1, n do
|
||||||
|
if not factor.window[i] then
|
||||||
|
factor.window[i] = factor.min
|
||||||
|
else
|
||||||
|
factor.min = math.min(factor.window[i], factor.min)
|
||||||
|
if factor.window[i] < 0.05 then factor.window[i] = 0.05 end
|
||||||
|
end
|
||||||
|
factor.total = factor.total + factor.window[i]
|
||||||
|
end
|
||||||
|
|
||||||
|
return factor
|
||||||
|
end
|
||||||
|
|
||||||
-- Tile group of clients in given area
|
-- Tile group of clients in given area
|
||||||
-- @canvas need for proper transformation only
|
-- @canvas need for proper transformation only
|
||||||
local function tile_column(canvas, area, list, useless_gap, transformation)
|
-- @winfactors table with clients size factors
|
||||||
|
local function tile_column(canvas, area, list, useless_gap, transformation, winfactors)
|
||||||
|
local used = 0
|
||||||
|
local factor = calc_factor(#list, winfactors)
|
||||||
|
|
||||||
for i, c in ipairs(list) do
|
for i, c in ipairs(list) do
|
||||||
local g = cut_area(area, #list, i)
|
local g = cut_row(area, factor, i, used)
|
||||||
|
used = used + g.height
|
||||||
|
|
||||||
-- swap workarea dimensions
|
-- swap workarea dimensions
|
||||||
if transformation.flip then g = flip(canvas, g) end
|
if transformation.flip then g = flip(canvas, g) end
|
||||||
|
@ -102,6 +123,14 @@ local function tile(p, orientation)
|
||||||
mwfact = 1
|
mwfact = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- clients size factor
|
||||||
|
local data = tag.getdata(t).windowfact
|
||||||
|
|
||||||
|
if not data then
|
||||||
|
data = {}
|
||||||
|
tag.getdata(t).windowfact = data
|
||||||
|
end
|
||||||
|
|
||||||
-- Workarea size correction depending on useless gap and global border
|
-- Workarea size correction depending on useless gap and global border
|
||||||
wa.height = wa.height - 2 * global_border - useless_gap
|
wa.height = wa.height - 2 * global_border - useless_gap
|
||||||
wa.width = wa.width - 2 * global_border - useless_gap
|
wa.width = wa.width - 2 * global_border - useless_gap
|
||||||
|
@ -136,7 +165,8 @@ local function tile(p, orientation)
|
||||||
height = wa.height
|
height = wa.height
|
||||||
}
|
}
|
||||||
|
|
||||||
tile_column(wa, master_area, cls_master, useless_gap, transformation)
|
if not data[0] then data[0] = {} end
|
||||||
|
tile_column(wa, master_area, cls_master, useless_gap, transformation, data[0])
|
||||||
|
|
||||||
-- Tile other windows
|
-- Tile other windows
|
||||||
local other_area = {
|
local other_area = {
|
||||||
|
@ -165,8 +195,10 @@ local function tile(p, orientation)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- and tile
|
-- and tile
|
||||||
local column_area = cut_area(other_area, ncol, position, true)
|
local column_area = cut_column(other_area, ncol, position)
|
||||||
tile_column(wa, column_area, column, useless_gap, transformation)
|
|
||||||
|
if not data[i] then data[i] = {} end
|
||||||
|
tile_column(wa, column_area, column, useless_gap, transformation, data[i])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue