diff --git a/app/lib/app.ts b/app/lib/app.ts index 6ff1dbbf..7000319e 100644 --- a/app/lib/app.ts +++ b/app/lib/app.ts @@ -1,4 +1,5 @@ import { app, ipcMain, Menu, Tray, shell } from 'electron' +import * as electron from 'electron' import { loadConfig } from './config' import { Window, WindowOptions } from './window' @@ -21,6 +22,10 @@ export class Application { app.commandLine.appendSwitch('lang', 'EN') } + init () { + electron.screen.on('display-metrics-changed', () => this.broadcast('host:display-metrics-changed')) + } + async newWindow (options?: WindowOptions): Promise { let window = new Window(options) this.windows.push(window) diff --git a/app/lib/index.ts b/app/lib/index.ts index 168b0dae..15f5aad7 100644 --- a/app/lib/index.ts +++ b/app/lib/index.ts @@ -58,5 +58,6 @@ app.on('ready', () => { } ])) } + application.init() application.newWindow({ hidden: argv.hidden }) }) diff --git a/terminus-core/src/services/hostApp.service.ts b/terminus-core/src/services/hostApp.service.ts index e9c6704f..c0f4f095 100644 --- a/terminus-core/src/services/hostApp.service.ts +++ b/terminus-core/src/services/hostApp.service.ts @@ -31,6 +31,7 @@ export class HostAppService { private configChangeBroadcast = new Subject() private windowCloseRequest = new Subject() private windowMoved = new Subject() + private displayMetricsChanged = new Subject() private logger: Logger private windowId: number @@ -43,6 +44,7 @@ export class HostAppService { get configChangeBroadcast$ (): Observable { return this.configChangeBroadcast } get windowCloseRequest$ (): Observable { return this.windowCloseRequest } get windowMoved$ (): Observable { return this.windowMoved } + get displayMetricsChanged$ (): Observable { return this.displayMetricsChanged } constructor ( private zone: NgZone, @@ -86,6 +88,10 @@ export class HostAppService { this.zone.run(() => this.windowMoved.next()) }) + electron.ipcRenderer.on('host:display-metrics-changed', () => { + this.zone.run(() => this.displayMetricsChanged.next()) + }) + electron.ipcRenderer.on('host:second-instance', (_$event, argv: any, cwd: string) => this.zone.run(() => { this.logger.info('Second instance', argv) const op = argv._[0] diff --git a/terminus-terminal/src/components/baseTerminalTab.component.ts b/terminus-terminal/src/components/baseTerminalTab.component.ts index 6b957565..1a37c579 100644 --- a/terminus-terminal/src/components/baseTerminalTab.component.ts +++ b/terminus-terminal/src/components/baseTerminalTab.component.ts @@ -265,6 +265,10 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit this.hostApp.windowMoved$.subscribe(() => setTimeout(() => { this.configure() }, 250)), + + this.hostApp.displayMetricsChanged$.subscribe(() => setTimeout(() => { + this.configure() + }, 250)), ] }