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

Window border width issue fixes in uselessfair
[etc/awesome.git] / layout / cascade.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 tag       = require("awful.tag")
12 local beautiful = require("beautiful")
13
14 local cascade =
15 {
16     name     = "cascade",
17     nmaster  = 0,
18     offset_x = 32,
19     offset_y = 8
20 }
21
22 function cascade.arrange(p)
23
24     -- Cascade windows.
25
26     -- A global border can be defined with
27     -- beautiful.global_border_width.
28     local global_border = tonumber(beautiful.global_border_width) or 0
29     if global_border < 0 then global_border = 0 end
30
31     -- Themes border width requires an offset.
32     local bw = tonumber(beautiful.border_width) or 0
33
34     -- Screen.
35     local wa = p.workarea
36     local cls = p.clients
37
38     wa.height = wa.height - ((global_border * 2) + (bw * 2))
39     wa.width = wa.width - ((global_border * 2) + (bw * 2))
40     wa.x = wa.x + global_border
41     wa.y = wa.y + global_border
42
43     -- Opening a new window will usually force all existing windows to
44     -- get resized. This wastes a lot of CPU time. So let's set a lower
45     -- bound to "how_many": This wastes a little screen space but you'll
46     -- get a much better user experience.
47     local t = tag.selected(p.screen)
48     local num_c
49     if cascade.nmaster > 0
50     then
51         num_c = cascade.nmaster
52     else
53         num_c = tag.getnmaster(t)
54     end
55
56     local how_many = #cls
57     if how_many < num_c
58     then
59         how_many = num_c
60     end
61
62     local current_offset_x = cascade.offset_x * (how_many - 1)
63     local current_offset_y = cascade.offset_y * (how_many - 1)
64
65     -- Iterate.
66     for i = 1,#cls,1
67     do
68         local c = cls[i]
69         local g = {}
70
71         g.x = wa.x + (how_many - i) * cascade.offset_x
72         g.y = wa.y + (i - 1) * cascade.offset_y
73         g.width = wa.width - current_offset_x
74         g.height = wa.height - current_offset_y
75
76         c:geometry(g)
77     end
78 end
79
80 return cascade