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.286 by sf-exg, Tue Dec 14 08:01:51 2010 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines