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.277 by sf-exg, Sat Aug 28 18:20:41 2010 UTC vs.
Revision 1.281 by sf-exg, Sun Aug 29 18:12:55 2010 UTC

1279 1279
1280 if (i) 1280 if (i)
1281 ModMetaMask = modmasks[i - 1]; 1281 ModMetaMask = modmasks[i - 1];
1282} 1282}
1283 1283
1284void
1285rxvt_term::set_icon (const char *file)
1286{
1287#ifdef HAVE_AFTERIMAGE
1288 init_asv ();
1289
1290 ASImage *im = file2ASImage (file, 0xFFFFFFFF, SCREEN_GAMMA, 0, NULL);
1291 if (!im)
1292 {
1293 rxvt_warn ("Loading image icon failed, continuing without.\n");
1294 return;
1295 }
1296
1297 unsigned int w = im->width;
1298 unsigned int h = im->height;
1299
1300 if (!IN_RANGE_INC (w, 1, 16383) || !IN_RANGE_INC (h, 1, 16383))
1301 {
1302 rxvt_warn ("Icon image too big, continuing without.\n");
1303 destroy_asimage (&im);
1304 return;
1305 }
1306
1307 ASImage *result = scale_asimage (asv, im,
1308 w, h, ASA_ARGB32,
1309 100, ASIMAGE_QUALITY_DEFAULT);
1310 destroy_asimage (&im);
1311
1312 if (!result)
1313 {
1314 rxvt_warn ("Icon image transformation to ARGB failed, continuing without.\n");
1315 return;
1316 }
1317
1318 long *buffer = (long *)malloc ((2 + w * h) * sizeof (long));
1319 if (buffer)
1320 {
1321 ARGB32 *asbuf = result->alt.argb32;
1322 buffer [0] = w;
1323 buffer [1] = h;
1324
1325 for (unsigned int i = 0; i < w * h; ++i)
1326 buffer [i + 2] = asbuf [i];
1327
1328 XChangeProperty (dpy, parent[0], xa[XA_NET_WM_ICON], XA_CARDINAL, 32,
1329 PropModeReplace, (const unsigned char *) buffer, 2 + w * h);
1330 free (buffer);
1331 }
1332 else
1333 rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n");
1334
1335 destroy_asimage (&result);
1336#endif
1337}
1338
1284/*----------------------------------------------------------------------*/ 1339/*----------------------------------------------------------------------*/
1285/* rxvt_Create_Windows () - Open and map the window */ 1340/* rxvt_Create_Windows () - Open and map the window */
1286void 1341void
1287rxvt_term::create_windows (int argc, const char *const *argv) 1342rxvt_term::create_windows (int argc, const char *const *argv)
1288{ 1343{
1368 wmHint.window_group = top; 1423 wmHint.window_group = top;
1369 1424
1370 XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc, 1425 XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc,
1371 &szHint, &wmHint, &classHint); 1426 &szHint, &wmHint, &classHint);
1372#if ENABLE_EWMH 1427#if ENABLE_EWMH
1373# ifdef HAVE_AFTERIMAGE
1374 /* 1428 /*
1375 * set up icon hint 1429 * set up icon hint
1376 * rs [Rs_iconfile] is path to icon 1430 * rs [Rs_iconfile] is path to icon
1377 */ 1431 */
1378 1432
1379 if (rs [Rs_iconfile]) 1433 if (rs [Rs_iconfile])
1380 { 1434 {
1381 init_asv (); 1435 set_icon (rs [Rs_iconfile]);
1382
1383 ASImage *im = file2ASImage (rs [Rs_iconfile], 0xFFFFFFFF, SCREEN_GAMMA, 0, NULL);
1384 if (im)
1385 {
1386 int w = im->width;
1387 int h = im->height;
1388 ASImage *result = scale_asimage (asv, im,
1389 w, h, ASA_ARGB32,
1390 100, ASIMAGE_QUALITY_DEFAULT);
1391 destroy_asimage (&im);
1392
1393 if (result)
1394 {
1395 long *buffer = (long *)malloc ((2 + w * h) * sizeof (long));
1396 if (buffer)
1397 {
1398 ARGB32 *asbuf = result->alt.argb32;
1399 buffer [0] = w;
1400 buffer [1] = h;
1401
1402 for (unsigned int i = 0; i < w * h; ++i)
1403 buffer [i + 2] = asbuf [i];
1404
1405 XChangeProperty (dpy, top, xa[XA_NET_WM_ICON], XA_CARDINAL, 32,
1406 PropModeReplace, (const unsigned char *) buffer, 2 + w * h);
1407 free (buffer);
1408 }
1409 else
1410 rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n");
1411
1412 destroy_asimage (&result);
1413 }
1414 else
1415 rxvt_warn ("Icon image transformation to ARGB failed, continuing without.\n");
1416 }
1417 else
1418 rxvt_warn ("Loading image icon failed, continuing without.\n");
1419 } 1436 }
1420# endif
1421#endif 1437#endif
1422 1438
1423#if ENABLE_FRILLS 1439#if ENABLE_FRILLS
1424 if (mwmhints.flags) 1440 if (mwmhints.flags)
1425 XChangeProperty (dpy, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, 1441 XChangeProperty (dpy, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines