tags 552292 + patch
thanks
I have written the patch to rescale the icons other way.
The old behaviour was to search through NET_WM_ICON set for icons with
sizes that matched SmallIconSize, LargeIconSize, HugeIconSize (either
their defaults - 16, 32, 48 - or user defined values). The missing icons
were being created by scaling already found larger icons. But if no
icons had been found at the first step (inkscape 64x64 icon didn't match
16, 32 or 48) then the taskbar icon wasn't being created.
The patch I suggest has a new approach. First we look up the NET_WM_ICON
set for icons that match the SmallIconSize, LargeIconSize,
HugeIconSize. Also we search the largest icon from provided NET_WM_ICON
set. Then we create the image from largest icon and scale it to fill the
missing icons. Inkscape icon now appears.
What do you think?
--- a/src/wmframe.cc 2009-10-28 17:09:16.000000000 +0300
+++ b/src/wmframe.cc 2009-10-28 17:11:27.000000000 +0300
@@ -2397,28 +2397,43 @@
ref<YIcon> oldFrameIcon = fFrameIcon;
if (client()->getNetWMIcon(&count, &elem)) {
- ref<YImage> icons[4];
- int sizes[] = { YIcon::smallSize(), YIcon::largeSize(), YIcon::hugeSize() };
-
- // find icons that match Small-/Large-/HugeIconSize, icons[3] is
- // fallback if none matches
- for (long *e = elem; e - count < elem; e += 2 + e[0] * e[1]) {
- int i = 0;
- for (; i < 3; i++)
- if (e[0] == sizes[i] && e[0] == e[1])
- break;
- if (icons[i] == null)
- icons[i] = YImage::createFromIconProperty(e + 2, e[0], e[1]);
- }
-
- // use the next larger existing icon to scale those that were missing
- for (int i = 0; i < 3; i++)
- if (icons[i] == null)
- for (int j = i + 1; j < 4; j++)
- if (icons[j] != null) {
- icons[i] = icons[j]->scale(sizes[i], sizes[i]);
- break;
- }
+ ref<YImage> icons[3], largestIcon;
+ int sizes[] = { YIcon::smallSize(), YIcon::largeSize(), YIcon::hugeSize()};
+ long *largestIconOffset = elem;
+ int largestIconSize = 0;
+
+ // Find icons that match Small-/Large-/HugeIconSize and search
+ // for the largest icon from NET_WM_ICON set.
+ for (long *e = elem; e - count < elem && e[0] > 0 && e[1] > 0;
+ e += 2 + e[0] * e[1]) {
+
+ if (e[0] > largestIconSize && e[0] == e[1]) {
+ largestIconOffset = e;
+ largestIconSize = e[0];
+ }
+
+ for (int i = 0; i < 3; i++) {
+ if (e[0] == sizes[i] && e[0] == e[1] &&
+ icons[i] == null && e + 2 + e[0] * e[1] <= e + count) {
+ icons[i] = YImage::createFromIconProperty(e + 2, e[0], e[1]);
+ break;
+ }
+ }
+ }
+
+ // create the largest icon
+ if (largestIconSize > 0)
+ largestIcon =
+ YImage::createFromIconProperty(largestIconOffset + 2,
+ largestIconSize,
+ largestIconSize);
+
+ // create the missing icons by rescaling the largest icon
+ if (largestIcon != null)
+ for (int i = 0; i < 3; i++)
+ if (icons[i] == null)
+ icons[i] = largestIcon->scale(sizes[i], sizes[i]);
fFrameIcon.init(new YIcon(icons[0], icons[1], icons[2]));
XFree(elem);