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.drawImageWithin (image, 0, 0, getWidth(), getHeight(),
-
RectanglePlacement::xLeft | RectanglePlacement::yTop | RectanglePlacement::onlyReduceInSize,
-
false);
}
}[/code]