diff --git a/jslib b/jslib index 2032e14285..36dfdf24f1 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 2032e14285ac3d4b2f3e9e310ad19ca1dd40c525 +Subproject commit 36dfdf24f146062447d2b8884fbf84981ecff664 diff --git a/src/main/tray.main.ts b/src/main/tray.main.ts index fdbe39e7a1..83258991bc 100644 --- a/src/main/tray.main.ts +++ b/src/main/tray.main.ts @@ -1,4 +1,5 @@ import { + Menu, nativeImage, Tray, } from 'electron'; @@ -10,6 +11,7 @@ import { DesktopConstants } from '../desktopConstants'; export class TrayMain { private tray: Tray; + private menu: Menu; private icon: string | Electron.NativeImage; private pressedIcon: Electron.NativeImage; @@ -27,6 +29,13 @@ export class TrayMain { } init() { + if (process.platform === 'linux') { + this.menu = Menu.buildFromTemplate([{ + label: this.appName, + click: () => this.open(), + }]); + } + this.windowMain.win.on('minimize', async (e: Event) => { if (await this.minToTray()) { e.preventDefault(); @@ -52,15 +61,19 @@ export class TrayMain { if (this.pressedIcon != null) { this.tray.setPressedImage(this.pressedIcon); } + if (this.menu != null) { + this.tray.setContextMenu(this.menu); + } - this.tray.on('click', () => { - if (this.windowMain.win.isVisible()) { - this.windowMain.win.hide(); - } else { - this.windowMain.win.show(); - } - }); - + this.tray.on('click', () => open()); this.windowMain.win.hide(); } + + private open() { + if (this.windowMain.win.isVisible()) { + this.windowMain.win.hide(); + } else { + this.windowMain.win.show(); + } + } }