From e75c62bf0f7543f858a2676e1e4606d057735dd1 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Tue, 27 Feb 2018 21:54:40 +0000 Subject: [PATCH] Electron: Fix logic of hidding app in macOS --- ElectronClient/app/ElectronAppWrapper.js | 8 +++++++- ElectronClient/app/app.js | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ElectronClient/app/ElectronAppWrapper.js b/ElectronClient/app/ElectronAppWrapper.js index 964519bbdf..84cf1d3f16 100644 --- a/ElectronClient/app/ElectronAppWrapper.js +++ b/ElectronClient/app/ElectronAppWrapper.js @@ -79,7 +79,7 @@ class ElectronAppWrapper { this.win_ = null; } else { event.preventDefault(); - this.win_.hide(); + this.hide(); } } else { if (this.trayShown() && !this.willQuitApp_) { @@ -118,6 +118,12 @@ class ElectronAppWrapper { return !!this.tray_; } + // This method is used in macOS only to hide the whole app (and not just the main window) + // including the menu bar. This follows the macOS way of hidding an app. + hide() { + this.electronApp_.hide(); + } + buildDir() { if (this.buildDir_) return this.buildDir_; let dir = __dirname + '/build'; diff --git a/ElectronClient/app/app.js b/ElectronClient/app/app.js index a411cf0fe1..463b42fd5d 100644 --- a/ElectronClient/app/app.js +++ b/ElectronClient/app/app.js @@ -365,7 +365,7 @@ class Application extends BaseApplication { label: _('Hide %s', 'Joplin'), platforms: ['darwin'], accelerator: 'CommandOrControl+H', - click: () => { bridge().window().hide() } + click: () => { bridge().electronApp().hide() } }, { type: 'separator', }, {