ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/init.C
(Generate patch)

Comparing rxvt-unicode/src/init.C (file contents):
Revision 1.274 by sf-exg, Wed Jul 28 17:56:16 2010 UTC vs.
Revision 1.283 by sf-exg, Wed Oct 13 23:04:57 2010 UTC

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])
815#ifdef ENABLE_TRANSPARENCY 820#ifdef ENABLE_TRANSPARENCY
816 if (option (Opt_transparent)) 821 if (option (Opt_transparent))
817 { 822 {
818 bgPixmap.set_transparent (); 823 bgPixmap.set_transparent ();
819 824
820#ifdef HAVE_AFTERIMAGE
821 if (rs [Rs_blurradius]) 825 if (rs [Rs_blurradius])
822 bgPixmap.set_blur_radius (rs [Rs_blurradius]); 826 bgPixmap.set_blur_radius (rs [Rs_blurradius]);
823#endif 827
824 if (ISSET_PIXCOLOR (Color_tint)) 828 if (ISSET_PIXCOLOR (Color_tint))
825 bgPixmap.set_tint (pix_colors_focused [Color_tint]); 829 bgPixmap.set_tint (pix_colors_focused [Color_tint]);
826 830
827 if (rs [Rs_shade]) 831 if (rs [Rs_shade])
828 bgPixmap.set_shade (rs [Rs_shade]); 832 bgPixmap.set_shade (rs [Rs_shade]);
1279 1283
1280 if (i) 1284 if (i)
1281 ModMetaMask = modmasks[i - 1]; 1285 ModMetaMask = modmasks[i - 1];
1282} 1286}
1283 1287
1288void
1289rxvt_term::set_icon (const char *file)
1290{
1291#ifdef HAVE_AFTERIMAGE
1292 init_asv ();
1293
1294 ASImage *im = file2ASImage (file, 0xFFFFFFFF, SCREEN_GAMMA, 0, NULL);
1295 if (!im)
1296 {
1297 rxvt_warn ("Loading image icon failed, continuing without.\n");
1298 return;
1299 }
1300
1301 unsigned int w = im->width;
1302 unsigned int h = im->height;
1303
1304 if (!IN_RANGE_INC (w, 1, 16383) || !IN_RANGE_INC (h, 1, 16383))
1305 {
1306 rxvt_warn ("Icon image too big, continuing without.\n");
1307 destroy_asimage (&im);
1308 return;
1309 }
1310
1311 ASImage *result = scale_asimage (asv, im,
1312 w, h, ASA_ARGB32,
1313 100, ASIMAGE_QUALITY_DEFAULT);
1314 destroy_asimage (&im);
1315
1316 if (!result)
1317 {
1318 rxvt_warn ("Icon image transformation to ARGB failed, continuing without.\n");
1319 return;
1320 }
1321
1322 long *buffer = (long *)malloc ((2 + w * h) * sizeof (long));
1323 if (buffer)
1324 {
1325 ARGB32 *asbuf = result->alt.argb32;
1326 buffer [0] = w;
1327 buffer [1] = h;
1328
1329 for (unsigned int i = 0; i < w * h; ++i)
1330 buffer [i + 2] = asbuf [i];
1331
1332 XChangeProperty (dpy, parent[0], xa[XA_NET_WM_ICON], XA_CARDINAL, 32,
1333 PropModeReplace, (const unsigned char *) buffer, 2 + w * h);
1334 free (buffer);
1335 }
1336 else
1337 rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n");
1338
1339 destroy_asimage (&result);
1340#endif
1341
1342#ifdef HAVE_PIXBUF
1343 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (file, NULL);
1344 if (!pixbuf)
1345 {
1346 rxvt_warn ("Loading image icon failed, continuing without.\n");
1347 return;
1348 }
1349
1350 unsigned int w = gdk_pixbuf_get_width (pixbuf);
1351 unsigned int h = gdk_pixbuf_get_height (pixbuf);
1352
1353 if (!IN_RANGE_INC (w, 1, 16383) || !IN_RANGE_INC (h, 1, 16383))
1354 {
1355 rxvt_warn ("Icon image too big, continuing without.\n");
1356 g_object_unref (pixbuf);
1357 return;
1358 }
1359
1360 if (long *buffer = (long *)malloc ((2 + w * h) * sizeof (long)))
1361 {
1362 int rowstride = gdk_pixbuf_get_rowstride (pixbuf);
1363 unsigned char *row = gdk_pixbuf_get_pixels (pixbuf);
1364 int channels = gdk_pixbuf_get_n_channels (pixbuf);
1365
1366 buffer [0] = w;
1367 buffer [1] = h;
1368 for (int i = 0; i < h; i++)
1369 {
1370 for (int j = 0; j < w; j++)
1371 {
1372 unsigned char *pixel = row + j * channels;
1373 long value;
1374
1375 if (channels == 4)
1376 value = pixel[3];
1377 else
1378 value = (unsigned char)0x00ff;
1379
1380 value = (value << 8) + pixel[0];
1381 value = (value << 8) + pixel[1];
1382 value = (value << 8) + pixel[2];
1383 buffer[(i * w + j) + 2] = value;
1384 }
1385
1386 row += rowstride;
1387 }
1388
1389 XChangeProperty (dpy, parent[0], xa[XA_NET_WM_ICON], XA_CARDINAL, 32,
1390 PropModeReplace, (const unsigned char *) buffer, 2 + w * h);
1391 free (buffer);
1392 }
1393 else
1394 rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n");
1395
1396 g_object_unref (pixbuf);
1397#endif
1398}
1399
1284/*----------------------------------------------------------------------*/ 1400/*----------------------------------------------------------------------*/
1285/* rxvt_Create_Windows () - Open and map the window */ 1401/* rxvt_Create_Windows () - Open and map the window */
1286void 1402void
1287rxvt_term::create_windows (int argc, const char *const *argv) 1403rxvt_term::create_windows (int argc, const char *const *argv)
1288{ 1404{
1368 wmHint.window_group = top; 1484 wmHint.window_group = top;
1369 1485
1370 XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc, 1486 XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc,
1371 &szHint, &wmHint, &classHint); 1487 &szHint, &wmHint, &classHint);
1372#if ENABLE_EWMH 1488#if ENABLE_EWMH
1373# ifdef HAVE_AFTERIMAGE
1374 /* 1489 /*
1375 * set up icon hint 1490 * set up icon hint
1376 * rs [Rs_iconfile] is path to icon, asv has been created in init_resources 1491 * rs [Rs_iconfile] is path to icon
1377 */ 1492 */
1378 1493
1379 if (rs [Rs_iconfile]) 1494 if (rs [Rs_iconfile])
1380 { 1495 {
1381 init_asv (); 1496 set_icon (rs [Rs_iconfile]);
1382
1383 ASImage *im = file2ASImage (rs [Rs_iconfile], 0xFFFFFFFF, SCREEN_GAMMA, 0, NULL);
1384 if (asv && im)
1385 {
1386 int w = im->width;
1387 int h = im->height;
1388 long *buffer = (long *)malloc ((2 + w * h) * sizeof (long));
1389 ASImage *result = scale_asimage (asv, im,
1390 w, h, ASA_ARGB32,
1391 100, ASIMAGE_QUALITY_DEFAULT);
1392 destroy_asimage (&im);
1393
1394 if (buffer && result)
1395 {
1396 ARGB32 *asbuf = result->alt.argb32;
1397 buffer [0] = w;
1398 buffer [1] = h;
1399
1400 for (unsigned int i = 0; i < w * h; ++i)
1401 buffer [i + 2] = asbuf [i];
1402
1403 destroy_asimage (&result);
1404 XChangeProperty (dpy, top, xa[XA_NET_WM_ICON], XA_CARDINAL, 32,
1405 PropModeReplace, (const unsigned char *) buffer, 2 + w * h);
1406 free (buffer);
1407 }
1408 else
1409 {
1410 if (!buffer)
1411 rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n");
1412
1413 if (!result)
1414 rxvt_warn ("Icon image transformation to ARGB failed, continuing without.\n");
1415 }
1416 }
1417 else
1418 rxvt_warn ("Loading image icon failed, continuing without.\n");
1419 } 1497 }
1420# endif
1421#endif 1498#endif
1422 1499
1423#if ENABLE_FRILLS 1500#if ENABLE_FRILLS
1424 if (mwmhints.flags) 1501 if (mwmhints.flags)
1425 XChangeProperty (dpy, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, 1502 XChangeProperty (dpy, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines