Component::setAlwaysOnTop on Linux


#1

Component::setAlwaysOnTop doesn’t seem to work on Linux (Ubuntu Edgy)

If i set it, the app window doesn’t doesn’t become visible.


#2

This may be related, or it may not:
I run Debian etch and when I bring up the source code window of the JUCE Demo, the two windows begin battling to be on top, producing serious flickering back and forth. Commenting out line 83 of maindemowindow.cpp solves it. The source window comes out on top anyway.
Seems like it might share a root cause with G-Mon’s problem?


#3

Sounds like it could be related. I don’t get any problems with the two windows in my installation (ubuntu edgy).

Don’t you just love the way with linux that every window manager just behaves completely differently…


#4

Agree. It’s beautiful. Like a field of unique and special little flowers.

I should mention that I use Xfce with it’s default WM (xfwm?) so that might be it, and not something you should concern yourself with. That’s why I didn’t mention it before.


#5

ok, I just tried some always-on-top windows and it’s fine on my setup, which is also ubuntu edgy… (?)


#6

With the following code, the window does not appear.
If I switch the setAlwaysOnTop calls, then it does show up.

[code] setSize(96, 96);
setOpaque(true);
// setAlwaysOnTop(true);
addToDesktop(0);
setVisible(true);
setAlwaysOnTop(true);

    Rectangle rc = Desktop::getInstance().getMainMonitorArea();

    Settings* settings = Settings::getInstance();
    if (settings->x == -1 || settings->y == -1 || !Desktop::getInstance().getAllMonitorDisplayAreas().containsPoint(settings->x, settings->y))
            setTopLeftPosition(rc.getRight() - 96 - 7, rc.getBottom() - 96 - 7);
    else
            setTopLeftPosition(settings->x, settings->y);

[/code]


#7

ok, well this little hack seems to do the trick:

[code] bool setAlwaysOnTop (bool alwaysOnTop)
{
if (windowH != 0 && component->isVisible())
{
setVisible (false);

        XSetWindowAttributes swa;
        swa.override_redirect = getComponent()->isAlwaysOnTop() ? True : False;

        XChangeWindowAttributes (display, windowH, CWOverrideRedirect, &swa);

        setVisible (true);
    }

    return true;
}

[/code]


#8

Ah, thanks


#9