diff options
Diffstat (limited to 'src/lib/Tray.js')
-rw-r--r-- | src/lib/Tray.js | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lib/Tray.js b/src/lib/Tray.js index c0d936599..84ee8e3bb 100644 --- a/src/lib/Tray.js +++ b/src/lib/Tray.js | |||
@@ -1,5 +1,5 @@ | |||
1 | import { | 1 | import { |
2 | app, Tray, Menu, systemPreferences, nativeTheme, nativeImage, | 2 | app, Menu, nativeImage, nativeTheme, systemPreferences, Tray, |
3 | } from 'electron'; | 3 | } from 'electron'; |
4 | import path from 'path'; | 4 | import path from 'path'; |
5 | 5 | ||
@@ -37,14 +37,20 @@ export default class TrayIcon { | |||
37 | ]; | 37 | ]; |
38 | 38 | ||
39 | const trayMenu = Menu.buildFromTemplate(trayMenuTemplate); | 39 | const trayMenu = Menu.buildFromTemplate(trayMenuTemplate); |
40 | this.trayIcon.setContextMenu(trayMenu); | ||
41 | 40 | ||
42 | this.trayIcon.on('click', () => { | 41 | this.trayIcon.on('click', () => { |
43 | if (app.mainWindow.isMinimized()) { | 42 | if (app.mainWindow.isMinimized()) { |
44 | app.mainWindow.restore(); | 43 | app.mainWindow.restore(); |
44 | } else if (app.mainWindow.isVisible()) { | ||
45 | app.mainWindow.hide(); | ||
46 | } else { | ||
47 | app.mainWindow.show(); | ||
48 | app.mainWindow.focus(); | ||
45 | } | 49 | } |
46 | app.mainWindow.show(); | 50 | }); |
47 | app.mainWindow.focus(); | 51 | |
52 | this.trayIcon.on('right-click', () => { | ||
53 | this.trayIcon.popUpContextMenu(trayMenu); | ||
48 | }); | 54 | }); |
49 | 55 | ||
50 | if (process.platform === 'darwin') { | 56 | if (process.platform === 'darwin') { |