From 5cf570beb4f74b284fde6eead2c95df706072520 Mon Sep 17 00:00:00 2001 From: Amine Date: Wed, 13 May 2020 04:08:58 +0000 Subject: Use Tray popUpContextMenu on macOS/Windows only (#741) --- src/lib/Tray.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/lib/Tray.js') diff --git a/src/lib/Tray.js b/src/lib/Tray.js index d875eef63..0afb6289b 100644 --- a/src/lib/Tray.js +++ b/src/lib/Tray.js @@ -2,6 +2,11 @@ import { app, Menu, nativeImage, nativeTheme, systemPreferences, Tray, ipcMain, } from 'electron'; import path from 'path'; +import { + isMac, + isWindows, + isLinux, +} from '../environment'; const FILE_EXTENSION = process.platform === 'win32' ? 'ico' : 'png'; const INDICATOR_TRAY_PLAIN = 'tray'; @@ -50,6 +55,9 @@ export default class TrayIcon { const { isAppMuted } = appSettings.data; this.trayMenuTemplate[1].label = isAppMuted ? 'Enable Notifications && Audio' : 'Disable Notifications && Audio'; this.trayMenu = Menu.buildFromTemplate(this.trayMenuTemplate); + if (isLinux) { + this.trayIcon.setContextMenu(this.trayMenu); + } } } @@ -61,6 +69,9 @@ export default class TrayIcon { this.trayIcon.setToolTip('Ferdi'); this.trayMenu = Menu.buildFromTemplate(this.trayMenuTemplate); + if (isLinux) { + this.trayIcon.setContextMenu(this.trayMenu); + } ipcMain.on('initialAppSettings', (event, appSettings) => { this._updateTrayMenu(appSettings); @@ -81,9 +92,11 @@ export default class TrayIcon { } }); - this.trayIcon.on('right-click', () => { - this.trayIcon.popUpContextMenu(this.trayMenu); - }); + if (isMac || isWindows) { + this.trayIcon.on('right-click', () => { + this.trayIcon.popUpContextMenu(this.trayMenu); + }); + } if (process.platform === 'darwin') { this.themeChangeSubscriberId = systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', () => { -- cgit v1.2.3-54-g00ecf