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 floor = math.floor
30 local function do_cascade(p, tiling)
31 local t = p.tag or screen[p.screen].selected_tag
35 if #cls == 0 then return end
41 if cascade.nmaster > 0 then
42 num_c = cascade.nmaster
44 num_c = t.master_count
47 -- Opening a new window will usually force all existing windows to
48 -- get resized. This wastes a lot of CPU time. So let's set a lower
49 -- bound to "how_many": This wastes a little screen space but you'll
50 -- get a much better user experience.
51 local how_many = (#cls >= num_c and #cls) or num_c
53 local current_offset_x = cascade.offset_x * (how_many - 1)
54 local current_offset_y = cascade.offset_y * (how_many - 1)
61 g.x = wa.x + (how_many - i) * cascade.offset_x
62 g.y = wa.y + (i - 1) * cascade.offset_y
63 g.width = wa.width - current_offset_x
64 g.height = wa.height - current_offset_y
66 if g.width < 1 then g.width = 1 end
67 if g.height < 1 then g.height = 1 end
72 -- Layout with one fixed column meant for a master window. Its
73 -- width is calculated according to mwfact. Other clients are
74 -- cascaded or "tabbed" in a slave column on the right.
77 -- +----------+---+ +----------+---+ +----------+---+ +----------+---+
78 -- | | | | | 3 | | | 4 | | +---+|
79 -- | | | -> | | | -> | +---++ -> | +---+|+
80 -- | 1 | 2 | | 1 +---++ | 1 | 3 || | 1 +---+|+|
81 -- | | | | | 2 || | +---++| | +---+|+ |
82 -- | | | | | || | | 2 | | | | 2 |+ |
83 -- +----------+---+ +---------+---++ +--------+---+-+ +------+---+---+
86 if cascade.tile.mwfact > 0 then
87 mwfact = cascade.tile.mwfact
89 mwfact = t.master_width_factor
92 -- Make slave windows overlap main window? Do this if ncol is 1.
94 if cascade.tile.ncol > 0 then
95 overlap_main = cascade.tile.ncol
97 overlap_main = t.column_count
100 -- Minimum space for slave windows? See cascade.tile.lua.
102 if cascade.tile.nmaster > 0 then
103 num_c = cascade.tile.nmaster
105 num_c = t.master_count
108 local how_many = (#cls - 1 >= num_c and (#cls - 1)) or num_c
110 local current_offset_x = cascade.tile.offset_x * (how_many - 1)
111 local current_offset_y = cascade.tile.offset_y * (how_many - 1)
113 if #cls <= 0 then return end
115 -- Main column, fixed width and height.
118 -- Rounding is necessary to prevent the rendered size of slavewid
119 -- from being 1 pixel off when the result is not an integer.
120 local mainwid = floor(wa.width * mwfact)
121 local slavewid = wa.width - mainwid
123 if overlap_main == 1 then
126 -- The size of the main window may be reduced a little bit.
127 -- This allows you to see if there are any windows below the
129 -- This only makes sense, though, if the main window is
130 -- overlapping everything else.
131 g.width = g.width - cascade.tile.extra_padding
140 if g.width < 1 then g.width = 1 end
141 if g.height < 1 then g.height = 1 end
145 -- Remaining clients stacked in slave column, new ones on top.
146 if #cls <= 1 then return end
151 g.width = slavewid - current_offset_x
152 g.height = wa.height - current_offset_y
154 g.x = wa.x + mainwid + (how_many - (i - 1)) * cascade.tile.offset_x
155 g.y = wa.y + (i - 2) * cascade.tile.offset_y
157 if g.width < 1 then g.width = 1 end
158 if g.height < 1 then g.height = 1 end
165 function cascade.tile.arrange(p)
166 return do_cascade(p, true)
169 function cascade.arrange(p)
170 return do_cascade(p, false)