Compiz friendlyness

Hi Jules,

If you test the juce demo with compiz enabled you will probably notice that the juce menus appear with lots of disturbing fancy effects – it looks like compiz thinks the menu windows are just regular windows.

in LinuxComponentPeer::removeWindowsDecoration , you have:

[code]long netHints [2];
netHints[0] = XInternAtom (display, “_KDE_NET_WM_WINDOW_TYPE_OVERRIDE”, True);

        if ((styleFlags & windowIsTemporary) != 0)
            netHints[1] = XInternAtom (display, "_NET_WM_WINDOW_TYPE_MENU", True);
        else
            netHints[1] = XInternAtom (display, "_NET_WM_WINDOW_TYPE_NORMAL", True);

        XChangeProperty (display, wndH, hints, XA_ATOM, 32, PropModeReplace,
                         (unsigned char*) &netHints, 2);

[/code]

the first atom is NULL on my wm, and it looks like compiz does not take into account the properties that are set after a “null” hint. So it basically ignores the _NET_WM_WINDOW_TYPE_MENU property. Changing to:

[code] long netHints [2];
int nbHints = 0;
netHints[nbHints] = XInternAtom (display, “_KDE_NET_WM_WINDOW_TYPE_OVERRIDE”, True);
if (netHints[nbHints]) ++nbHints;

        if ((styleFlags & windowIsTemporary) != 0) {
            netHints[nbHints] = XInternAtom (display, "_NET_WM_WINDOW_TYPE_MENU", True);
        } else
            netHints[nbHints] = XInternAtom (display, "_NET_WM_WINDOW_TYPE_NORMAL", True);
        if (netHints[nbHints]) ++nbHints;

        XChangeProperty (display, wndH, hints, XA_ATOM, 32, PropModeReplace,
                         (unsigned char*) &netHints, nbHints);

[/code]

fixes the problem.

mmm… I’m not running a 64-bit distro right now so I can’t check, but shouldn’t the long netHinst[2] be replaced by int netHints[2] ?

I’ve only got linux in a VM and don’t think it can run compiz, so I’ll take your word for it!

Yes, I think you’re right, and there are a couple of other places that’s used too, so I’ll change them.

Sorry to come back on the subject but it looks like my initial bug fix does not work anymore. In order to get it to work, I have to either completely remove the

netHints[nbHints] = XInternAtom (display, "_KDE_NET_WM_WINDOW_TYPE_OVERRIDE", True); if (netHints[nbHints]) ++nbHints;

or move it down, just before XChangeProperty. It looks like compiz really does not like this property.

Ok, so like this?

[code] if (hints != None)
{
int netHints [2];
int numHints = 0;
if ((styleFlags & windowIsTemporary) != 0)
netHints [numHints] = XInternAtom (display, “_NET_WM_WINDOW_TYPE_MENU”, True);
else
netHints [numHints] = XInternAtom (display, “_NET_WM_WINDOW_TYPE_NORMAL”, True);

        if (netHints [numHints] != 0)
            ++numHints;

        netHints[numHints] = XInternAtom (display, "_KDE_NET_WM_WINDOW_TYPE_OVERRIDE", True);

        if (netHints [numHints] != 0)
            ++numHints;

        XChangeProperty (display, wndH, hints, XA_ATOM, 32, PropModeReplace,
                         (unsigned char*) &netHints, numHints);
    }

[/code]

Yes, that way it is really working, thanks !