diff --git a/electron/src/electron-main.js b/electron/src/electron-main.js index ccf1d8f807..bd3a1b5cc2 100644 --- a/electron/src/electron-main.js +++ b/electron/src/electron-main.js @@ -2,6 +2,7 @@ const {app, BrowserWindow} = require('electron'); let mainWindow = null; +let appQuitting = false; app.on('ready', () => { mainWindow = new BrowserWindow({ @@ -12,8 +13,26 @@ app.on('ready', () => { mainWindow.on('closed', () => { mainWindow = null; }); + mainWindow.on('close', (e) => { + if (process.platform == 'darwin' && !appQuitting) { + // On Mac, closing the window just hides it + // (this is generally how single-window Mac apps + // behave, eg. Mail.app) + e.preventDefault(); + mainWindow.hide(); + return false; + } + }); }); app.on('window-all-closed', () => { app.quit(); }); + +app.on('activate', () => { + mainWindow.show(); +}); + +app.on('before-quit', () => { + appQuitting = true; +});