… | |
… | |
632 | #ifdef HAVE_AFTERIMAGE |
632 | #ifdef HAVE_AFTERIMAGE |
633 | set_application_name ((char *)rs[Rs_name]); |
633 | set_application_name ((char *)rs[Rs_name]); |
634 | set_output_threshold (OUTPUT_LEVEL_WARNING); |
634 | set_output_threshold (OUTPUT_LEVEL_WARNING); |
635 | #endif |
635 | #endif |
636 | |
636 | |
|
|
637 | #ifdef HAVE_PIXBUF |
|
|
638 | g_type_init (); |
|
|
639 | gdk_pixbuf_xlib_init (dpy, display->screen); |
|
|
640 | #endif |
|
|
641 | |
637 | #if ENABLE_PERL |
642 | #if ENABLE_PERL |
638 | if (!rs[Rs_perl_ext_1]) |
643 | if (!rs[Rs_perl_ext_1]) |
639 | rs[Rs_perl_ext_1] = "default"; |
644 | rs[Rs_perl_ext_1] = "default"; |
640 | |
645 | |
641 | if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) |
646 | if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) |
… | |
… | |
1332 | else |
1337 | else |
1333 | rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); |
1338 | rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); |
1334 | |
1339 | |
1335 | destroy_asimage (&result); |
1340 | destroy_asimage (&result); |
1336 | #endif |
1341 | #endif |
|
|
1342 | |
|
|
1343 | #ifdef HAVE_PIXBUF |
|
|
1344 | GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (file, NULL); |
|
|
1345 | if (!pixbuf) |
|
|
1346 | { |
|
|
1347 | rxvt_warn ("Loading image icon failed, continuing without.\n"); |
|
|
1348 | return; |
|
|
1349 | } |
|
|
1350 | |
|
|
1351 | unsigned int w = gdk_pixbuf_get_width (pixbuf); |
|
|
1352 | unsigned int h = gdk_pixbuf_get_height (pixbuf); |
|
|
1353 | |
|
|
1354 | if (!IN_RANGE_INC (w, 1, 16383) || !IN_RANGE_INC (h, 1, 16383)) |
|
|
1355 | { |
|
|
1356 | rxvt_warn ("Icon image too big, continuing without.\n"); |
|
|
1357 | g_object_unref (pixbuf); |
|
|
1358 | return; |
|
|
1359 | } |
|
|
1360 | |
|
|
1361 | if (long *buffer = (long *)malloc ((2 + w * h) * sizeof (long))) |
|
|
1362 | { |
|
|
1363 | int rowstride = gdk_pixbuf_get_rowstride (pixbuf); |
|
|
1364 | unsigned char *row = gdk_pixbuf_get_pixels (pixbuf); |
|
|
1365 | int channels = gdk_pixbuf_get_n_channels (pixbuf); |
|
|
1366 | |
|
|
1367 | buffer [0] = w; |
|
|
1368 | buffer [1] = h; |
|
|
1369 | for (int i = 0; i < h; i++) |
|
|
1370 | { |
|
|
1371 | for (int j = 0; j < w; j++) |
|
|
1372 | { |
|
|
1373 | unsigned char *pixel = row + j * channels; |
|
|
1374 | long value; |
|
|
1375 | |
|
|
1376 | if (channels == 4) |
|
|
1377 | value = pixel[3]; |
|
|
1378 | else |
|
|
1379 | value = (unsigned char)0x00ff; |
|
|
1380 | |
|
|
1381 | value = (value << 8) + pixel[0]; |
|
|
1382 | value = (value << 8) + pixel[1]; |
|
|
1383 | value = (value << 8) + pixel[2]; |
|
|
1384 | buffer[(i * w + j) + 2] = value; |
|
|
1385 | } |
|
|
1386 | |
|
|
1387 | row += rowstride; |
|
|
1388 | } |
|
|
1389 | |
|
|
1390 | XChangeProperty (dpy, parent[0], xa[XA_NET_WM_ICON], XA_CARDINAL, 32, |
|
|
1391 | PropModeReplace, (const unsigned char *) buffer, 2 + w * h); |
|
|
1392 | free (buffer); |
|
|
1393 | } |
|
|
1394 | else |
|
|
1395 | rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); |
|
|
1396 | |
|
|
1397 | g_object_unref (pixbuf); |
|
|
1398 | #endif |
1337 | } |
1399 | } |
1338 | |
1400 | |
1339 | /*----------------------------------------------------------------------*/ |
1401 | /*----------------------------------------------------------------------*/ |
1340 | /* rxvt_Create_Windows () - Open and map the window */ |
1402 | /* rxvt_Create_Windows () - Open and map the window */ |
1341 | void |
1403 | void |