Skip to content

Commit

Permalink
fix window/app focusing
Browse files Browse the repository at this point in the history
  • Loading branch information
OothecaPickle committed Dec 3, 2024
1 parent a286751 commit 5ce70f4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,13 @@ function runApp() {
// Someone tried to run a second instance, we should focus our window
if (mainWindow && typeof commandLine !== 'undefined') {
if (mainWindow.isMinimized()) mainWindow.restore()
mainWindow.focus()
process.platform === 'darwin' ? app.focus({ steal: true }) : app.focus()
mainWindow.setAlwaysOnTop(true)
mainWindow.show()
setTimeout(function() { mainWindow.focus() }, 100)
mainWindow.moveTop()
process.platform === 'darwin' ? app.focus({ steal: true }) : app.focus()
mainWindow.setAlwaysOnTop(false)

const url = getLinkUrl(commandLine)
if (url) {
Expand Down Expand Up @@ -797,8 +803,13 @@ function runApp() {
return
}

process.platform === 'darwin' ? app.focus({ steal: true }) : app.focus()
newWindow.setAlwaysOnTop(true)
newWindow.show()
newWindow.focus()
setTimeout(function() { newWindow.focus() }, 100)
newWindow.moveTop()
process.platform === 'darwin' ? app.focus({ steal: true }) : app.focus()
newWindow.setAlwaysOnTop(false)

if (process.env.NODE_ENV === 'development') {
newWindow.webContents.openDevTools({ activate: false })
Expand Down

0 comments on commit 5ce70f4

Please sign in to comment.