--- rxvt-unicode/src/init.C 2010/08/28 18:19:45 1.276 +++ rxvt-unicode/src/init.C 2010/08/29 15:04:40 1.278 @@ -1281,6 +1281,54 @@ ModMetaMask = modmasks[i - 1]; } +void +rxvt_term::set_icon (const char *file) +{ +#ifdef HAVE_AFTERIMAGE + init_asv (); + + ASImage *im = file2ASImage (file, 0xFFFFFFFF, SCREEN_GAMMA, 0, NULL); + if (!im) + { + rxvt_warn ("Loading image icon failed, continuing without.\n"); + return; + } + + int w = im->width; + int h = im->height; + + ASImage *result = scale_asimage (asv, im, + w, h, ASA_ARGB32, + 100, ASIMAGE_QUALITY_DEFAULT); + destroy_asimage (&im); + + if (!result) + { + rxvt_warn ("Icon image transformation to ARGB failed, continuing without.\n"); + return; + } + + long *buffer = (long *)malloc ((2 + w * h) * sizeof (long)); + if (buffer) + { + 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]; + + XChangeProperty (dpy, parent[0], xa[XA_NET_WM_ICON], XA_CARDINAL, 32, + PropModeReplace, (const unsigned char *) buffer, 2 + w * h); + free (buffer); + } + else + rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); + + destroy_asimage (&result); +#endif +} + /*----------------------------------------------------------------------*/ /* rxvt_Create_Windows () - Open and map the window */ void @@ -1370,7 +1418,6 @@ 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 @@ -1378,46 +1425,8 @@ if (rs [Rs_iconfile]) { - init_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"); + set_icon (rs [Rs_iconfile]); } -# endif #endif #if ENABLE_FRILLS