tray: only quit if server is stopped; hide in tray when starting minimzed
This commit is contained in:
parent
374ef68028
commit
015736486c
3 changed files with 22 additions and 14 deletions
|
|
@ -116,7 +116,7 @@ menu.append(new MenuItem({type: 'submenu' , label: 'Launcher', submenu: [
|
|||
}
|
||||
}),
|
||||
new MenuItem({
|
||||
label: 'Start minimized',
|
||||
label: 'Start hidden (in tray)',
|
||||
type: 'checkbox',
|
||||
checked: settings.remote.read('startMinimized'),
|
||||
click: (e)=>{
|
||||
|
|
|
|||
|
|
@ -61,13 +61,8 @@ module.exports = function(options={}) {
|
|||
window.setBounds(geometry)
|
||||
|
||||
window.once('ready-to-show', ()=>{
|
||||
window.show()
|
||||
if (options.id === 'launcher' && settings.read('startMinimized')) {
|
||||
if (process.platform === 'darwin') {
|
||||
window.hide()
|
||||
} else {
|
||||
window.minimize()
|
||||
}
|
||||
window.hide()
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -177,20 +177,27 @@ function stopServerProcess() {
|
|||
|
||||
if (settings.read('no-gui')) {
|
||||
if (serverProcess) serverProcess.kill('SIGINT')
|
||||
serverProcess = null
|
||||
return
|
||||
}
|
||||
|
||||
var toClose = [...clientWindows].filter(w=>w && !w.isDestroyed()),
|
||||
var toClose = clientWindows.filter(w=>w && !w.isDestroyed()),
|
||||
closed = 0
|
||||
|
||||
if (toClose.length === 0) serverProcess.kill('SIGINT')
|
||||
if (toClose.length === 0) {
|
||||
serverProcess.kill('SIGINT')
|
||||
serverProcess = null
|
||||
}
|
||||
|
||||
for (var w of toClose) {
|
||||
w.on('closed', ()=>{
|
||||
closed++
|
||||
if (closed === toClose.length) {
|
||||
clientWindows = []
|
||||
if (serverProcess) serverProcess.kill('SIGINT')
|
||||
if (serverProcess) {
|
||||
serverProcess.kill('SIGINT')
|
||||
serverProcess = null
|
||||
}
|
||||
}
|
||||
})
|
||||
w.close()
|
||||
|
|
@ -227,14 +234,14 @@ function startLauncher() {
|
|||
})
|
||||
|
||||
launcher.on('will-close', ()=>{
|
||||
if (clientWindows.length) {
|
||||
if (clientWindows.some(w=>w && !w.isDestroyed())) {
|
||||
launcher.hide()
|
||||
e.preventDefault()
|
||||
}
|
||||
})
|
||||
|
||||
launcher.on('close', (e)=>{
|
||||
if (clientWindows.length) {
|
||||
if (clientWindows.some(w=>w && !w.isDestroyed()) && serverProcess) {
|
||||
launcher.hide()
|
||||
e.preventDefault()
|
||||
return
|
||||
|
|
@ -345,13 +352,19 @@ if (settings.read('docs')) {
|
|||
|
||||
app.on('ready', ()=>{
|
||||
process.on('SIGINT', function() {
|
||||
if (serverProcess) serverProcess.kill('SIGINT')
|
||||
if (serverProcess) {
|
||||
serverProcess.kill('SIGINT')
|
||||
serverProcess = null
|
||||
}
|
||||
process.exit(0)
|
||||
})
|
||||
})
|
||||
|
||||
app.on('before-quit',()=>{
|
||||
if (serverProcess) serverProcess.kill('SIGINT')
|
||||
if (serverProcess) {
|
||||
serverProcess.kill('SIGINT')
|
||||
serverProcess = null
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue