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().
This commit is contained in:
Lucas Oskorep
2026-02-24 17:46:20 -05:00
parent 99778f3ef2
commit 7083482d5c
3 changed files with 14 additions and 13 deletions

View File

@@ -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()

View File

@@ -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<number, WindowWrapper>();
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;

View File

@@ -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);
}
}