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
7 * (c) 2013, Luke Bonham
8 * (c) 2010-2012, Peter Hofmann
10 Based on centerwork.lua
13 local awful = require("awful")
14 local beautiful = require("beautiful")
15 local tonumber = tonumber
16 local math = { floor = math.floor }
23 function centerworkd.arrange(p)
24 -- A useless gap (like the dwm patch) can be defined with
25 -- beautiful.useless_gap_width .
26 local useless_gap = tonumber(beautiful.useless_gap_width) or 0
28 -- A global border can be defined with
29 -- beautiful.global_border_width
30 local global_border = tonumber(beautiful.global_border_width) or 0
31 if global_border < 0 then global_border = 0 end
37 -- Borders are factored in.
38 wa.height = wa.height - (global_border * 2)
39 wa.width = wa.width - (global_border * 2)
40 wa.x = wa.x + global_border
41 wa.y = wa.y + global_border
43 -- Width of main column?
44 local t = awful.tag.selected(p.screen)
45 local mwfact = awful.tag.getmwfact(t)
49 -- Main column, fixed width and height.
52 local mainwid = math.floor(wa.width * mwfact)
53 local slavewid = wa.width - mainwid
54 local slaveLwid = math.floor(slavewid / 2)
55 local slaveRwid = slavewid - slaveLwid
56 local nbrLeftSlaves = math.floor(#cls / 2)
57 local nbrRightSlaves = math.floor((#cls - 1) / 2)
59 local slaveLeftHeight = 0
60 if nbrLeftSlaves > 0 then slaveLeftHeight = math.floor(wa.height / nbrLeftSlaves) end
61 if nbrRightSlaves > 0 then slaveRightHeight = math.floor(wa.height / nbrRightSlaves) end
63 g.height = wa.height - 2*useless_gap - 2*c.border_width
64 g.width = mainwid - 2*c.border_width
65 g.x = wa.x + slaveLwid
66 g.y = wa.y + useless_gap
68 if g.width < 1 then g.width = 1 end
69 if g.height < 1 then g.height = 1 end
80 local rowIndex = math.floor(i/2)
82 -- If i is even it should be placed on the left side
86 g.x = wa.x + useless_gap
87 g.y = wa.y + useless_gap + (rowIndex-1)*slaveLeftHeight
89 g.width = slaveLwid - 2*useless_gap - 2*c.border_width
91 -- if last slave in left row use remaining space for that slave
92 if rowIndex == nbrLeftSlaves
94 g.height = wa.y + wa.height - g.y - useless_gap - 2*c.border_width
96 g.height = slaveLeftHeight - useless_gap - 2*c.border_width
100 g.x = wa.x + slaveLwid + mainwid + useless_gap
101 g.y = wa.y + useless_gap + (rowIndex-1)*slaveRightHeight
103 g.width = slaveRwid - 2*useless_gap - 2*c.border_width
105 -- if last slave in right row use remaining space for that slave
106 if rowIndex == nbrRightSlaves
108 g.height = wa.y + wa.height - g.y - useless_gap - 2*c.border_width
110 g.height = slaveRightHeight - useless_gap - 2*c.border_width
115 if g.width < 1 then g.width = 1 end
116 if g.height < 1 then g.height = 1 end