From c41efbd62bcd9a28f1bc32fa5b76cde80574294e Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Wed, 12 Jul 2017 20:24:35 +0200 Subject: [PATCH] quit properly (fixes #109) --- app/main.js | 14 +------------- .../src/components/appRoot.component.ts | 2 -- terminus-core/src/index.ts | 2 -- terminus-core/src/services/hostApp.service.ts | 6 ------ terminus-core/src/services/quitter.service.ts | 18 ------------------ 5 files changed, 1 insertion(+), 41 deletions(-) delete mode 100644 terminus-core/src/services/quitter.service.ts diff --git a/app/main.js b/app/main.js index 09e5295a..e3cc7046 100644 --- a/app/main.js +++ b/app/main.js @@ -30,28 +30,18 @@ if (!process.env.TERMINUS_PLUGINS) { } setupWindowManagement = () => { - let windowCloseable - app.window.on('show', () => { app.window.webContents.send('host:window-shown') }) app.window.on('close', (e) => { windowConfig.set('windowBoundaries', app.window.getBounds()) - if (!windowCloseable) { - app.window.minimize() - e.preventDefault() - } }) app.window.on('closed', () => { app.window = null }) - electron.ipcMain.on('window-closeable', (event, flag) => { - windowCloseable = flag - }) - electron.ipcMain.on('window-focus', () => { app.window.focus() }) @@ -102,8 +92,6 @@ setupWindowManagement = () => { electron.ipcMain.on('window-set-always-on-top', (event, flag) => { app.window.setAlwaysOnTop(flag) }) - - app.on('before-quit', () => windowCloseable = true) } @@ -131,7 +119,7 @@ setupMenu = () => { label: 'Quit', accelerator: 'Cmd+Q', click () { - app.window.webContents.send('host:quit-request') + app.quit() } } ] diff --git a/terminus-core/src/components/appRoot.component.ts b/terminus-core/src/components/appRoot.component.ts index d57e51db..6d91b0fc 100644 --- a/terminus-core/src/components/appRoot.component.ts +++ b/terminus-core/src/components/appRoot.component.ts @@ -5,7 +5,6 @@ import { ElectronService } from '../services/electron.service' import { HostAppService, Platform } from '../services/hostApp.service' import { HotkeysService } from '../services/hotkeys.service' import { Logger, LogService } from '../services/log.service' -import { QuitterService } from '../services/quitter.service' import { ConfigService } from '../services/config.service' import { DockingService } from '../services/docking.service' import { TabRecoveryService } from '../services/tabRecovery.service' @@ -57,7 +56,6 @@ export class AppRootComponent { @Inject(ToolbarButtonProvider) private toolbarButtonProviders: ToolbarButtonProvider[], log: LogService, _themes: ThemesService, - _quitter: QuitterService, ) { this.logger = log.create('main') this.logger.info('v', electron.app.getVersion()) diff --git a/terminus-core/src/index.ts b/terminus-core/src/index.ts index e5a0d9ee..21697a09 100644 --- a/terminus-core/src/index.ts +++ b/terminus-core/src/index.ts @@ -11,7 +11,6 @@ import { ElectronService } from './services/electron.service' import { HostAppService } from './services/hostApp.service' import { LogService } from './services/log.service' import { HotkeysService, AppHotkeyProvider } from './services/hotkeys.service' -import { QuitterService } from './services/quitter.service' import { DockingService } from './services/docking.service' import { TabRecoveryService } from './services/tabRecovery.service' import { ThemesService } from './services/themes.service' @@ -42,7 +41,6 @@ const PROVIDERS = [ LogService, TabRecoveryService, ThemesService, - QuitterService, { provide: HotkeyProvider, useClass: AppHotkeyProvider, multi: true }, { provide: Theme, useClass: StandardTheme, multi: true }, { provide: ConfigProvider, useClass: CoreConfigProvider, multi: true }, diff --git a/terminus-core/src/services/hostApp.service.ts b/terminus-core/src/services/hostApp.service.ts index 5c066963..4eccd72c 100644 --- a/terminus-core/src/services/hostApp.service.ts +++ b/terminus-core/src/services/hostApp.service.ts @@ -18,7 +18,6 @@ export interface Bounds { export class HostAppService { platform: Platform nodePlatform: string - quitRequested = new EventEmitter() preferencesMenu$ = new Subject() ready = new EventEmitter() shown = new EventEmitter() @@ -39,7 +38,6 @@ export class HostAppService { linux: Platform.Linux }[this.nodePlatform] - electron.ipcRenderer.on('host:quit-request', () => this.zone.run(() => this.quitRequested.emit())) electron.ipcRenderer.on('host:preferences-menu', () => this.zone.run(() => this.preferencesMenu$.next())) electron.ipcRenderer.on('uncaughtException', ($event, err) => { @@ -79,10 +77,6 @@ export class HostAppService { this.getWindow().webContents.openDevTools() } - setCloseable (flag: boolean) { - this.electron.ipcRenderer.send('window-set-closeable', flag) - } - focusWindow () { this.electron.ipcRenderer.send('window-focus') } diff --git a/terminus-core/src/services/quitter.service.ts b/terminus-core/src/services/quitter.service.ts deleted file mode 100644 index 5c8f8c65..00000000 --- a/terminus-core/src/services/quitter.service.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Injectable } from '@angular/core' -import { HostAppService } from '../services/hostApp.service' - -@Injectable() -export class QuitterService { - constructor ( - private hostApp: HostAppService, - ) { - hostApp.quitRequested.subscribe(() => { - this.quit() - }) - } - - quit () { - this.hostApp.setCloseable(true) - this.hostApp.quit() - } -}