ELECTRON-826 - Change logic window focus logic for Window (#543)

This commit is contained in:
Kiran Niranjan 2019-01-09 13:01:21 +05:30 committed by Vishwas Shashidhar
parent 6b81a39736
commit 0bb617aab3

View File

@ -890,26 +890,25 @@ function activate(windowName, shouldFocus = true) {
return null; return null;
} }
let keys = Object.keys(windows); for (const key in windows) {
for (let i = 0, len = keys.length; i < len; i++) { if (Object.prototype.hasOwnProperty.call(windows, key)) {
let window = windows[keys[i]]; const window = windows[ key ];
if (window && !window.isDestroyed() && window.winName === windowName) { if (window && !window.isDestroyed() && window.winName === windowName) {
// Flash task bar icon in Windows // Bring the window to the top without focusing
if (isWindowsOS && !shouldFocus) { // Flash task bar icon in Windows for windows
return window.flashFrame(true); if (!shouldFocus) {
return isMac ? window.showInactive() : window.flashFrame(true);
}
// Note: On window just focusing will preserve window snapped state
// Hiding the window and just calling the focus() won't display the window
if (isWindowsOS) {
return window.isMinimized() ? window.restore() : window.focus();
}
return window.isMinimized() ? window.restore() : window.show();
} }
// brings window without giving focus on mac
if (isMac && !shouldFocus) {
return window.showInactive();
}
if (window.isMinimized()) {
return window.restore();
}
return window.show();
} }
} }
return null; return null;