1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix windows tray icon click (#1908)

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2021-01-08 16:44:33 +02:00 committed by GitHub
parent 3fc552a466
commit da2cc70141
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,7 +10,7 @@ import { workspaceStore } from "../common/workspace-store";
import { preferencesURL } from "../renderer/components/+preferences/preferences.route"; import { preferencesURL } from "../renderer/components/+preferences/preferences.route";
import { clusterViewURL } from "../renderer/components/cluster-manager/cluster-view.route"; import { clusterViewURL } from "../renderer/components/cluster-manager/cluster-view.route";
import logger from "./logger"; import logger from "./logger";
import { isDevelopment } from "../common/vars"; import { isDevelopment, isWindows } from "../common/vars";
import { exitApp } from "./exit-app"; import { exitApp } from "./exit-app";
// note: instance of Tray should be saved somewhere, otherwise it disappears // note: instance of Tray should be saved somewhere, otherwise it disappears
@ -29,7 +29,7 @@ export function initTray(windowManager: WindowManager) {
try { try {
const menu = createTrayMenu(windowManager); const menu = createTrayMenu(windowManager);
buildTray(getTrayIcon(), menu); buildTray(getTrayIcon(), menu, windowManager);
} catch (err) { } catch (err) {
logger.error(`[TRAY]: building failed: ${err}`); logger.error(`[TRAY]: building failed: ${err}`);
} }
@ -42,20 +42,25 @@ export function initTray(windowManager: WindowManager) {
}; };
} }
export function buildTray(icon: string | NativeImage, menu: Menu) { function buildTray(icon: string | NativeImage, menu: Menu, windowManager: WindowManager) {
if (!tray) { if (!tray) {
tray = new Tray(icon); tray = new Tray(icon);
tray.setToolTip(packageInfo.description); tray.setToolTip(packageInfo.description);
tray.setIgnoreDoubleClickEvents(true); tray.setIgnoreDoubleClickEvents(true);
} tray.setImage(icon);
tray.setContextMenu(menu);
tray.setImage(icon); if (isWindows) {
tray.setContextMenu(menu); tray.on("click", () => {
windowManager.ensureMainWindow();
});
}
}
return tray; return tray;
} }
export function createTrayMenu(windowManager: WindowManager): Menu { function createTrayMenu(windowManager: WindowManager): Menu {
return Menu.buildFromTemplate([ return Menu.buildFromTemplate([
{ {
label: "About Lens", label: "About Lens",