diff options
author | Amine <amine@mouafik.fr> | 2020-05-13 04:08:58 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-13 04:08:58 +0000 |
commit | 5cf570beb4f74b284fde6eead2c95df706072520 (patch) | |
tree | 3a2920273afd1192f4367627e7d4b87e3cfa1321 /src/lib | |
parent | docs: add dandelionadia as a contributor (#740) (diff) | |
download | ferdium-app-5cf570beb4f74b284fde6eead2c95df706072520.tar.gz ferdium-app-5cf570beb4f74b284fde6eead2c95df706072520.tar.zst ferdium-app-5cf570beb4f74b284fde6eead2c95df706072520.zip |
Use Tray popUpContextMenu on macOS/Windows only (#741)
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Tray.js | 19 |
1 files changed, 16 insertions, 3 deletions
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 { | |||
2 | app, Menu, nativeImage, nativeTheme, systemPreferences, Tray, ipcMain, | 2 | app, Menu, nativeImage, nativeTheme, systemPreferences, Tray, ipcMain, |
3 | } from 'electron'; | 3 | } from 'electron'; |
4 | import path from 'path'; | 4 | import path from 'path'; |
5 | import { | ||
6 | isMac, | ||
7 | isWindows, | ||
8 | isLinux, | ||
9 | } from '../environment'; | ||
5 | 10 | ||
6 | const FILE_EXTENSION = process.platform === 'win32' ? 'ico' : 'png'; | 11 | const FILE_EXTENSION = process.platform === 'win32' ? 'ico' : 'png'; |
7 | const INDICATOR_TRAY_PLAIN = 'tray'; | 12 | const INDICATOR_TRAY_PLAIN = 'tray'; |
@@ -50,6 +55,9 @@ export default class TrayIcon { | |||
50 | const { isAppMuted } = appSettings.data; | 55 | const { isAppMuted } = appSettings.data; |
51 | this.trayMenuTemplate[1].label = isAppMuted ? 'Enable Notifications && Audio' : 'Disable Notifications && Audio'; | 56 | this.trayMenuTemplate[1].label = isAppMuted ? 'Enable Notifications && Audio' : 'Disable Notifications && Audio'; |
52 | this.trayMenu = Menu.buildFromTemplate(this.trayMenuTemplate); | 57 | this.trayMenu = Menu.buildFromTemplate(this.trayMenuTemplate); |
58 | if (isLinux) { | ||
59 | this.trayIcon.setContextMenu(this.trayMenu); | ||
60 | } | ||
53 | } | 61 | } |
54 | } | 62 | } |
55 | 63 | ||
@@ -61,6 +69,9 @@ export default class TrayIcon { | |||
61 | this.trayIcon.setToolTip('Ferdi'); | 69 | this.trayIcon.setToolTip('Ferdi'); |
62 | 70 | ||
63 | this.trayMenu = Menu.buildFromTemplate(this.trayMenuTemplate); | 71 | this.trayMenu = Menu.buildFromTemplate(this.trayMenuTemplate); |
72 | if (isLinux) { | ||
73 | this.trayIcon.setContextMenu(this.trayMenu); | ||
74 | } | ||
64 | 75 | ||
65 | ipcMain.on('initialAppSettings', (event, appSettings) => { | 76 | ipcMain.on('initialAppSettings', (event, appSettings) => { |
66 | this._updateTrayMenu(appSettings); | 77 | this._updateTrayMenu(appSettings); |
@@ -81,9 +92,11 @@ export default class TrayIcon { | |||
81 | } | 92 | } |
82 | }); | 93 | }); |
83 | 94 | ||
84 | this.trayIcon.on('right-click', () => { | 95 | if (isMac || isWindows) { |
85 | this.trayIcon.popUpContextMenu(this.trayMenu); | 96 | this.trayIcon.on('right-click', () => { |
86 | }); | 97 | this.trayIcon.popUpContextMenu(this.trayMenu); |
98 | }); | ||
99 | } | ||
87 | 100 | ||
88 | if (process.platform === 'darwin') { | 101 | if (process.platform === 'darwin') { |
89 | this.themeChangeSubscriberId = systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', () => { | 102 | this.themeChangeSubscriberId = systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', () => { |