SystemTrayIconComponent on linux (latest Ubuntu)


#1

yeah i’m using latest Ubuntu and i got the JuceDemo to build and also my own project to build (i use Netbeans btw it works great with juce based projects). But the systemTrayIcon does not appear, well not the whoel thing anyway, just a single pixel line, and that line actually works as a tray icon (popup menus and all). but well it’s not what i wanted to get :slight_smile:

i’m new @juce with linux so maybe i’m missing something obvious (as usual).

here is a screen:

i’ve made a red arrow on the bottom showing the “tray icon”, also the demo sometimes get’s black squares (i’m using compiz) on the application window. this was a debug build, without any modifications to the source (except for the unsigned char insetad of Byte in the juce code).


#2

any idead about this, i still a get a single line in the tray

maybe it’s the icon size ? or format
or something


#3

What window manager is this, looks like GNOME? I tested with GNOME (gives me the same result as you), Xfce (gives the same result as GNOME) and KDE (works as expected). So I suspect that the Linux specific code for the system tray icon is to blame, I’m going to see if I can come up with a version that works with GNOME and Xfce too.

Update 1:

For GNOME and Xfce the minimal size of the XWindow displaying the tray icon must be set to 22x22. In LinuxComponentPeer::setTaskBarIcon:

[code] void setTaskBarIcon (const Image& image)
{
[…]

    // For older KDE's ...
    long atomData = 1;
    Atom trayAtom = XInternAtom (display, "KWM_DOCKWINDOW", false);
    XChangeProperty (display, windowH, trayAtom, trayAtom, 32, PropModeReplace, (unsigned char*) &atomData, 1);

    // For more recent KDE's...
    trayAtom = XInternAtom (display, "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", false);
    XChangeProperty (display, windowH, trayAtom, XA_WINDOW, 32, PropModeReplace, (unsigned char*) &windowH, 1);
  •   // minimum size needed for GNOME and Xfce, otherwise the icon is displayed with a width of 1
    
  •   XSizeHints* hints = XAllocSizeHints();
    
  •   hints->flags = PMinSize;
    
  •   hints->min_width = 22;
    
  •   hints->min_height = 22;
    
  •   XSetWMNormalHints (display, windowH, hints);
    
  •   XFree (hints);
    
    }[/code]

This is tested on Ubuntu Hardy with KDE (the change doesn’t break it), GNOME (it’s working now) and Xfce (it’s working now too).

Update 2:

Draw the icon fitted into the available space:

[code]void SystemTrayIconComponent::paint (Graphics& g)
{
LinuxComponentPeer* const wp = dynamic_cast <LinuxComponentPeer*> (getPeer());

if (wp != 0)
{
    const Image* const image = wp->getTaskbarIcon();

    if (image != 0)
  •       g.drawImageAt (image, 0, 0, false);
    
  •       g.drawImageWithin (image, 0, 0, getWidth(), getHeight(),
    
  •                          RectanglePlacement::xLeft | RectanglePlacement::yTop | RectanglePlacement::onlyReduceInSize,
    
  •                          false);
    
    }
    }[/code]

#4

Thanks - I guess I’ll roll that in there…


#5

Is this working for anybody on xfce?

Doesn't show on my Debians w/ vanilla Xfce, both Wheezyy & Jessie when running Juce Demo. Juce's hardcoded 22 pixels size comes from the default Xfce notification area maximum icon size but I doubt it's related to the bug.

thx,

-- p