diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-06-04 09:40:58 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-06-04 09:40:58 +0200 |
| commit | f199a6e56724823be02e614e1174185964edaeba (patch) | |
| tree | 7e4201b7c47eb49cbe8c0a20fa429b2336dc17c9 | |
| parent | 53be834b991ae1622bd580c98ecec86b82418ba8 (diff) | |
| parent | 8ead3b297a7605b3a38770c9bd5a6124b44cb2a0 (diff) | |
| download | mullvadvpn-f199a6e56724823be02e614e1174185964edaeba.tar.xz mullvadvpn-f199a6e56724823be02e614e1174185964edaeba.zip | |
Merge branch 'macos-big-sur-context-menus-workaround'
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | gui/src/main/index.ts | 15 |
2 files changed, 15 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index b7a48559e2..11aeacbcce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,7 @@ Line wrap the file at 100 chars. Th #### MacOS - Set correct permissions for daemon's launch file in installer. - Fix downgrades on macOS silently keeping previous version. +- Fix other menubar context menus not always closing when opening app on macOS 11. #### Android - Fix UI sometimes not updating correctly while no split screen or after having a dialog from diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index 22ddb47954..4e9aacc85c 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -10,6 +10,7 @@ import { shell, Tray, } from 'electron'; +import os from 'os'; import * as path from 'path'; import { sprintf } from 'sprintf-js'; import * as uuid from 'uuid'; @@ -1764,7 +1765,19 @@ class ApplicationMain { } this.tray?.on('click', () => this.windowController?.show()); } else { - this.tray?.on('click', () => this.windowController?.toggle()); + this.tray?.on('click', () => { + const isMacOsBigSur = process.platform === 'darwin' && parseInt(os.release(), 10) >= 20; + if (isMacOsBigSur && !this.windowController?.isVisible()) { + // This is a workaround for this Electron issue, when it's resolved + // `this.windowController?.toggle()` should do the trick on all platforms: + // https://github.com/electron/electron/issues/28776 + const contextMenu = Menu.buildFromTemplate([]); + contextMenu.on('menu-will-show', () => this.windowController?.show()); + this.tray?.popUpContextMenu(contextMenu); + } else { + this.windowController?.toggle(); + } + }); this.tray?.on('right-click', () => this.windowController?.hide()); } } |
