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) 2016, Henrik Antonsson
6 * (c) 2015, Joerg Jaspert
8 * (c) 2013, Luke Bonham
9 * (c) 2010-2012, Peter Hofmann
13 local floor = math.floor
18 horizontal = { name = "centerworkh" }
21 local function do_centerwork(p, orientation)
22 local t = p.tag or screen[p.screen].selected_tag
26 if #cls == 0 then return end
31 -- Main column, fixed width and height.
32 local mwfact = t.master_width_factor
33 local mainhei = floor(wa.height * mwfact)
34 local mainwid = floor(wa.width * mwfact)
35 local slavewid = wa.width - mainwid
36 local slaveLwid = floor(slavewid / 2)
37 local slaveRwid = slavewid - slaveLwid
38 local slavehei = wa.height - mainhei
39 local slaveThei = floor(slavehei / 2)
40 local slaveBhei = slavehei - slaveThei
41 local nbrFirstSlaves = floor(#cls / 2)
42 local nbrSecondSlaves = floor((#cls - 1) / 2)
44 local slaveFirstDim, slaveSecondDim = 0, 0
46 if orientation == "vertical" then
47 if nbrFirstSlaves > 0 then slaveFirstDim = floor(wa.height / nbrFirstSlaves) end
48 if nbrSecondSlaves > 0 then slaveSecondDim = floor(wa.height / nbrSecondSlaves) end
53 g.x = wa.x + slaveLwid
56 if nbrFirstSlaves > 0 then slaveFirstDim = floor(wa.width / nbrFirstSlaves) end
57 if nbrSecondSlaves > 0 then slaveSecondDim = floor(wa.width / nbrSecondSlaves) end
63 g.y = wa.y + slaveThei
66 if g.width < 1 then g.width = 1 end
67 if g.height < 1 then g.height = 1 end
72 if #cls <= 1 then return end
77 local rowIndex = floor(i/2)
79 if orientation == "vertical" then
83 g.y = wa.y + (rowIndex-1)*slaveFirstDim
87 -- if last slave in left row use remaining space for that slave
88 if rowIndex == nbrFirstSlaves then
89 g.height = wa.y + wa.height - g.y
91 g.height = slaveFirstDim
95 g.x = wa.x + slaveLwid + mainwid
96 g.y = wa.y + (rowIndex-1)*slaveSecondDim
100 -- if last slave in right row use remaining space for that slave
101 if rowIndex == nbrSecondSlaves then
102 g.height = wa.y + wa.height - g.y
104 g.height = slaveSecondDim
110 g.x = wa.x + (rowIndex-1)*slaveFirstDim
115 -- if last slave in top row use remaining space for that slave
116 if rowIndex == nbrFirstSlaves then
117 g.width = wa.x + wa.width - g.x
119 g.width = slaveFirstDim
123 g.x = wa.x + (rowIndex-1)*slaveSecondDim
124 g.y = wa.y + slaveThei + mainhei
128 -- if last slave in bottom row use remaining space for that slave
129 if rowIndex == nbrSecondSlaves then
130 g.width = wa.x + wa.width - g.x
132 g.width = slaveSecondDim
138 if g.width < 1 then g.width = 1 end
139 if g.height < 1 then g.height = 1 end
146 function centerwork.horizontal.arrange(p)
147 return do_centerwork(p, "horizontal")
150 function centerwork.arrange(p)
151 return do_centerwork(p, "vertical")