Fix the next top-level window doesn't get focus when closing the main window in Windows

This commit is contained in:
Yuya Ochiai
2016-08-26 22:09:14 +09:00
parent 2458889a09
commit 7883693d73

View File

@@ -415,20 +415,24 @@ app.on('ready', function() {
} }
else { // Minimize or hide the window for close button. else { // Minimize or hide the window for close button.
event.preventDefault(); event.preventDefault();
const hide_window = (window) => {
window.hide();
window.blur(); // To move focus to the next top-level window in Windows
};
switch (process.platform) { switch (process.platform) {
case 'win32': case 'win32':
mainWindow.hide(); hide_window(mainWindow);
break; break;
case 'linux': case 'linux':
if (config.minimizeToTray) { if (config.minimizeToTray) {
mainWindow.hide(); hide_window(mainWindow);
} }
else { else {
mainWindow.minimize(); mainWindow.minimize();
} }
break; break;
case 'darwin': case 'darwin':
mainWindow.hide(); hide_window(mainWindow);
if (config.minimizeToTray) { if (config.minimizeToTray) {
app.dock.hide(); app.dock.hide();
} }