diff --git a/src/engine/window.ts b/src/engine/window.ts index ca5c851..7a6da00 100644 --- a/src/engine/window.ts +++ b/src/engine/window.ts @@ -19,23 +19,26 @@ // DEALINGS IN THE SOFTWARE. class WindowResizeDelta { - public readonly diff: Rect; - public readonly east: number; - public readonly west: number; - public readonly south: number; - public readonly north: number; + public static fromWindow(window: Window): WindowResizeDelta { + const diff = window.actualGeometry.subtract(window.geometry); + return new WindowResizeDelta( + diff.width + diff.x, + -diff.x, + diff.height + diff.y, + -diff.y, + ); + } - public constructor(window: Window) { - this.diff = window.actualGeometry.subtract(window.geometry); - this.east = this.diff.width + this.diff.x; - this.west = -this.diff.x; - this.south = this.diff.height + this.diff.y; - this.north = -this.diff.y; + constructor( + public readonly east: number, + public readonly west: number, + public readonly south: number, + public readonly north: number, + ) { } public toString(): string { return "WindowResizeDelta(" + [ - "diff=" + this.diff, "east=" + this.east, "west=" + this.west, "north=" + this.north, diff --git a/src/layouts/quarterlayout.ts b/src/layouts/quarterlayout.ts index 69fc541..24b7a6a 100644 --- a/src/layouts/quarterlayout.ts +++ b/src/layouts/quarterlayout.ts @@ -43,7 +43,7 @@ class QuarterLayout implements ILayout { if (idx < 0) return; - const delta = new WindowResizeDelta(basis); + const delta = WindowResizeDelta.fromWindow(basis); /* vertical split */ if ((idx === 0 || idx === 3) && delta.east !== 0) diff --git a/src/layouts/tilelayout.ts b/src/layouts/tilelayout.ts index 6fbff73..6d1984e 100644 --- a/src/layouts/tilelayout.ts +++ b/src/layouts/tilelayout.ts @@ -44,7 +44,7 @@ class TileLayout implements ILayout { if (idx < 0) return; - const delta = new WindowResizeDelta(basis); + const delta = WindowResizeDelta.fromWindow(basis); if (idx < this.numMaster) { /* master tiles */ if (delta.east !== 0) { const newMasterWidth = Math.floor(area.width * this.masterRatio) + delta.east;