So for example lets say the user has Chrome open in full screen. Then a popup comes from the electron app, but it overlays on the chrome screen instead of switching screens to the electron app.
Like the VPN app below;
How would i go about doing this?
To focus a window, you can use: window.show().
If your on a mac and it's in a different workspace then it won't show. You would need to run: window.setVisibleOnAllWorkspaces(true) on the window when the window is being created then window.show() when you want it to show.
show docs
setVisibleOnAllWorkspaces docs
I found a solution that seems to work for this! So this is assuming you've already figured out how to show a window above full screen apps in general. The issue I had with that is that when you try to bring a new window into view, it takes you out of fullscreen, even if that window is configured to show above fullscreen apps.
To deal with this the solution was simple:
mainWindow.hide()
mainWindow.show()
setTimeout(() => displayPopupWindow(data), 300)
In this case, your main window (which can be invisible) is given focus while still having the fullscreen app open, then opening the popup window will not close the fullscreen app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With