diff --git a/app/main.js b/app/main.js index 9d56da49..2c773708 100644 --- a/app/main.js +++ b/app/main.js @@ -56,14 +56,6 @@ setupWindowManagement = () => { app.window.focus() }) - electron.ipcMain.on('window-toggle-focus', () => { - if (app.window.isFocused()) { - app.window.minimize() - } else { - app.window.focus() - } - }) - electron.ipcMain.on('window-maximize', () => { app.window.maximize() }) diff --git a/terminus-core/src/components/appRoot.component.ts b/terminus-core/src/components/appRoot.component.ts index ce1ee98a..b4dc451e 100644 --- a/terminus-core/src/components/appRoot.component.ts +++ b/terminus-core/src/components/appRoot.component.ts @@ -130,11 +130,13 @@ export class AppRootComponent { onGlobalHotkey () { if (this.electron.app.window.isFocused()) { // focused + this.electron.loseFocus() this.electron.app.window.hide() } else { if (!this.electron.app.window.isVisible()) { // unfocused, invisible this.electron.app.window.show() + this.electron.app.window.focus() } else { if (this.config.store.appearance.dock === 'off') { // not docked, visible diff --git a/terminus-core/src/services/electron.service.ts b/terminus-core/src/services/electron.service.ts index d76e9df8..0aafa404 100644 --- a/terminus-core/src/services/electron.service.ts +++ b/terminus-core/src/services/electron.service.ts @@ -33,4 +33,10 @@ export class ElectronService { remoteRequirePluginModule (plugin: string, module: string, globals: any): any { return this.remoteRequire(globals.require.resolve(`${plugin}/node_modules/${module}`)) } + + loseFocus () { + if (process.platform === 'darwin') { + this.remote.Menu.sendActionToFirstResponder('hide:') + } + } } diff --git a/terminus-core/src/services/hostApp.service.ts b/terminus-core/src/services/hostApp.service.ts index 0956f644..5a23fd96 100644 --- a/terminus-core/src/services/hostApp.service.ts +++ b/terminus-core/src/services/hostApp.service.ts @@ -86,10 +86,6 @@ export class HostAppService { this.electron.ipcRenderer.send('window-focus') } - toggleWindow () { - this.electron.ipcRenderer.send('window-toggle-focus') - } - minimize () { this.electron.ipcRenderer.send('window-minimize') }