Component::addToDesktop() and setAlwaysOnTop()


#1

I need one of my components to be draggable outside the window like in the “misc widgets” page of the demo application. the behavior I need is the same one as the toolbars of photoshop for example.

I used addToDesktop(), but the window doesn’t stay on top of the main window if focus goes from this window to the main one.
Then I used setAlwaysOnTop(), which let the window on top of other, but also on top of other applications.

The setAlwaysOnTop() should be replaced by two different functions like setAlwaysOnTopOfOtherComponents() and setAlwaysOnTopOfOtherDesktopWindows(),

Or is there other way to do this ?


#2

sure, but it’d be very hard to actually do that… Why not just make it always on top while it’s being dragged?


#3

Don’t know what you mean exactly,
Maybe I’ve not been very clear in what I’d like to do :

I’d like the component to stay on top of my application, but not on top of other application…
which looks impossible after you do addToDesktop()

this is a common behaviour for draggable toolbars, like in visual studio if your drag out properties pannel. Or like the photoshop’s toolbars …


#4

yes, I understand. I want to do some toolbar classes soon anyway, so will see if I can find a good solution then.


#5

ok thanks !


#6

As an interim, you could do it so your main window, whenever it gets focus/redrawn/whatever, bring to top all of your other toolbar windows too. Mabye just always have the toolbar windows to be always on top when your app is focuesed, then removed from always on top when out of focus?


#7

yes, that’s the sort of thing I did in tracktion to keep the vst windows on top.


#8

That solved the problem thanks,

More precisely for those with same problem :

Use the focusGained(), focusLost() and minimisationStateChanged() callbacks of the main window to set the toolbars visible or invisible.


#9

In fact a neater way (which might also catch some events that you’d otherwise miss) would be to use TopLevelWindow::activeWindowStatusChanged() and isActiveWindow()


#10

Holy old thread revival, Batman! :slight_smile:

I was being good and doing some research on my question before asking it, and came across this thread. Basically I want to do almost exactly what was described above:

yes, that’s the sort of thing I did in tracktion to keep the vst windows on top.[/quote]

Has anything changed with the recommended way of doing this in the intervening 7 years?? :slight_smile:

Specifically, I have a plugin hosting app, and I want the plugins to be always on top within my app only, but not system-wide. setAlwaysOnTop() sets the plugin windows to be always on top system-wide. I’m fine with adding platform-specific code, I’ve already done that to address this on the Mac side.

Alternatively, is there a way to get notification of when the application is switched away from the foreground? I could hide all the plugin windows when app is switched out. Note that my app also has other windows besides the “main” one and the plugin windows, for example there’s a separate prefs window. So when the prefs window is open, the main app window is not in focus, but this is not a case where I want to hide the plugin windows. I only want to do it when the entire app is actually switched out of the foreground.


#11

No, don’t think I’ve added anything new to address this since this thread was started.


#12

Hi Jules,

I use a topLevelWindow component on which I do a AddToDesktop to display warning messages in my plugin.

Like the other people on this thread, I want the warning window to be on top of the plugin window but only inside the DAW scope.

On PC, this works perfectly but on Mac, the warning window is either behing the plugin (if setAlwaysOnTop(false)) or on top of all apps (if setAlwaysOnTop(true)). 

I can't find any satisfying workaround to have a proper display.

The workaround that consists of changing the setAlwaysOnTop flag in focusGained() and focusLost() partially solves the problem. A major issue remains: If a topLevel window is displayed, and the user clicks outside the DAW and click back into the DAW, the topLevel window gets stuck behind the plugin,the DAW is unaccessable and I have to move the plugin to access the warning window to close it...

I'm amazed to see that this thread is 8-year-old and that no solution has been found yet.

Is there a chance to have a proper management of windows display on Mac soon?


#13

Is there a chance to have a proper management of windows display on Mac soon?

No. Like I've said a million times, you shouldn't be popping out windows from a plugin - it's just not going to work on all hosts with all their different windowing arrangements. Especially now there are all kinds of extra confusions when you start getting 32/64-bit bridging processes, so that host/plugin windows are running in completely separate processes.

If you're just showing a warning message, why not just use a lightweight component inside your plugin window? Nothing can go wrong with that.


#14