]> git.madduck.net Git - etc/awesome.git/blob - layout/cascade.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:

Created brigthness (markdown)
[etc/awesome.git] / layout / cascade.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 tag = require("awful.tag")
11
12 local cascade =
13 {
14     name     = "cascade",
15     nmaster  = 0,
16     offset_x = 32,
17     offset_y = 8
18 }
19
20 function cascade.arrange(p)
21
22     -- Cascade windows.
23
24     -- Screen.
25     local wa = p.workarea
26     local cls = p.clients
27
28     -- Opening a new window will usually force all existing windows to
29     -- get resized. This wastes a lot of CPU time. So let's set a lower
30     -- bound to "how_many": This wastes a little screen space but you'll
31     -- get a much better user experience.
32     local t = tag.selected(p.screen)
33     local num_c
34     if cascade.nmaster > 0
35     then
36         num_c = cascade.nmaster
37     else
38         num_c = tag.getnmaster(t)
39     end
40
41     local how_many = #cls
42     if how_many < num_c
43     then
44         how_many = num_c
45     end
46
47     local current_offset_x = cascade.offset_x * (how_many - 1)
48     local current_offset_y = cascade.offset_y * (how_many - 1)
49
50     -- Iterate.
51     for i = 1,#cls,1
52     do
53         local c = cls[i]
54         local g = {}
55
56         g.x = wa.x + (how_many - i) * cascade.offset_x
57         g.y = wa.y + (i - 1) * cascade.offset_y
58         g.width = wa.width - current_offset_x
59         g.height = wa.height - current_offset_y
60
61         c:geometry(g)
62     end
63 end
64
65 return cascade