Page MenuHome

Ghost: Add support for always-on-top windows

Authored by Julian Eisel (Severin) on Wed, Sep 11, 8:29 PM.
"Love" token, awarded by 0o00o0oo."100" token, awarded by Frozen_Death_Knight."Love" token, awarded by Alrob."Like" token, awarded by Zino."Love" token, awarded by Lumpengnom."Love" token, awarded by billreynish."Love" token, awarded by TheRedWaxPolice."Mountain of Wealth" token, awarded by Regnas.



Adds a Ghost window function to tell the system to keep the window
always on top. Also calls this for temporary windows for testing. I'm
not proposing to actually do this, that's a separate topic.

Tested on Linux (Gnome) and Windows 10. I wouldn't be surprised if it
doesn't work on macOS, I kinda guessed how to do it there, I didn't
find a good reference.

Diff Detail

rB Blender
always-on-top (branched from master)
Build Status
Buildable 4920
Build 4920: arc lint + arc unit

Event Timeline

Julian Eisel (Severin) edited the summary of this revision. (Show Details)Wed, Sep 11, 8:30 PM

I considered adding a new GHOST_TWindowState item, but we'd want windows to keep the always-on-top state while maximized, or while in any other state.

Also, I didn't add funcion comments yet, of course I'll do that before the final commit.

@Julian Eisel (Severin) if you won’t propose to actually add this, I gladly will. This is essential to support secondary windows in a useful way, so they don’t disappear behind the main window.

Phrased this badly, I mean I'm not actually proposing to apply this to all temp windows by default, although we might want to do just that. What matters for this review is checking if it works on all platforms and if this way of doing it is fine.
We'd probably need to figure out where precisely we want to use it then, and if we want to make it optional in some cases.

One issue I noted was that the exit confirm popup is easily hidden behind the on-top window. Closing Blender via a shortcut doesn't seem to do anything then.


This code works:

GHOST_TSuccess GHOST_WindowCocoa::setAlwaysOnTop(bool value)
  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setAlwaysOnTop(): window invalid");

  if (value) {
    [m_window setLevel:NSFloatingWindowLevel];
  else {
    [m_window setLevel:NSNormalWindowLevel];

  return GHOST_kSuccess;
  • Correct Cocoa implementation
  • Cleanup: Add comments, clang-format

Bah, had it like that before, but thought it was a legacy function (since I didn't fine it in the NSWindow API doc - which actually seems to be the wrong one). Thanks!

@Julian Eisel (Severin) I think we should make all temp windows and secondary windows display on top. Although I guess it’s also fine to start by adding it to just temp windows.

We want to do things a bit different, so that secondary/temporary Blender windows are not on top of non-Blender windows - like this patch does it.