]> 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:

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