diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-10-04 17:02:35 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-10-05 13:03:00 +0200 |
| commit | fbc6bccc4e2c2b082d54c0153640e9adae2319cc (patch) | |
| tree | d8f6dc2d2956472b20ac9e9742a271e5a13e17c7 /gui/src | |
| parent | 2bbc3b3e1e9f129282a1882cfbcd2be68a2579ee (diff) | |
| download | mullvadvpn-fbc6bccc4e2c2b082d54c0153640e9adae2319cc.tar.xz mullvadvpn-fbc6bccc4e2c2b082d54c0153640e9adae2319cc.zip | |
Prevent app from showing when dragging icon on macOS
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/main/index.ts | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index b211d9fe12..6c2aa76f5f 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -1932,17 +1932,21 @@ class ApplicationMain { } this.tray?.on('click', () => this.windowController?.show()); } else { - 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('click', (event) => { + // The app shouldn't become visible if the user is reordering the tray icons on macOS. The + // tray icon becomes draggable when holding the command key (meta). + if (process.platform !== 'darwin' || !event.metaKey) { + 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()); |
