Minimize to tray on Close only
This commit is contained in:
32
src/main.js
32
src/main.js
@@ -229,18 +229,21 @@ app.on('ready', function() {
|
|||||||
trayIcon.setToolTip(app.getName());
|
trayIcon.setToolTip(app.getName());
|
||||||
trayIcon.on('click', function() {
|
trayIcon.on('click', function() {
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
if (config.minimizeToTray) {
|
if (mainWindow.isHidden || mainWindow.isMinimized()) {
|
||||||
if (mainWindow.isHidden) {
|
mainWindow.show();
|
||||||
mainWindow.show();
|
mainWindow.isHidden = false;
|
||||||
mainWindow.isHidden = false;
|
mainWindow.focus();
|
||||||
}
|
}
|
||||||
else if (config.toggleWindowOnTrayIconClick) {
|
else if (config.toggleWindowOnTrayIconClick) {
|
||||||
mainWindow.hide();
|
mainWindow.minimize();
|
||||||
mainWindow.isHidden = true;
|
}
|
||||||
}
|
else {
|
||||||
|
mainWindow.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mainWindow.focus();
|
else {
|
||||||
|
mainWindow.focus();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
trayIcon.on('right-click', () => {
|
trayIcon.on('right-click', () => {
|
||||||
trayIcon.popUpContextMenu();
|
trayIcon.popUpContextMenu();
|
||||||
@@ -384,15 +387,6 @@ app.on('ready', function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (process.platform === 'win32') {
|
|
||||||
mainWindow.on('minimize', function() {
|
|
||||||
if (config.minimizeToTray) {
|
|
||||||
mainWindow.hide();
|
|
||||||
mainWindow.isHidden = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// App should save bounds when a window is closed.
|
// App should save bounds when a window is closed.
|
||||||
// However, 'close' is not fired in some situations(shutdown, ctrl+c)
|
// However, 'close' is not fired in some situations(shutdown, ctrl+c)
|
||||||
// because main process is killed in such situations.
|
// because main process is killed in such situations.
|
||||||
|
Reference in New Issue
Block a user