| 198 | } |
| 199 | |
| 200 | export function layoutGrabColumn(column, x, y0, targetWidth, availableHeight, grabWindow) { |
| 201 | function mosh(windows, height, y0) { |
| 202 | let targetHeights = fitProportionally( |
| 203 | windows.map(mw => mw.rect.height), |
| 204 | height |
| 205 | ); |
| 206 | let [w, y] = layoutColumnSimple(windows, x, y0, targetWidth, targetHeights); |
| 207 | return y; |
| 208 | } |
| 209 | |
| 210 | const k = column.indexOf(grabWindow); |
| 211 | if (k < 0) { |
| 212 | throw new Error(`Anchor doesn't exist in column ${grabWindow.title}`); |
| 213 | } |
| 214 | |
| 215 | const gap = prefs.window_gap; |
| 216 | const f = grabWindow.globalRect(); |
| 217 | let yGrabRel = f.y - this.monitor.y; |
| 218 | targetWidth = f.width; |
| 219 | |
| 220 | const H1 = (yGrabRel - y0) - gap - (k - 1) * gap; |
| 221 | const H2 = availableHeight - (yGrabRel + f.height - y0) - gap - (column.length - k - 2) * gap; |
| 222 | k > 0 && mosh(column.slice(0, k), H1, y0); |
| 223 | let y = mosh(column.slice(k, k + 1), f.height, yGrabRel); |
| 224 | k + 1 < column.length && mosh(column.slice(k + 1), H2, y); |
| 225 | |
| 226 | return targetWidth; |
| 227 | } |
| 228 | |
| 229 | |
| 230 | export function layoutColumnSimple(windows, x, y0, targetWidth, targetHeights, time) { |