mirror of
https://github.com/Eugeny/tabby
synced 2024-12-14 23:32:41 +00:00
quit properly (fixes #109)
This commit is contained in:
parent
1643ca2bd5
commit
c41efbd62b
5 changed files with 1 additions and 41 deletions
14
app/main.js
14
app/main.js
|
@ -30,28 +30,18 @@ if (!process.env.TERMINUS_PLUGINS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
setupWindowManagement = () => {
|
setupWindowManagement = () => {
|
||||||
let windowCloseable
|
|
||||||
|
|
||||||
app.window.on('show', () => {
|
app.window.on('show', () => {
|
||||||
app.window.webContents.send('host:window-shown')
|
app.window.webContents.send('host:window-shown')
|
||||||
})
|
})
|
||||||
|
|
||||||
app.window.on('close', (e) => {
|
app.window.on('close', (e) => {
|
||||||
windowConfig.set('windowBoundaries', app.window.getBounds())
|
windowConfig.set('windowBoundaries', app.window.getBounds())
|
||||||
if (!windowCloseable) {
|
|
||||||
app.window.minimize()
|
|
||||||
e.preventDefault()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
app.window.on('closed', () => {
|
app.window.on('closed', () => {
|
||||||
app.window = null
|
app.window = null
|
||||||
})
|
})
|
||||||
|
|
||||||
electron.ipcMain.on('window-closeable', (event, flag) => {
|
|
||||||
windowCloseable = flag
|
|
||||||
})
|
|
||||||
|
|
||||||
electron.ipcMain.on('window-focus', () => {
|
electron.ipcMain.on('window-focus', () => {
|
||||||
app.window.focus()
|
app.window.focus()
|
||||||
})
|
})
|
||||||
|
@ -102,8 +92,6 @@ setupWindowManagement = () => {
|
||||||
electron.ipcMain.on('window-set-always-on-top', (event, flag) => {
|
electron.ipcMain.on('window-set-always-on-top', (event, flag) => {
|
||||||
app.window.setAlwaysOnTop(flag)
|
app.window.setAlwaysOnTop(flag)
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('before-quit', () => windowCloseable = true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,7 +119,7 @@ setupMenu = () => {
|
||||||
label: 'Quit',
|
label: 'Quit',
|
||||||
accelerator: 'Cmd+Q',
|
accelerator: 'Cmd+Q',
|
||||||
click () {
|
click () {
|
||||||
app.window.webContents.send('host:quit-request')
|
app.quit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -5,7 +5,6 @@ import { ElectronService } from '../services/electron.service'
|
||||||
import { HostAppService, Platform } from '../services/hostApp.service'
|
import { HostAppService, Platform } from '../services/hostApp.service'
|
||||||
import { HotkeysService } from '../services/hotkeys.service'
|
import { HotkeysService } from '../services/hotkeys.service'
|
||||||
import { Logger, LogService } from '../services/log.service'
|
import { Logger, LogService } from '../services/log.service'
|
||||||
import { QuitterService } from '../services/quitter.service'
|
|
||||||
import { ConfigService } from '../services/config.service'
|
import { ConfigService } from '../services/config.service'
|
||||||
import { DockingService } from '../services/docking.service'
|
import { DockingService } from '../services/docking.service'
|
||||||
import { TabRecoveryService } from '../services/tabRecovery.service'
|
import { TabRecoveryService } from '../services/tabRecovery.service'
|
||||||
|
@ -57,7 +56,6 @@ export class AppRootComponent {
|
||||||
@Inject(ToolbarButtonProvider) private toolbarButtonProviders: ToolbarButtonProvider[],
|
@Inject(ToolbarButtonProvider) private toolbarButtonProviders: ToolbarButtonProvider[],
|
||||||
log: LogService,
|
log: LogService,
|
||||||
_themes: ThemesService,
|
_themes: ThemesService,
|
||||||
_quitter: QuitterService,
|
|
||||||
) {
|
) {
|
||||||
this.logger = log.create('main')
|
this.logger = log.create('main')
|
||||||
this.logger.info('v', electron.app.getVersion())
|
this.logger.info('v', electron.app.getVersion())
|
||||||
|
|
|
@ -11,7 +11,6 @@ import { ElectronService } from './services/electron.service'
|
||||||
import { HostAppService } from './services/hostApp.service'
|
import { HostAppService } from './services/hostApp.service'
|
||||||
import { LogService } from './services/log.service'
|
import { LogService } from './services/log.service'
|
||||||
import { HotkeysService, AppHotkeyProvider } from './services/hotkeys.service'
|
import { HotkeysService, AppHotkeyProvider } from './services/hotkeys.service'
|
||||||
import { QuitterService } from './services/quitter.service'
|
|
||||||
import { DockingService } from './services/docking.service'
|
import { DockingService } from './services/docking.service'
|
||||||
import { TabRecoveryService } from './services/tabRecovery.service'
|
import { TabRecoveryService } from './services/tabRecovery.service'
|
||||||
import { ThemesService } from './services/themes.service'
|
import { ThemesService } from './services/themes.service'
|
||||||
|
@ -42,7 +41,6 @@ const PROVIDERS = [
|
||||||
LogService,
|
LogService,
|
||||||
TabRecoveryService,
|
TabRecoveryService,
|
||||||
ThemesService,
|
ThemesService,
|
||||||
QuitterService,
|
|
||||||
{ provide: HotkeyProvider, useClass: AppHotkeyProvider, multi: true },
|
{ provide: HotkeyProvider, useClass: AppHotkeyProvider, multi: true },
|
||||||
{ provide: Theme, useClass: StandardTheme, multi: true },
|
{ provide: Theme, useClass: StandardTheme, multi: true },
|
||||||
{ provide: ConfigProvider, useClass: CoreConfigProvider, multi: true },
|
{ provide: ConfigProvider, useClass: CoreConfigProvider, multi: true },
|
||||||
|
|
|
@ -18,7 +18,6 @@ export interface Bounds {
|
||||||
export class HostAppService {
|
export class HostAppService {
|
||||||
platform: Platform
|
platform: Platform
|
||||||
nodePlatform: string
|
nodePlatform: string
|
||||||
quitRequested = new EventEmitter<any>()
|
|
||||||
preferencesMenu$ = new Subject<void>()
|
preferencesMenu$ = new Subject<void>()
|
||||||
ready = new EventEmitter<any>()
|
ready = new EventEmitter<any>()
|
||||||
shown = new EventEmitter<any>()
|
shown = new EventEmitter<any>()
|
||||||
|
@ -39,7 +38,6 @@ export class HostAppService {
|
||||||
linux: Platform.Linux
|
linux: Platform.Linux
|
||||||
}[this.nodePlatform]
|
}[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('host:preferences-menu', () => this.zone.run(() => this.preferencesMenu$.next()))
|
||||||
|
|
||||||
electron.ipcRenderer.on('uncaughtException', ($event, err) => {
|
electron.ipcRenderer.on('uncaughtException', ($event, err) => {
|
||||||
|
@ -79,10 +77,6 @@ export class HostAppService {
|
||||||
this.getWindow().webContents.openDevTools()
|
this.getWindow().webContents.openDevTools()
|
||||||
}
|
}
|
||||||
|
|
||||||
setCloseable (flag: boolean) {
|
|
||||||
this.electron.ipcRenderer.send('window-set-closeable', flag)
|
|
||||||
}
|
|
||||||
|
|
||||||
focusWindow () {
|
focusWindow () {
|
||||||
this.electron.ipcRenderer.send('window-focus')
|
this.electron.ipcRenderer.send('window-focus')
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue