From d85880d0a52d2a941a0c72e1eccf89f87dae8726 Mon Sep 17 00:00:00 2001 From: Vaughan Milliman Date: Sun, 31 Mar 2024 15:47:04 -0500 Subject: [PATCH] fix tile insertion when layout empty and remove building layout timer --- src/driver/index.ts | 13 ++----------- src/engine/layouts/btree.ts | 4 +++- src/engine/layouts/half.ts | 3 ++- src/engine/layouts/threecolumn.ts | 14 +++++--------- 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/driver/index.ts b/src/driver/index.ts index c233291..0858491 100644 --- a/src/driver/index.ts +++ b/src/driver/index.ts @@ -22,20 +22,11 @@ export class DriverManager { buildingLayout: boolean = false; resizingLayout: boolean = false; - // have to use a timer to set buildingLayout back to false to stop kwin from moving too fast and setting off signals - private buildingLayoutTimer: QTimer; - constructor(c: Controller) { this.ctrl = c; this.engineFactory = new TilingEngineFactory(this.ctrl.config); this.logger = c.logger; - this.config = c.config; - this.buildingLayoutTimer = c.qmlObjects.root.createTimer(); - this.buildingLayoutTimer.interval = c.config.timerDelay; - this.buildingLayoutTimer.repeat = false; - this.buildingLayoutTimer.triggeredOnStart = false; - this.buildingLayoutTimer.triggered.connect((() => this.buildingLayout = false).bind(this)); - + this.config = c.config; } init(): void { @@ -231,7 +222,7 @@ export class DriverManager { } } } - this.buildingLayoutTimer.restart(); + this.buildingLayout = false; } untileWindow(window: Window, desktops?: Desktop[]): void { diff --git a/src/engine/layouts/btree.ts b/src/engine/layouts/btree.ts index 1c8f8f7..ea72b9b 100644 --- a/src/engine/layouts/btree.ts +++ b/src/engine/layouts/btree.ts @@ -167,7 +167,9 @@ export default class BTreeEngine extends TilingEngine { putClientInTile(client: Client, tile: Tile, direction?: Direction) { const node = this.nodeMap.inverse.get(tile); if (node == undefined) { - throw new Error("Node not found for tile"); + // usually means there are no other tiles in the layout + this.addClient(client); + return; } if (node.client == null) { node.client = client; diff --git a/src/engine/layouts/half.ts b/src/engine/layouts/half.ts index 71ba0b7..4a4f2dc 100644 --- a/src/engine/layouts/half.ts +++ b/src/engine/layouts/half.ts @@ -152,7 +152,8 @@ export default class HalfEngine extends TilingEngine { let targetBox: BoxIndex; const box = this.tileMap.get(tile); if (box == undefined) { - throw new Error("Box not found for tile"); + this.addClient(client); + return; } targetBox = new BoxIndex(this, box.client); diff --git a/src/engine/layouts/threecolumn.ts b/src/engine/layouts/threecolumn.ts index a7a6297..b9d506b 100644 --- a/src/engine/layouts/threecolumn.ts +++ b/src/engine/layouts/threecolumn.ts @@ -132,16 +132,12 @@ export default class ThreeColumnEngine extends TilingEngine { putClientInTile(client: Client, tile: Tile, direction?: Direction) { const clientBox = new ClientBox(client); let targetBox: BoxIndex; - try { - const box = this.tileMap.get(tile); - if (box == undefined) { - throw new Error("Box not found for tile"); - } - targetBox = new BoxIndex(this, box.client); - } catch (e) { - throw e; + const box = this.tileMap.get(tile); + if (box == undefined) { + this.addClient(client); + return; } - + targetBox = new BoxIndex(this, box.client); const targetArr = this.rows[targetBox.row]; if (direction == null || direction & Direction.Up) { targetArr.splice(targetBox.index, 0, clientBox);