From 8c013ac7bc8d293c81c1f14f03c2147d47d43703 Mon Sep 17 00:00:00 2001 From: Mikhail Zolotukhin Date: Sat, 23 Oct 2021 01:20:17 +0300 Subject: [PATCH] feat: use better layout notifications --- src/engine/index.ts | 15 +++++++++++++-- src/engine/layout/cascade_layout.ts | 6 +++--- src/engine/layout/three_column_layout.ts | 2 +- src/engine/layout/tile_layout.ts | 4 ++-- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/engine/index.ts b/src/engine/index.ts index 102addbb..8a03111e 100644 --- a/src/engine/index.ts +++ b/src/engine/index.ts @@ -164,6 +164,12 @@ export interface Engine { * @param text the text of the notification */ showNotification(text: string): void; + + /** + * Show the notification with the info + * about the current layout. + */ + showLayoutNotification(): void; } export class EngineImpl implements Engine { @@ -566,7 +572,7 @@ export class EngineImpl implements Engine { step ); if (layout) { - this.controller.showNotification(layout.description); + this.showLayoutNotification(); // Minimize inactive windows if Monocle and config.monocleMinimizeRest if ( @@ -584,7 +590,7 @@ export class EngineImpl implements Engine { layoutClassID ); if (layout) { - this.controller.showNotification(layout.description); + this.showLayoutNotification(); // Minimize inactive windows if Monocle and config.monocleMinimizeRest if ( @@ -695,6 +701,11 @@ export class EngineImpl implements Engine { this.controller.showNotification(text); } + public showLayoutNotification(): void { + const currentLayout = this.currentLayoutOnCurrentSurface(); + this.controller.showNotification(`Layout: ${currentLayout.description}`); + } + /** * Returns the tiling area for the given working area and the windows layout. * diff --git a/src/engine/layout/cascade_layout.ts b/src/engine/layout/cascade_layout.ts index 96f18c02..643a881b 100644 --- a/src/engine/layout/cascade_layout.ts +++ b/src/engine/layout/cascade_layout.ts @@ -58,7 +58,7 @@ export default class CascadeLayout implements WindowsLayout { public readonly classID = CascadeLayout.id; public get description(): string { - return "Cascade [" + CascadeDirection[this.dir] + "]"; + return `Cascade [${CascadeDirection[this.dir]}]`; } constructor(private dir: CascadeDirection = CascadeDirection.SouthEast) { @@ -105,10 +105,10 @@ export default class CascadeLayout implements WindowsLayout { public executeAction(engine: Engine, action: Action): void { if (action instanceof IncreaseMasterAreaWindowCount) { this.dir = (this.dir + 1 + 8) % 8; - engine.showNotification(this.description); + engine.showLayoutNotification(); } else if (action instanceof DecreaseMasterAreaWindowCount) { this.dir = (this.dir - 1 + 8) % 8; - engine.showNotification(this.description); + engine.showLayoutNotification(); } else { action.executeWithoutLayoutOverride(); } diff --git a/src/engine/layout/three_column_layout.ts b/src/engine/layout/three_column_layout.ts index 9b08ef26..0f0abc2e 100644 --- a/src/engine/layout/three_column_layout.ts +++ b/src/engine/layout/three_column_layout.ts @@ -239,6 +239,6 @@ export default class ThreeColumnLayout implements WindowsLayout { private resizeMaster(engine: Engine, step: -1 | 1): void { this.masterSize = clip(this.masterSize + step, 1, 10); - engine.showNotification(this.description); + engine.showLayoutNotification(); } } diff --git a/src/engine/layout/tile_layout.ts b/src/engine/layout/tile_layout.ts index 2d935eb2..fc6e6b33 100644 --- a/src/engine/layout/tile_layout.ts +++ b/src/engine/layout/tile_layout.ts @@ -124,12 +124,12 @@ export default class TileLayout implements WindowsLayout { if (this.numMaster < 10) { this.numMaster += 1; } - engine.showNotification(this.description); + engine.showLayoutNotification(); } else if (action instanceof DecreaseMasterAreaWindowCount) { if (this.numMaster > 0) { this.numMaster -= 1; } - engine.showNotification(this.description); + engine.showLayoutNotification(); } else if (action instanceof Rotate) { this.parts.rotate(90); } else if (action instanceof RotatePart) {