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

Method layoutGrabColumn

tiling.js:528–559  ·  view source on GitHub ↗
(column, x, y0, targetWidth, availableHeight, time, grabWindow)

Source from the content-addressed store, hash-verified

526 }
527
528 layoutGrabColumn(column, x, y0, targetWidth, availableHeight, time, grabWindow) {
529 let space = this;
530 let needRelayout = false;
531
532 function mosh(windows, height, y0) {
533 let targetHeights = fitProportionally(
534 windows.map(mw => mw.get_frame_rect().height),
535 height
536 );
537 let [, relayout, y] = space.layoutColumnSimple(windows, x, y0, targetWidth, targetHeights, time);
538 needRelayout = needRelayout || relayout;
539 return y;
540 }
541
542 const k = column.indexOf(grabWindow);
543 if (k < 0) {
544 throw new Error(`Anchor doesn't exist in column ${grabWindow?.title}`);
545 }
546
547 const gap = Settings.prefs.window_gap;
548 const f = grabWindow.get_frame_rect();
549 let yGrabRel = f.y - this.monitor.y;
550 targetWidth = f.width;
551
552 const H1 = (yGrabRel - y0) - gap - (k - 1) * gap;
553 const H2 = availableHeight - (yGrabRel + f.height - y0) - gap - (column.length - k - 2) * gap;
554 k > 0 && mosh(column.slice(0, k), H1, y0);
555 let y = mosh(column.slice(k, k + 1), f.height, yGrabRel);
556 k + 1 < column.length && mosh(column.slice(k + 1), H2, y);
557
558 return [targetWidth, needRelayout];
559 }
560
561 layoutColumnSimple(windows, x, y0, targetWidth, targetHeights, time) {
562 let space = this;

Callers 1

layoutMethod · 0.95

Calls 2

moshFunction · 0.85
indexOfMethod · 0.80

Tested by

no test coverage detected