From 015736486c22d1edf6c11e02912ca2be0a076ba1 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 22 Jul 2025 19:02:41 +0200 Subject: [PATCH] tray: only quit if server is stopped; hide in tray when starting minimzed --- src/launcher/toolbar.js | 2 +- src/server/electron-window.js | 7 +------ src/server/index.js | 27 ++++++++++++++++++++------- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/launcher/toolbar.js b/src/launcher/toolbar.js index ee623b60..fa3208d4 100644 --- a/src/launcher/toolbar.js +++ b/src/launcher/toolbar.js @@ -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)=>{ diff --git a/src/server/electron-window.js b/src/server/electron-window.js index 77786bc0..b0231faa 100644 --- a/src/server/electron-window.js +++ b/src/server/electron-window.js @@ -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() } }) diff --git a/src/server/index.js b/src/server/index.js index 7c74cca6..c222b065 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -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 + } })