Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #13671 from brave/fix/issue-13659-take2
Browse files Browse the repository at this point in the history
Never call browserWindow.showInactive() as it is buggy on Windows.
  • Loading branch information
bsclifton committed Mar 30, 2018
1 parent 516cf8a commit a755489
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions app/browser/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,32 +151,32 @@ const updatePinnedTabs = (win, appState) => {
}
}

function refocusFocusedWindow () {
const focusedWindow = BrowserWindow.getFocusedWindow()
if (focusedWindow) {
function refocusFocusedWindow (win) {
if (win && !win.isDestroyed()) {
if (shouldDebugWindowEvents) {
console.log('focusing on window', focusedWindow.id)
console.log('focusing on window', win.id)
}
focusedWindow.focus()
win.focus()
}
}

function showDeferredShowWindow (win) {
// were we asked to make the window active / foreground?
// note: do not call win.showInactive if there is no other active window, otherwise this window will
// never get an entry in taskbar on Windows
const shouldShowInactive = win.webContents.browserWindowOptions.inactive && BrowserWindow.getFocusedWindow()
const currentlyFocused = BrowserWindow.getFocusedWindow()
const shouldShowInactive = win.webContents.browserWindowOptions.inactive && currentlyFocused
if (shouldShowInactive) {
// we were asked NOT to show the window active.
// we should maintain focus on the window which already has it
if (shouldDebugWindowEvents) {
console.log('showing deferred window inactive', win.id)
}
win.showInactive()
win.show()
// Whilst the window will not have focus, it will potentially be
// on top of the window which already had focus,
// so re-focus the focused window.
setImmediate(refocusFocusedWindow)
setImmediate(refocusFocusedWindow.bind(null, currentlyFocused))
} else {
// we were asked to show the window active
if (shouldDebugWindowEvents) {
Expand All @@ -193,7 +193,7 @@ function showDeferredShowWindow (win) {
setTimeout(() => {
win.setFullScreen(true)
if (shouldShowInactive) {
setImmediate(refocusFocusedWindow)
setImmediate(refocusFocusedWindow.bind(null, currentlyFocused))
}
}, 100)
} else if (win.__shouldMaximize) {
Expand Down

0 comments on commit a755489

Please sign in to comment.