Set browserWindow Always on top, even other app is in fullscreen [Electron, MAC OS]
Asked Answered
F

2

19

it's possible to use custom window level in Electron Framework, for make window always on top, even other apps is in fullscreen ?

For native MacOS apps i found this: https://mcmap.net/q/386167/-keep-window-always-on-top

Where he saying:

window.level = Int(CGWindowLevelForKey(kCGMaximumWindowLevelKey))

On electron, i have a browser window:

mainWindow = new BrowserWindow({width: 1400, height: 50, resizable: false, alwaysOnTop: true, y: 0, x: 0, minimizable: false, title: 'CD App', frame: false, titleBarStyle: 'hidden', type: 'desktop' });

I know the 'type' parameter is the POINT, but this parameter have just two options:

On macOS, possible types are desktop, textured. The textured type adds metal gradient appearance (NSTexturedBackgroundWindowMask). The desktop type places the window at the desktop background window level (kCGDesktopWindowLevel - 1). Note that desktop window will not receive focus, keyboard or mouse events, but you can use globalShortcut to receive input sparingly.

So, any possibilities to do this thing ?

Fourchette answered 3/10, 2016 at 15:34 Comment(1)
Hi @Paulo Rodrigues, were you able to solve this problem?Eyas
V
31

As of Electron 1.4.2 the setAlwaysOnTop() API takes an optional level parameter to adjust the window level, you'd use it like so:

mainWindow = new BrowserWindow({ ... });
mainWindow.setAlwaysOnTop(true, 'screen');

See the docs for all the possible values of the optional parameter, I'm not sure screen is the one you want in this case, you'll need to experiment.

Varini answered 4/10, 2016 at 5:1 Comment(3)
This, answer my question partially, i need to know if is possible to do electron apps with highest window level possible, even if other apps (like keynote) is on fullscreen, i need to show a "toolbar" in front of keynote.Fourchette
I don't know if it's possible, you'll have to experiment.Varini
works for me too, and also adding these to it, the app rules the screenwindowName.setMinimizable(false); fullscreen:trueNeuroblast
B
3

2024 answer. You can do the following to have your window over everything including full-screen apps and across every workspace.

  mainWindow.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });
  mainWindow.setAlwaysOnTop(true, 'screen-saver', 1);

This GH thread follows a lot of the window on-top of full-screen feature creation/implementation.

Boart answered 20/1 at 18:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.