From 4426d4827f0e3557ec445c7aeda0319ee7d570df Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Wed, 31 Oct 2018 17:37:34 +0100 Subject: [PATCH] bring window to front when called from CLI (fixes #489) --- app/lib/window.ts | 11 +++++++++++ terminus-core/src/services/hostApp.service.ts | 4 ++++ terminus-terminal/src/index.ts | 3 +++ 3 files changed, 18 insertions(+) diff --git a/app/lib/window.ts b/app/lib/window.ts index f1c7e884..884c2280 100644 --- a/app/lib/window.ts +++ b/app/lib/window.ts @@ -224,6 +224,17 @@ export class Window { this.window.setTitle(title) }) + ipcMain.on('window-bring-to-front', event => { + if (event.sender !== this.window.webContents) { + return + } + if (this.window.isMinimized()) { + this.window.restore() + } + this.window.show() + this.window.moveTop() + }) + this.window.webContents.on('new-window', event => event.preventDefault()) } diff --git a/terminus-core/src/services/hostApp.service.ts b/terminus-core/src/services/hostApp.service.ts index 9d89bda5..33fe5e6c 100644 --- a/terminus-core/src/services/hostApp.service.ts +++ b/terminus-core/src/services/hostApp.service.ts @@ -180,6 +180,10 @@ export class HostAppService { this.electron.ipcRenderer.send('app:ready') } + bringToFront () { + this.electron.ipcRenderer.send('window-bring-to-front') + } + quit () { this.logger.info('Quitting') this.electron.app.quit() diff --git a/terminus-terminal/src/index.ts b/terminus-terminal/src/index.ts index e3dc966c..3def0646 100644 --- a/terminus-terminal/src/index.ts +++ b/terminus-terminal/src/index.ts @@ -163,6 +163,7 @@ export default class TerminalModule { if (await fs.exists(directory)) { if ((await fs.stat(directory)).isDirectory()) { terminal.openTab(null, directory) + hostApp.bringToFront() } } }) @@ -172,10 +173,12 @@ export default class TerminalModule { command: command[0], args: command.slice(1), }, null, true) + hostApp.bringToFront() }) hostApp.cliPaste$.subscribe(text => { if (app.activeTab instanceof TerminalTabComponent && app.activeTab.session) { (app.activeTab as TerminalTabComponent).sendInput(text) + hostApp.bringToFront() } }) } -- GitLab