--- rxvt-unicode/src/init.C 2008/07/15 16:41:22 1.253 +++ rxvt-unicode/src/init.C 2008/11/04 11:03:29 1.254 @@ -1137,6 +1137,53 @@ XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc, &szHint, &wmHint, &classHint); +#if ENABLE_EWMH +# ifdef HAVE_AFTERIMAGE + /* + * set up icon hint + * rs [Rs_iconfile] is path to icon, asv has been created in init_resources + */ + if (rs [Rs_iconfile] && asv) + { + ASImage *im = file2ASImage (rs [Rs_iconfile], 0xFFFFFFFF, SCREEN_GAMMA, 0, NULL); + if (im) + { + int w = im->width; + int h = im->height; + long* buffer = (long *)malloc ((2 + w * h) * sizeof (long)); + ASImage *result = scale_asimage (asv, im, + w, h, ASA_ARGB32, + 100, ASIMAGE_QUALITY_DEFAULT); + destroy_asimage (&im); + + if (buffer && result) + { + ARGB32 *asbuf = result->alt.argb32; + buffer [0] = w; + buffer [1] = h; + + for (unsigned int i = 0; i < w * h; ++i) + buffer [i + 2] = asbuf [i]; + + destroy_asimage (&result); + XChangeProperty (dpy, top, xa[XA_NET_WM_ICON], XA_CARDINAL, 32, + PropModeReplace, (const unsigned char*) buffer, 2 + w * h); + free (buffer); + } + else + { + if (!buffer) + rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); + + if (!result) + rxvt_warn ("Icon image transformation to ARGB failed, continuing without.\n"); + } + } + else + rxvt_warn ("Loading image icon failed, continuing without.\n"); + } +# endif +#endif #if ENABLE_FRILLS if (mwmhints.flags)