From 87936131170f5dda44633953e4333e37d179686e Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Sat, 29 Dec 2018 13:27:45 +0100 Subject: [PATCH] potentially fixed #576 --- app/lib/window.ts | 11 +++++++++++ terminus-core/src/services/hostApp.service.ts | 6 ++++++ .../src/components/terminalTab.component.ts | 6 +++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/app/lib/window.ts b/app/lib/window.ts index b14216bd..6562b4f5 100644 --- a/app/lib/window.ts +++ b/app/lib/window.ts @@ -1,4 +1,5 @@ import { Subject, Observable } from 'rxjs' +import { debounceTime } from 'rxjs/operators' import { BrowserWindow, app, ipcMain, Rectangle } from 'electron' import ElectronConfig = require('electron-config') import * as os from 'os' @@ -143,6 +144,16 @@ export class Window { this.visible.next(false) }) + let moveSubscription = new Observable(observer => { + this.window.on('move', () => observer.next()) + }).pipe(debounceTime(250)).subscribe(() => { + this.window.webContents.send('host:window-moved') + }) + + this.window.on('closed', () => { + moveSubscription.unsubscribe() + }) + this.window.on('enter-full-screen', () => this.window.webContents.send('host:window-enter-full-screen')) this.window.on('leave-full-screen', () => this.window.webContents.send('host:window-leave-full-screen')) diff --git a/terminus-core/src/services/hostApp.service.ts b/terminus-core/src/services/hostApp.service.ts index 6c3245d7..e9c6704f 100644 --- a/terminus-core/src/services/hostApp.service.ts +++ b/terminus-core/src/services/hostApp.service.ts @@ -30,6 +30,7 @@ export class HostAppService { private cliOpenProfile = new Subject() private configChangeBroadcast = new Subject() private windowCloseRequest = new Subject() + private windowMoved = new Subject() private logger: Logger private windowId: number @@ -41,6 +42,7 @@ export class HostAppService { get cliOpenProfile$ (): Observable { return this.cliOpenProfile } get configChangeBroadcast$ (): Observable { return this.configChangeBroadcast } get windowCloseRequest$ (): Observable { return this.windowCloseRequest } + get windowMoved$ (): Observable { return this.windowMoved } constructor ( private zone: NgZone, @@ -80,6 +82,10 @@ export class HostAppService { this.zone.run(() => this.windowCloseRequest.next()) }) + electron.ipcRenderer.on('host:window-moved', () => { + this.zone.run(() => this.windowMoved.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/terminalTab.component.ts b/terminus-terminal/src/components/terminalTab.component.ts index e6a94149..b4961a8c 100644 --- a/terminus-terminal/src/components/terminalTab.component.ts +++ b/terminus-terminal/src/components/terminalTab.component.ts @@ -276,7 +276,11 @@ export class TerminalTabComponent extends BaseTabComponent { this.session.resize(columns, rows) } }) - }) + }), + + this.hostApp.windowMoved$.subscribe(() => setTimeout(() => { + this.configure() + }, 250)), ] }