Commit b542edc6 authored by dev0tion's avatar dev0tion

Fix left mouse button tray behavior and tray icon

parent 35a906bc
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
const app = electron.app; const app = electron.app;
// Module to create native browser window. // Module to create native browser window.
const BrowserWindow = electron.BrowserWindow; const BrowserWindow = electron.BrowserWindow;
const nativeImage = require('electron').nativeImage
const path = require('path'); const path = require('path');
const url = require('url'); const url = require('url');
...@@ -181,36 +182,36 @@ function createTray() { ...@@ -181,36 +182,36 @@ function createTray() {
const Menu = electron.Menu; const Menu = electron.Menu;
const Tray = electron.Tray; const Tray = electron.Tray;
let appIcon = null; let trayIcon;
var iconPath
if (os.platform() === 'win32') {
if (serve) { if (serve) {
iconPath = '.\\src\\assets\\images\\breeze-logo-tray.ico'; trayIcon = nativeImage.createFromPath('./src/assets/images/breeze-logo.png');
} else { } else {
iconPath = path.join(__dirname + '\\assets\\images\\breeze-logo-tray.png'); trayIcon = nativeImage.createFromPath('./assets/images/breeze-logo.png');
} }
} else { let systemTray = new Tray(trayIcon);
if (serve) { const contextMenu = Menu.buildFromTemplate([
iconPath = './src/assets/images/breeze-logo-tray.png'; {
} else { label: 'Hide/Show',
iconPath = path.join(__dirname + '//assets//images//breeze-logo-tray.png'); click: function () {
} mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show();
} }
}
]);
systemTray.setToolTip('Breeze Wallet');
systemTray.setContextMenu(contextMenu);
systemTray.on('click', function() {
if (!mainWindow.isVisible()) {
mainWindow.show();
}
appIcon = new Tray(iconPath); if (!mainWindow.isFocused()) {
const contextMenu = Menu.buildFromTemplate([{ mainWindow.focus();
label: 'Hide/Show',
click: function () {
mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show();
} }
}]); });
appIcon.setToolTip('Breeze Wallet');
appIcon.setContextMenu(contextMenu);
app.on('window-all-closed', function () { app.on('window-all-closed', function () {
if (appIcon) appIcon.destroy(); if (systemTray) systemTray.destroy();
}); });
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment