diff options
| -rw-r--r-- | app/main.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/app/main.js b/app/main.js index 0a7fb6172a..6bf18490a3 100644 --- a/app/main.js +++ b/app/main.js @@ -20,6 +20,7 @@ const ApplicationMain = { _logFilePath: '', _oldLogFilePath: (null: ?string), _connectionFilePollInterval: (null: ?IntervalID), + _shouldQuit: false, run() { if (this._ensureSingleInstance()) { @@ -33,6 +34,7 @@ const ApplicationMain = { app.on('ready', () => this._onReady()); app.on('window-all-closed', () => app.quit()); + app.on('before-quit', () => this._onBeforeQuit()); }, _ensureSingleInstance() { @@ -119,6 +121,11 @@ const ApplicationMain = { } }, + _onBeforeQuit() { + this._shouldQuit = true; + return true; + }, + async _onReady() { const window = this._createWindow(); const tray = this._createTray(); @@ -149,6 +156,10 @@ const ApplicationMain = { case 'darwin': this._installMacOsMenubarAppWindowHandlers(tray, windowController); break; + case 'linux': + this._installGenericMenubarAppWindowHandlers(tray, windowController); + this._installLinuxWindowCloseHandler(windowController); + break; default: this._installGenericMenubarAppWindowHandlers(tray, windowController); break; @@ -461,6 +472,18 @@ const ApplicationMain = { }); windowController.show(); }, + + _installLinuxWindowCloseHandler(windowController: WindowController) { + windowController.window.on('close', (closeEvent) => { + if (process.platform === 'linux' && !this._shouldQuit) { + closeEvent.preventDefault(); + windowController.hide(); + return false; + } else { + return true; + } + }); + }, }; ApplicationMain.run(); |
