diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-08-06 09:51:23 -0300 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-08-07 08:38:09 -0300 |
| commit | 2a2e9270e2f7f61adaafe33a672a47f4553fd797 (patch) | |
| tree | b1cd41eee98363ac913183e35cbf1c2edb43c3c3 | |
| parent | e4d5a3ba555b7d4abd0aa3447c554fa9a4fc0594 (diff) | |
| download | mullvadvpn-2a2e9270e2f7f61adaafe33a672a47f4553fd797.tar.xz mullvadvpn-2a2e9270e2f7f61adaafe33a672a47f4553fd797.zip | |
Handle window close on Linux
| -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(); |
