Skip to content

Commit

Permalink
fix tile insertion when layout empty and remove building layout timer
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroxoneafour committed Mar 31, 2024
1 parent ef3d61e commit d85880d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 22 deletions.
13 changes: 2 additions & 11 deletions src/driver/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -231,7 +222,7 @@ export class DriverManager {
}
}
}
this.buildingLayoutTimer.restart();
this.buildingLayout = false;
}

untileWindow(window: Window, desktops?: Desktop[]): void {
Expand Down
4 changes: 3 additions & 1 deletion src/engine/layouts/btree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/engine/layouts/half.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
14 changes: 5 additions & 9 deletions src/engine/layouts/threecolumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d85880d

Please sign in to comment.