aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/Tray.js
diff options
context:
space:
mode:
authorLibravatar Amine Mouafik <amine@mouafik.fr>2020-02-21 17:12:40 +0100
committerLibravatar Amine Mouafik <amine@mouafik.fr>2020-02-21 17:12:40 +0100
commitdfb1dd3c8c3e106fe19fe2801b1b92d662ce8026 (patch)
treea4ceaa003e470bb7147ebf2714b24f9763e7dae0 /src/lib/Tray.js
parentReview wording for setting toggling tray on/off (diff)
downloadferdium-app-dfb1dd3c8c3e106fe19fe2801b1b92d662ce8026.tar.gz
ferdium-app-dfb1dd3c8c3e106fe19fe2801b1b92d662ce8026.tar.zst
ferdium-app-dfb1dd3c8c3e106fe19fe2801b1b92d662ce8026.zip
Make tray bring-to-top/show/hide on click, show menu on right click
Diffstat (limited to 'src/lib/Tray.js')
-rw-r--r--src/lib/Tray.js14
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 @@
1import { 1import {
2 app, Tray, Menu, systemPreferences, nativeTheme, nativeImage, 2 app, Menu, nativeImage, nativeTheme, systemPreferences, Tray,
3} from 'electron'; 3} from 'electron';
4import path from 'path'; 4import 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') {