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

Function layoutGrabColumn

virtTiling.js:200–227  ·  view source on GitHub ↗
(column, x, y0, targetWidth, availableHeight, grabWindow)

Source from the content-addressed store, hash-verified

198}
199
200export 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
230export function layoutColumnSimple(windows, x, y0, targetWidth, targetHeights, time) {

Callers 1

layoutFunction · 0.85

Calls 2

moshFunction · 0.85
indexOfMethod · 0.80

Tested by

no test coverage detected