electron: [Bug]: Calling setAlwaysOnTop(false) and then setAlwaysOnTop(true) seems to cause other always-on-top windows to lose their always on top status
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a feature request that matches the one I want to file, without success.
Electron Version
15.1.2 -> 2.0.0
What operating system are you using?
Windows
Operating System Version
Windows 10
What arch are you using?
x64
Last Known Working Electron version
n/a
Expected Behavior
I expect that calling setAlwaysOnTop(false); setAlwaysOnTop(true) on a window will keep other always-on-top windows always on top.
Actual Behavior
Other windows lose their always-on-top status
Testcase Gist URL
https://gist.github.com/132060ee8a94ceda7c049187f2ec2dab
Additional Information
Iām working around this bug by detecting focus on an always-on-top window and calling setAlwaysOnTop(false) and setAlwaysOnTop(true) to bring it back to the front.
It seems like doing that makes the other window that was previously on top not on top anymore (isAlwaysOnTop() returns false).
- start main.js
- open two always on top windows
- focus on one of them, focus on another
- click on a background app
- the main window and the non-focused window (which should be always on top) get sent to the back. Only the focused window is always on top
main.js:
const {app, BrowserWindow} = require('electron')
function createWindow () {
const mainWindow = new BrowserWindow()
mainWindow.loadFile('index.html')
mainWindow.webContents.setWindowOpenHandler(_ => {
return {
action: "allow",
overrideBrowserWindowOptions: {
alwaysOnTop: true,
parent: mainWindow
}
}
})
mainWindow.webContents.on("did-create-window", (win) => {
win.on("focus", () => {
win.setAlwaysOnTop(false);
win.setAlwaysOnTop(true);
})
});
}
app.on('ready', () => {
createWindow()
})
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})
index.html:
<button onclick="window.open('https://google.com')">Open Always-on-top Window</button>
Possibly related to this issue
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 23 (5 by maintainers)
@pushkin- Just wanted to say I appreciate you closing out older issues that work fine now. š
I can no longer repro this, even with v34 where it used to repro. This may have been fixed by Windows. Currently on 24H2 - OS Build 26100.3476
repros in v34
repros in v33