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.
4 Licensed under GNU General Public License v2
6 * (c) 2013, Luke Bonham
7 * (c) 2010-2012, Peter Hofmann
11 local tag = require("awful.tag")
12 local tonumber = tonumber
30 local function do_cascade(p, tiling)
35 if #cls <= 0 then return end
38 local useless_gap = p.useless_gap or 0
44 if cascade.nmaster > 0 then
45 num_c = cascade.nmaster
47 num_c = tag.master_count
50 -- Opening a new window will usually force all existing windows to
51 -- get resized. This wastes a lot of CPU time. So let's set a lower
52 -- bound to "how_many": This wastes a little screen space but you'll
53 -- get a much better user experience.
54 local how_many = (#cls >= num_c and #cls) or num_c
56 local current_offset_x = cascade.offset_x * (how_many - 1)
57 local current_offset_y = cascade.offset_y * (how_many - 1)
64 g.x = wa.x + (how_many - i) * cascade.offset_x
65 g.y = wa.y + (i - 1) * cascade.offset_y
66 g.width = wa.width - current_offset_x - 2*c.border_width
67 g.height = wa.height - current_offset_y - 2*c.border_width
69 if g.width < 1 then g.width = 1 end
70 if g.height < 1 then g.height = 1 end
75 -- Layout with one fixed column meant for a master window. Its
76 -- width is calculated according to mwfact. Other clients are
77 -- cascaded or "tabbed" in a slave column on the right.
80 -- +----------+---+ +----------+---+ +----------+---+ +----------+---+
81 -- | | | | | 3 | | | 4 | | +---+|
82 -- | | | -> | | | -> | +---++ -> | +---+|+
83 -- | 1 | 2 | | 1 +---++ | 1 | 3 || | 1 +---+|+|
84 -- | | | | | 2 || | +---++| | +---+|+ |
85 -- | | | | | || | | 2 | | | | 2 |+ |
86 -- +----------+---+ +---------+---++ +--------+---+-+ +------+---+---+
89 if cascade.tile.mwfact > 0 then
90 mwfact = cascade.tile.mwfact
92 mwfact = tag.getmwfact(t)
95 -- Make slave windows overlap main window? Do this if ncol is 1.
97 if cascade.tile.ncol > 0 then
98 overlap_main = cascade.tile.ncol
100 overlap_main = tag.column_count
103 -- Minimum space for slave windows? See cascade.tile.lua.
105 if cascade.tile.nmaster > 0 then
106 num_c = cascade.tile.nmaster
108 num_c = tag.master_count
111 local how_many = (#cls - 1 >= num_c and (#cls - 1)) or num_c
113 local current_offset_x = cascade.tile.offset_x * (how_many - 1)
114 local current_offset_y = cascade.tile.offset_y * (how_many - 1)
116 if #cls <= 0 then return end
118 -- Main column, fixed width and height.
121 -- Subtracting the useless_gap width from the work area width here
122 -- makes this mwfact calculation work the same as in uselesstile.
123 -- Rounding is necessary to prevent the rendered size of slavewid
124 -- from being 1 pixel off when the result is not an integer.
125 local mainwid = math.floor((wa.width - useless_gap) * mwfact)
126 local slavewid = wa.width - mainwid
128 if overlap_main == 1 then
129 g.width = wa.width - 2*c.border_width
131 -- The size of the main window may be reduced a little bit.
132 -- This allows you to see if there are any windows below the
134 -- This only makes sense, though, if the main window is
135 -- overlapping everything else.
136 g.width = g.width - cascade.tile.extra_padding
138 g.width = mainwid - 2*c.border_width
141 g.height = wa.height - 2*c.border_width
144 if useless_gap > 0 then
145 -- Reduce width once and move window to the right.
146 -- Reduce height twice, however.
147 g.width = g.width - useless_gap
148 g.height = g.height - 2 * useless_gap
149 g.x = g.x + useless_gap
150 g.y = g.y + useless_gap
152 -- When there's no window to the right, add an additional gap.
153 if overlap_main == 1 then g.width = g.width - useless_gap end
155 if g.width < 1 then g.width = 1 end
156 if g.height < 1 then g.height = 1 end
159 -- Remaining clients stacked in slave column, new ones on top.
164 g.width = slavewid - current_offset_x - 2*c.border_width
165 g.height = wa.height - current_offset_y - 2*c.border_width
166 g.x = wa.x + mainwid + (how_many - (i - 1)) * cascade.tile.offset_x
167 g.y = wa.y + (i - 2) * cascade.tile.offset_y
169 if useless_gap > 0 then
170 g.width = g.width - 2 * useless_gap
171 g.height = g.height - 2 * useless_gap
172 g.x = g.x + useless_gap
173 g.y = g.y + useless_gap
176 if g.width < 1 then g.width = 1 end
177 if g.height < 1 then g.height = 1 end
185 function cascade.tile.arrange(p)
186 return do_cascade(p, true)
189 function cascade.arrange(p)
190 return do_cascade(p, false)