]> git.madduck.net Git - etc/awesome.git/blob - layout/centerwork.lua

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

wiki updated
[etc/awesome.git] / layout / centerwork.lua
1
2 --[[
3                                                   
4      Licensed under GNU General Public License v2 
5       * (c) 2014,      projektile                 
6       * (c) 2013,      Luke Bonham                
7       * (c) 2010-2012, Peter Hofmann              
8                                                   
9 --]]
10
11 local awful     = require("awful")
12 local beautiful = require("beautiful")
13 local tonumber  = tonumber
14 local math      = { floor = math.floor }
15
16 local centerwork =
17 {
18     name         = "centerwork",
19     top_left     = 0,
20     top_right    = 1,
21     bottom_left  = 2,
22     bottom_right = 3
23 }
24
25 function centerwork.arrange(p)
26     -- A useless gap (like the dwm patch) can be defined with
27     -- beautiful.useless_gap_width .
28     local useless_gap = tonumber(beautiful.useless_gap_width) or 0
29
30     -- A global border can be defined with
31     -- beautiful.global_border_width
32     local global_border = tonumber(beautiful.global_border_width) or 0
33     if global_border < 0 then global_border = 0 end
34
35     -- Themes border width requires an offset
36     local bw = tonumber(beautiful.border_width) or 0
37
38     -- Screen.
39     local wa = p.workarea
40     local cls = p.clients
41
42     -- Borders are factored in.
43     wa.height = wa.height - ((global_border * 2) + (bw * 2))
44     wa.width = wa.width - ((global_border * 2) + (bw * 2))
45
46     -- Width of main column?
47     local t = awful.tag.selected(p.screen)
48     local mwfact = awful.tag.getmwfact(t)
49
50     if #cls > 0
51     then
52         -- Main column, fixed width and height.
53         local c = cls[#cls]
54         local g = {}
55         local mainwid = math.floor(wa.width * mwfact)
56         local slavewid = wa.width - mainwid
57         local slaveLwid = math.floor(slavewid / 2)
58         local slaveRwid = slavewid - slaveLwid
59         local slaveThei = math.floor(wa.height / 2)
60         local slaveBhei = wa.height - slaveThei
61
62         g.height = wa.height - 2 * useless_gap
63         g.width = mainwid
64         g.x = wa.x + slaveLwid + global_border
65         g.y = wa.y + useless_gap + global_border
66
67         c:geometry(g)
68
69         -- Auxiliary windows.
70         if #cls > 1
71         then
72             local at = 0
73             for i = (#cls - 1),1,-1
74             do
75                 -- It's all fixed. If there are more than 5 clients,
76                 -- those additional clients will float. This is
77                 -- intentional.
78                 if at == 4
79                 then
80                     break
81                 end
82
83                 c = cls[i]
84                 g = {}
85
86                 if at == centerwork.top_left
87                 then
88                     -- top left
89                     g.x = wa.x + useless_gap + global_border
90                     g.y = wa.y + useless_gap + global_border
91                     g.width = slaveLwid - 2 * useless_gap
92                     g.height = slaveThei - useless_gap
93                 elseif at == centerwork.top_right
94                 then
95                     -- top right
96                     g.x = wa.x + slaveLwid + mainwid + useless_gap + global_border
97                     g.y = wa.y + useless_gap + global_border
98                     g.width = slaveRwid - 2 * useless_gap
99                     g.height = slaveThei - useless_gap
100                 elseif at == centerwork.bottom_left
101                 then
102                     -- bottom left
103                     g.x = wa.x + useless_gap + global_border
104                     g.y = wa.y + slaveThei + useless_gap + global_border
105                     g.width = slaveLwid - 2 * useless_gap
106                     g.height = slaveBhei - 2 * useless_gap
107                 elseif at == centerwork.bottom_right
108                 then
109                     -- bottom right
110                     g.x = wa.x + slaveLwid + mainwid + useless_gap + global_border
111                     g.y = wa.y + slaveThei + useless_gap + global_border
112                     g.width = slaveRwid - 2 * useless_gap
113                     g.height = slaveBhei - 2 * useless_gap
114                 end
115
116                 c:geometry(g)
117
118                 at = at + 1
119             end
120
121             -- Set remaining clients to floating.
122             for i = (#cls - 1 - 4),1,-1
123             do
124                 c = cls[i]
125                 awful.client.floating.set(c, true)
126             end
127         end
128     end
129 end
130
131 return centerwork