From 7083482d5cc36f8d7ed55c9a6433b67759231363 Mon Sep 17 00:00:00 2001 From: Lucas Oskorep Date: Tue, 24 Feb 2026 17:46:20 -0500 Subject: [PATCH] fix: min-window-size setting now read live from Gio.Settings on every boundary adjust Previously _minRatio was baked into WindowContainer at construction time and never updated. Now adjustBoundary() takes minRatio as a parameter, WindowManager._getMinRatio() reads it from Gio.Settings on every call, and the settings reference is injected from extension.ts on enable(). --- extension.ts | 1 + src/wm/container.ts | 9 ++------- src/wm/windowManager.ts | 17 +++++++++++------ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/extension.ts b/extension.ts index c6b391d..2ad046a 100644 --- a/extension.ts +++ b/extension.ts @@ -20,6 +20,7 @@ export default class aerospike extends Extension { enable() { Logger.log("STARTING AEROSPIKE!") + this.windowManager._settings = this.settings; this.bindSettings(); this.setupKeybindings(); this.windowManager.enable() diff --git a/src/wm/container.ts b/src/wm/container.ts index 17c511a..b433e97 100644 --- a/src/wm/container.ts +++ b/src/wm/container.ts @@ -40,15 +40,11 @@ export default class WindowContainer { */ _splitRatios: number[]; - /** Minimum fraction any child may occupy (read from settings, default 0.10). */ - _minRatio: number; - - constructor(workspaceArea: Rect, minRatio: number = 0.10) { + constructor(workspaceArea: Rect) { this._tiledItems = []; this._tiledWindowLookup = new Map(); this._workArea = workspaceArea; this._splitRatios = []; - this._minRatio = minRatio; } // ─── Helpers ──────────────────────────────────────────────────────────────── @@ -245,7 +241,7 @@ export default class WindowContainer { * Returns true if the adjustment was applied, false if it was rejected * (e.g. out of bounds index or clamping would violate minimum). */ - adjustBoundary(boundaryIndex: number, deltaPixels: number): boolean { + adjustBoundary(boundaryIndex: number, deltaPixels: number, minRatio: number = 0.10): boolean { if (boundaryIndex < 0 || boundaryIndex >= this._tiledItems.length - 1) { Logger.warn(`adjustBoundary: invalid boundaryIndex ${boundaryIndex}`); return false; @@ -255,7 +251,6 @@ export default class WindowContainer { if (totalDim === 0) return false; const ratioDelta = deltaPixels / totalDim; - const minRatio = this._minRatio; const newLeft = this._splitRatios[boundaryIndex] + ratioDelta; const newRight = this._splitRatios[boundaryIndex + 1] - ratioDelta; diff --git a/src/wm/windowManager.ts b/src/wm/windowManager.ts index cc03e4e..5655337 100644 --- a/src/wm/windowManager.ts +++ b/src/wm/windowManager.ts @@ -1,5 +1,5 @@ import Meta from "gi://Meta"; -// import Gio from "gi://Gio"; +import Gio from "gi://Gio"; // import GLib from "gi://GLib"; import {WindowWrapper} from './window.js'; @@ -60,9 +60,13 @@ export default class WindowManager implements IWindowManager { /** Re-entrancy guard: true while tileWindows is propagating position-changed events. */ _isTiling: boolean = false; - constructor() { + _settings: Gio.Settings | null = null; + constructor() {} + /** Returns the live min-ratio value from settings, falling back to 0.10. */ + private _getMinRatio(): number { + return this._settings?.get_double('min-window-size-percent') ?? 0.10; } public enable(): void { @@ -405,18 +409,19 @@ export default class WindowManager implements IWindowManager { // positive dx/dy moves the left edge right, growing the left neighbour // and shrinking this item — so we negate the delta. + const minRatio = this._getMinRatio(); let adjusted = false; if (isHorizontal) { if (op === Meta.GrabOp.RESIZING_E || op === Meta.GrabOp.RESIZING_NE || op === Meta.GrabOp.RESIZING_SE) { - adjusted = container.adjustBoundary(itemIndex, dx); + adjusted = container.adjustBoundary(itemIndex, dx, minRatio); } else if (op === Meta.GrabOp.RESIZING_W || op === Meta.GrabOp.RESIZING_NW || op === Meta.GrabOp.RESIZING_SW) { - adjusted = container.adjustBoundary(itemIndex - 1, dx); + adjusted = container.adjustBoundary(itemIndex - 1, dx, minRatio); } } else { if (op === Meta.GrabOp.RESIZING_S || op === Meta.GrabOp.RESIZING_SE || op === Meta.GrabOp.RESIZING_SW) { - adjusted = container.adjustBoundary(itemIndex, dy); + adjusted = container.adjustBoundary(itemIndex, dy, minRatio); } else if (op === Meta.GrabOp.RESIZING_N || op === Meta.GrabOp.RESIZING_NE || op === Meta.GrabOp.RESIZING_NW) { - adjusted = container.adjustBoundary(itemIndex - 1, dy); + adjusted = container.adjustBoundary(itemIndex - 1, dy, minRatio); } }