Pure function contract for consumer layout strategies. (D1) No side effects. Implement this in your shell repo — @kehto/wm ships only the contract.
// In your shell repo (not in @kehto/wm):import type { LayoutStrategy, WindowState, Rect } from '@kehto/wm';export const myBspStrategy: LayoutStrategy = { arrange(windows, containerRect) { const visible = windows.filter(w => !w.minimized); if (visible.length === 0) return []; const w = Math.floor(containerRect.w / visible.length); return visible.map((win, i) => ({ id: win.id, rect: { x: containerRect.x + i * w, y: containerRect.y, w, h: containerRect.h }, })); },}; Copy
// In your shell repo (not in @kehto/wm):import type { LayoutStrategy, WindowState, Rect } from '@kehto/wm';export const myBspStrategy: LayoutStrategy = { arrange(windows, containerRect) { const visible = windows.filter(w => !w.minimized); if (visible.length === 0) return []; const w = Math.floor(containerRect.w / visible.length); return visible.map((win, i) => ({ id: win.id, rect: { x: containerRect.x + i * w, y: containerRect.y, w, h: containerRect.h }, })); },};
Arrange visible windows inside a container rectangle.
Current window state snapshot.
Available layout rectangle.
Window placements for this layout pass.
Pure function contract for consumer layout strategies. (D1) No side effects. Implement this in your shell repo — @kehto/wm ships only the contract.
Example