From f283ef6208dc276ac775cd1ce768c6a3bf0b5598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20G=C3=B3mez?= Date: Thu, 18 Dec 2025 16:25:34 +0100 Subject: [PATCH] docs: improve --- src/lib/layout-utils.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/lib/layout-utils.ts b/src/lib/layout-utils.ts index 0b28d54..c2d4146 100644 --- a/src/lib/layout-utils.ts +++ b/src/lib/layout-utils.ts @@ -86,8 +86,9 @@ export function findAllLeaves( } /** - * Finds the shallowest leaf in the tree (closest to root = largest screen space) - * If multiple leaves at same depth, returns first one encountered + * Finds the shallowest leaf in the tree as a heuristic for largest screen space + * Accurate for balanced splits (default 50%), may be suboptimal for very unbalanced splits + * If multiple leaves at same depth, returns first one encountered (deterministic) */ export function findShallowstLeaf( node: MosaicNode | null, @@ -190,10 +191,14 @@ export function calculateBalancedDirection( /** * Inserts a new window into the layout tree according to the layout configuration * - * Smart mode uses shallowest-leaf algorithm for balanced trees: - * - Finds the leaf node at minimum depth (approximates largest visual space) - * - Splits that leaf with direction rotated from parent (row→column, column→row) - * - Creates more balanced layouts than root-level wrapping + * Smart mode uses shallowest-leaf algorithm for balanced/dwindle-style layouts: + * - Finds the leaf node at minimum depth (heuristic for largest visual space) + * - Splits that leaf with direction rotated 90° from parent (row→column, column→row) + * - Creates checkerboard-like balanced layouts, progressively equalizing space + * - Works best with balanced split percentages (default 50%) + * + * This is NOT a spiral/fibonacci layout (which maintains a main window). + * It creates equal-ish space distribution similar to "dwindle" mode in other WMs. * * @param currentLayout - The current layout tree (null if no windows yet) * @param newWindowId - The ID of the new window to insert