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.275 by sf-exg, Sat Aug 28 11:03:30 2010 UTC vs.
Revision 1.282 by sf-exg, Thu Sep 2 15:48:11 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])
1279 1284
1280 if (i) 1285 if (i)
1281 ModMetaMask = modmasks[i - 1]; 1286 ModMetaMask = modmasks[i - 1];
1282} 1287}
1283 1288
1289void
1290rxvt_term::set_icon (const char *file)
1291{
1292#ifdef HAVE_AFTERIMAGE
1293 init_asv ();
1294
1295 ASImage *im = file2ASImage (file, 0xFFFFFFFF, SCREEN_GAMMA, 0, NULL);
1296 if (!im)
1297 {
1298 rxvt_warn ("Loading image icon failed, continuing without.\n");
1299 return;
1300 }
1301
1302 unsigned int w = im->width;
1303 unsigned int h = im->height;
1304
1305 if (!IN_RANGE_INC (w, 1, 16383) || !IN_RANGE_INC (h, 1, 16383))
1306 {
1307 rxvt_warn ("Icon image too big, continuing without.\n");
1308 destroy_asimage (&im);
1309 return;
1310 }
1311
1312 ASImage *result = scale_asimage (asv, im,
1313 w, h, ASA_ARGB32,
1314 100, ASIMAGE_QUALITY_DEFAULT);
1315 destroy_asimage (&im);
1316
1317 if (!result)
1318 {
1319 rxvt_warn ("Icon image transformation to ARGB failed, continuing without.\n");
1320 return;
1321 }
1322
1323 long *buffer = (long *)malloc ((2 + w * h) * sizeof (long));
1324 if (buffer)
1325 {
1326 ARGB32 *asbuf = result->alt.argb32;
1327 buffer [0] = w;
1328 buffer [1] = h;
1329
1330 for (unsigned int i = 0; i < w * h; ++i)
1331 buffer [i + 2] = asbuf [i];
1332
1333 XChangeProperty (dpy, parent[0], xa[XA_NET_WM_ICON], XA_CARDINAL, 32,
1334 PropModeReplace, (const unsigned char *) buffer, 2 + w * h);
1335 free (buffer);
1336 }
1337 else
1338 rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n");
1339
1340 destroy_asimage (&result);
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
1399}
1400
1284/*----------------------------------------------------------------------*/ 1401/*----------------------------------------------------------------------*/
1285/* rxvt_Create_Windows () - Open and map the window */ 1402/* rxvt_Create_Windows () - Open and map the window */
1286void 1403void
1287rxvt_term::create_windows (int argc, const char *const *argv) 1404rxvt_term::create_windows (int argc, const char *const *argv)
1288{ 1405{
1368 wmHint.window_group = top; 1485 wmHint.window_group = top;
1369 1486
1370 XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc, 1487 XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc,
1371 &szHint, &wmHint, &classHint); 1488 &szHint, &wmHint, &classHint);
1372#if ENABLE_EWMH 1489#if ENABLE_EWMH
1373# ifdef HAVE_AFTERIMAGE
1374 /* 1490 /*
1375 * set up icon hint 1491 * set up icon hint
1376 * rs [Rs_iconfile] is path to icon 1492 * rs [Rs_iconfile] is path to icon
1377 */ 1493 */
1378 1494
1379 if (rs [Rs_iconfile]) 1495 if (rs [Rs_iconfile])
1380 { 1496 {
1381 init_asv (); 1497 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 } 1498 }
1420# endif
1421#endif 1499#endif
1422 1500
1423#if ENABLE_FRILLS 1501#if ENABLE_FRILLS
1424 if (mwmhints.flags) 1502 if (mwmhints.flags)
1425 XChangeProperty (dpy, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, 1503 XChangeProperty (dpy, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines