# Component::setAlwaysOnTop on Linux

**URL:** <https://forum.juce.com/t/component-setalwaysontop-on-linux/1848>\
**Category:** Linux\
**Created:** [June 29, 2007, 12:50pm UTC](https://forum.juce.com/t/component-setalwaysontop-on-linux/1848 "2007-06-29T12:50:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![RolandMR](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rolandmr/32/641_2.png) [@RolandMR](https://forum.juce.com/u/RolandMR)\
**Post date:** [June 29, 2007, 12:50pm UTC](https://forum.juce.com/t/component-setalwaysontop-on-linux/1848/1 "2007-06-29T12:50:46Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![Rock\_Hardbuns](https://avatars.discourse-cdn.com/v4/letter/r/41988e/32.png) [@Rock\_Hardbuns](https://forum.juce.com/u/Rock_Hardbuns)\
**Post date:** [June 29, 2007, 1:21pm UTC](https://forum.juce.com/t/component-setalwaysontop-on-linux/1848/2 "2007-06-29T13:21:40Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [June 29, 2007, 1:44pm UTC](https://forum.juce.com/t/component-setalwaysontop-on-linux/1848/3 "2007-06-29T13:44:54Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![Rock\_Hardbuns](https://avatars.discourse-cdn.com/v4/letter/r/41988e/32.png) [@Rock\_Hardbuns](https://forum.juce.com/u/Rock_Hardbuns)\
**Post date:** [June 29, 2007, 1:52pm UTC](https://forum.juce.com/t/component-setalwaysontop-on-linux/1848/4 "2007-06-29T13:52:55Z")

</div>

> [@](#):
>
> Don’t you just love the way with linux that every window manager just behaves completely differently

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.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [June 29, 2007, 1:53pm UTC](https://forum.juce.com/t/component-setalwaysontop-on-linux/1848/5 "2007-06-29T13:53:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![RolandMR](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rolandmr/32/641_2.png) [@RolandMR](https://forum.juce.com/u/RolandMR)\
**Post date:** [June 29, 2007, 2:20pm UTC](https://forum.juce.com/t/component-setalwaysontop-on-linux/1848/6 "2007-06-29T14:20:42Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [June 29, 2007, 2:43pm UTC](https://forum.juce.com/t/component-setalwaysontop-on-linux/1848/7 "2007-06-29T14:43:32Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![RolandMR](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rolandmr/32/641_2.png) [@RolandMR](https://forum.juce.com/u/RolandMR)\
**Post date:** [June 29, 2007, 3:05pm UTC](https://forum.juce.com/t/component-setalwaysontop-on-linux/1848/8 "2007-06-29T15:05:19Z")

</div>

Ah, thanks

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 12, 2017, 3:13pm UTC](https://forum.juce.com/t/component-setalwaysontop-on-linux/1848/9 "2017-05-12T15:13:36Z")

</div>


