]> 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 for pull #39
[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) or 0
28
29     -- Screen.
30     local wa = p.workarea
31     local cls = p.clients
32
33     -- Width of main column?
34     local t = awful.tag.selected(p.screen)
35     local mwfact = awful.tag.getmwfact(t)
36
37     if #cls > 0
38     then
39         -- Main column, fixed width and height.
40         local c = cls[#cls]
41         local g = {}
42         local mainwid = math.floor(wa.width * mwfact)
43         local slavewid = wa.width - mainwid
44         local slaveLwid = math.floor(slavewid / 2)
45         local slaveRwid = slavewid - slaveLwid
46         local slaveThei = math.floor(wa.height / 2)
47         local slaveBhei = wa.height - slaveThei
48
49         g.height = wa.height - 2 * useless_gap
50         g.width = mainwid
51         g.x = wa.x + slaveLwid
52         g.y = wa.y + useless_gap
53
54         c:geometry(g)
55
56         -- Auxiliary windows.
57         if #cls > 1
58         then
59             local at = 0
60             for i = (#cls - 1),1,-1
61             do
62                 -- It's all fixed. If there are more than 5 clients,
63                 -- those additional clients will float. This is
64                 -- intentional.
65                 if at == 4
66                 then
67                     break
68                 end
69
70                 c = cls[i]
71                 g = {}
72
73                 if at == centerwork.top_left
74                 then
75                     -- top left
76                     g.x = wa.x + useless_gap
77                     g.y = wa.y + useless_gap
78                     g.width = slaveLwid - 2 * useless_gap
79                     g.height = slaveThei - useless_gap
80                 elseif at == centerwork.top_right
81                 then
82                     -- top right
83                     g.x = wa.x + slaveLwid + mainwid + useless_gap
84                     g.y = wa.y + useless_gap
85                     g.width = slaveRwid - 2 * useless_gap
86                     g.height = slaveThei - useless_gap
87                 elseif at == centerwork.bottom_left
88                 then
89                     -- bottom left
90                     g.x = wa.x + useless_gap
91                     g.y = wa.y + slaveThei + useless_gap
92                     g.width = slaveLwid - 2 * useless_gap
93                     g.height = slaveBhei - 2 * useless_gap
94                 elseif at == centerwork.bottom_right
95                 then
96                     -- bottom right
97                     g.x = wa.x + slaveLwid + mainwid + useless_gap
98                     g.y = wa.y + slaveThei + useless_gap
99                     g.width = slaveRwid - 2 * useless_gap
100                     g.height = slaveBhei - 2 * useless_gap
101                 end
102
103                 c:geometry(g)
104
105                 at = at + 1
106             end
107
108             -- Set remaining clients to floating.
109             for i = (#cls - 1 - 4),1,-1
110             do
111                 c = cls[i]
112                 awful.client.floating.set(c, true)
113             end
114         end
115     end
116 end
117
118 return centerwork