MCPcopy
hub / github.com/paperwm/PaperWM / layout

Function layout

virtTiling.js:251–292  ·  view source on GitHub ↗
(columns, workArea, prefs, options = {})

Source from the content-addressed store, hash-verified

249 Mutates columns
250 */
251export function layout(columns, workArea, prefs, options = {}) {
252 let gap = prefs.window_gap;
253 let availableHeight = workArea.height;
254
255 let { inGrab, selectedWindow } = options;
256 let selectedIndex = -1;
257
258 if (selectedWindow) {
259 selectedIndex = columns.findIndex(col => col.includes(selectedWindow));
260 }
261
262 let y0 = workArea.y;
263 let x = 0;
264
265 for (let i = 0; i < columns.length; i++) {
266 let column = columns[i];
267
268 let selectedInColumn = i === selectedIndex ? selectedWindow : null;
269
270 let targetWidth;
271 if (i === selectedIndex) {
272 targetWidth = selectedInColumn.width;
273 } else {
274 targetWidth = Math.max(...column.map(w => w.width));
275 }
276 targetWidth = Math.min(targetWidth, workArea.width - 2 * prefs.minimum_margin);
277
278 if (inGrab && i === selectedIndex) {
279 layoutGrabColumn(column, x, y0, targetWidth, availableHeight, selectedInColumn);
280 } else {
281 let allocator = options.customAllocators && options.customAllocators[i];
282 allocator = allocator || allocateDefault;
283
284 let targetHeights = allocator(column, availableHeight, selectedInColumn);
285 layoutColumnSimple(column, x, y0, targetWidth, targetHeights);
286 }
287
288 x += targetWidth + gap;
289 }
290
291 return columns;
292}

Callers 1

syncFunction · 0.85

Calls 2

layoutGrabColumnFunction · 0.85
layoutColumnSimpleFunction · 0.85

Tested by

no test coverage detected