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.
3 Licensed under GNU General Public License v2
6 * (c) 2010-2012, Peter Hofmann
10 local floor = math.floor
29 local function do_cascade(p, tiling)
30 local t = p.tag or screen[p.screen].selected_tag
34 if #cls == 0 then return end
40 if cascade.nmaster > 0 then
41 num_c = cascade.nmaster
43 num_c = t.master_count
46 -- Opening a new window will usually force all existing windows to
47 -- get resized. This wastes a lot of CPU time. So let's set a lower
48 -- bound to "how_many": This wastes a little screen space but you'll
49 -- get a much better user experience.
50 local how_many = (#cls >= num_c and #cls) or num_c
52 local current_offset_x = cascade.offset_x * (how_many - 1)
53 local current_offset_y = cascade.offset_y * (how_many - 1)
60 g.x = wa.x + (how_many - i) * cascade.offset_x
61 g.y = wa.y + (i - 1) * cascade.offset_y
62 g.width = wa.width - current_offset_x
63 g.height = wa.height - current_offset_y
65 if g.width < 1 then g.width = 1 end
66 if g.height < 1 then g.height = 1 end
71 -- Layout with one fixed column meant for a master window. Its
72 -- width is calculated according to mwfact. Other clients are
73 -- cascaded or "tabbed" in a slave column on the right.
76 -- +----------+---+ +----------+---+ +----------+---+ +----------+---+
77 -- | | | | | 3 | | | 4 | | +---+|
78 -- | | | -> | | | -> | +---++ -> | +---+|+
79 -- | 1 | 2 | | 1 +---++ | 1 | 3 || | 1 +---+|+|
80 -- | | | | | 2 || | +---++| | +---+|+ |
81 -- | | | | | || | | 2 | | | | 2 |+ |
82 -- +----------+---+ +---------+---++ +--------+---+-+ +------+---+---+
85 if cascade.tile.mwfact > 0 then
86 mwfact = cascade.tile.mwfact
88 mwfact = t.master_width_factor
91 -- Make slave windows overlap main window? Do this if ncol is 1.
93 if cascade.tile.ncol > 0 then
94 overlap_main = cascade.tile.ncol
96 overlap_main = t.column_count
99 -- Minimum space for slave windows? See cascade.tile.lua.
101 if cascade.tile.nmaster > 0 then
102 num_c = cascade.tile.nmaster
104 num_c = t.master_count
107 local how_many = (#cls - 1 >= num_c and (#cls - 1)) or num_c
109 local current_offset_x = cascade.tile.offset_x * (how_many - 1)
110 local current_offset_y = cascade.tile.offset_y * (how_many - 1)
112 if #cls <= 0 then return end
114 -- Main column, fixed width and height.
117 -- Rounding is necessary to prevent the rendered size of slavewid
118 -- from being 1 pixel off when the result is not an integer.
119 local mainwid = floor(wa.width * mwfact)
120 local slavewid = wa.width - mainwid
122 if overlap_main == 1 then
125 -- The size of the main window may be reduced a little bit.
126 -- This allows you to see if there are any windows below the
128 -- This only makes sense, though, if the main window is
129 -- overlapping everything else.
130 g.width = g.width - cascade.tile.extra_padding
139 if g.width < 1 then g.width = 1 end
140 if g.height < 1 then g.height = 1 end
144 -- Remaining clients stacked in slave column, new ones on top.
145 if #cls <= 1 then return end
150 g.width = slavewid - current_offset_x
151 g.height = wa.height - current_offset_y
153 g.x = wa.x + mainwid + (how_many - (i - 1)) * cascade.tile.offset_x
154 g.y = wa.y + (i - 2) * cascade.tile.offset_y
156 if g.width < 1 then g.width = 1 end
157 if g.height < 1 then g.height = 1 end
164 function cascade.tile.arrange(p)
165 return do_cascade(p, true)
168 function cascade.arrange(p)
169 return do_cascade(p, false)