[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
- [X] I have read the Contributing Guidelines for this project.
- [X] I agree to follow the Code of Conduct that this project adheres to.
- [X] 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
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
repros with latest stable (21)
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
repros in v22
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
repros in v24
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
bump
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
repros in v27
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
bump
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
repros in v29.3.0
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
bump
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
repros in v33
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
repros in v34
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
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
@pushkin- Just wanted to say I appreciate you closing out older issues that work fine now. :)