Always on top stopped working on upgrade

Hi,

I have an application that uses the always on top mode, which is user selectable.
Some of our users need it to be in front on all windows. This has stopped working after an upgrade.

What we are doing:
The Browser window is being initialized this way:

mainWindow = new BrowserWindow({
  resizable: false,
  frame: false,
  fullscreenable: false,
  alwaysOnTop: true,
  x: screenWidth - width,
  y: screenHeight - height,
  width,
  height,
  webPreferences: {
    nodeIntegration: 'true or false, depending on the environment',
    preload: path.join(__dirname, 'preload.js'),
    blinkFeatures: 'OnDeviceChange'
  }
})

Then, we allow the user to toggle always on top:

setAlwaysOnTop (alwaysOnTop) {
  const platform = __REMOTE__.system.getPlatform()
  const level = platform === 'darwin' ? 'floating' : 'screen-saver'  // for Windows only.

  mainWindow.setAlwaysOnTop(alwaysOnTop, level)
}

With this configuration, I was able to keep the application above all windows.
However, users started complaining that it wasn’t always true. For example, the application can no longer stay on top of other ones, such as Remote Desktop. This is happening, so far, only in Windows 10.

This problem started when we upgraded from Electron 6.1.11 to Electron 8.5.3.
Before, it would stay on top and we confirmed that with an older application version.
The snippet above was the first fix we did, which solved the problem for some users, but not for everyone. For example, there is another application called TightVNC which would jump in front of ours and no longer does.

Before the upgrade, the level wasn’t even being set:

setAlwaysOnTop (alwaysOnTop) {
  mainWindow.setAlwaysOnTop(alwaysOnTop)
}

I couldn’t find anything relevant on the release notes.
Is this a known issue? Am I doing something wrong? How can I force the application to be always on top of others, like it did before?
Thanks!

At a guess given your two issues seem to be with Remote Desktop style applications I would assume they are also trying to remain on top of other windows.

Afraid I don’t have much to suggest other than the below as clearly if more than one app is trying to be always on top someone’s going to have to win :slight_smile:

You could try checking to see if your app is currently “on top” and if it’s not re trigger the always on top method? Not sure if there is an event fired when window is no longer on top?

Thanks!
I didn’t have the time to test yet, but I will post the results as soon as possible.