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.273 by sf-exg, Mon Jul 26 22:07:38 2010 UTC vs.
Revision 1.279 by sf-exg, Sun Aug 29 15:05:08 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 int w = im->width;
1298 int h = im->height;
1299
1300 if (!IN_RANGE_INC (w, 1, 32767) || !IN_RANGE_INC (h, 1, 32767))
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, asv has been created in init_resources 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 (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 } 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,
1502 pix_colors = pix_colors_unfocused; 1518 pix_colors = pix_colors_unfocused;
1503#endif 1519#endif
1504 1520
1505 pointer_unblank (); 1521 pointer_unblank ();
1506 scr_recolour (); 1522 scr_recolour ();
1507}
1508
1509/* ------------------------------------------------------------------------- *
1510 * GET TTY CURRENT STATE *
1511 * ------------------------------------------------------------------------- */
1512static void
1513rxvt_get_ttymode (struct termios *tio)
1514{
1515 /*
1516 * standard System V termios interface
1517 */
1518 // does not work as stdin is not a tty
1519 // if (tcgetattr (STDIN_FILENO, tio) < 0)
1520 if (1)
1521 {
1522 // return error - use system defaults,
1523 // where possible, and zero elsewhere
1524 memset (tio, 0, sizeof (struct termios));
1525 if (VDISABLE)
1526 for (int i = 0; i < NCCS; i++)
1527 tio->c_cc[i] = VDISABLE;
1528
1529 tio->c_cc[VINTR] = CINTR;
1530 tio->c_cc[VQUIT] = CQUIT;
1531 tio->c_cc[VERASE] = CERASE;
1532#ifdef VERASE2
1533 tio->c_cc[VERASE2] = CERASE2;
1534#endif
1535 tio->c_cc[VKILL] = CKILL;
1536 tio->c_cc[VSTART] = CSTART;
1537 tio->c_cc[VSTOP] = CSTOP;
1538 tio->c_cc[VSUSP] = CSUSP;
1539# ifdef VDSUSP
1540 tio->c_cc[VDSUSP] = CDSUSP;
1541# endif
1542# ifdef VREPRINT
1543 tio->c_cc[VREPRINT] = CRPRNT;
1544# endif
1545# ifdef VDISCRD
1546 tio->c_cc[VDISCRD] = CFLUSH;
1547# endif
1548# ifdef VWERSE
1549 tio->c_cc[VWERSE] = CWERASE;
1550# endif
1551# ifdef VLNEXT
1552 tio->c_cc[VLNEXT] = CLNEXT;
1553# endif
1554 }
1555
1556 tio->c_cc[VEOF] = CEOF;
1557# if VMIN != VEOF
1558 tio->c_cc[VMIN] = 1;
1559# endif
1560# if VTIME != VEOL
1561 tio->c_cc[VTIME] = 0;
1562# endif
1563
1564 /* input modes */
1565 tio->c_iflag = (BRKINT | IGNPAR | ICRNL
1566# ifdef IMAXBEL
1567 | IMAXBEL
1568# endif
1569 | IXON);
1570
1571 /* output modes */
1572 tio->c_oflag = (OPOST | ONLCR);
1573
1574 /* control modes */
1575 tio->c_cflag = (CS8 | CREAD);
1576
1577 /* line discipline modes */
1578 tio->c_lflag = (ISIG | ICANON | IEXTEN | ECHO
1579# if defined (ECHOCTL) && defined (ECHOKE)
1580 | ECHOCTL | ECHOKE
1581# endif
1582 | ECHOE | ECHOK);
1583
1584 /*
1585 * Debugging
1586 */
1587#ifdef DEBUG_TTYMODE
1588 /* c_iflag bits */
1589 fprintf (stderr, "Input flags\n");
1590
1591 /* cpp token stringize doesn't work on all machines <sigh> */
1592# define FOO(flag,name) \
1593 if ((tio->c_iflag) & flag) \
1594 fprintf (stderr, "%s ", name)
1595
1596 /* c_iflag bits */
1597 FOO (IGNBRK, "IGNBRK");
1598 FOO (BRKINT, "BRKINT");
1599 FOO (IGNPAR, "IGNPAR");
1600 FOO (PARMRK, "PARMRK");
1601 FOO (INPCK, "INPCK");
1602 FOO (ISTRIP, "ISTRIP");
1603 FOO (INLCR, "INLCR");
1604 FOO (IGNCR, "IGNCR");
1605 FOO (ICRNL, "ICRNL");
1606 FOO (IXON, "IXON");
1607 FOO (IXOFF, "IXOFF");
1608# ifdef IUCLC
1609 FOO (IUCLC, "IUCLC");
1610# endif
1611# ifdef IXANY
1612 FOO (IXANY, "IXANY");
1613# endif
1614# ifdef IMAXBEL
1615 FOO (IMAXBEL, "IMAXBEL");
1616# endif
1617
1618 fprintf (stderr, "\n");
1619
1620# undef FOO
1621# define FOO(entry, name) \
1622 fprintf (stderr, "%-8s = %#04o\n", name, tio->c_cc [entry])
1623
1624 FOO (VINTR, "VINTR");
1625 FOO (VQUIT, "VQUIT");
1626 FOO (VERASE, "VERASE");
1627 FOO (VKILL, "VKILL");
1628 FOO (VEOF, "VEOF");
1629 FOO (VEOL, "VEOL");
1630# ifdef VEOL2
1631 FOO (VEOL2, "VEOL2");
1632# endif
1633# ifdef VSWTC
1634 FOO (VSWTC, "VSWTC");
1635# endif
1636# ifdef VSWTCH
1637 FOO (VSWTCH, "VSWTCH");
1638# endif
1639 FOO (VSTART, "VSTART");
1640 FOO (VSTOP, "VSTOP");
1641 FOO (VSUSP, "VSUSP");
1642# ifdef VDSUSP
1643 FOO (VDSUSP, "VDSUSP");
1644# endif
1645# ifdef VREPRINT
1646 FOO (VREPRINT, "VREPRINT");
1647# endif
1648# ifdef VDISCRD
1649 FOO (VDISCRD, "VDISCRD");
1650# endif
1651# ifdef VWERSE
1652 FOO (VWERSE, "VWERSE");
1653# endif
1654# ifdef VLNEXT
1655 FOO (VLNEXT, "VLNEXT");
1656# endif
1657
1658 fprintf (stderr, "\n");
1659# undef FOO
1660#endif /* DEBUG_TTYMODE */
1661} 1523}
1662 1524
1663/*----------------------------------------------------------------------*/ 1525/*----------------------------------------------------------------------*/
1664/* 1526/*
1665 * Run the command in a subprocess and return a file descriptor for the 1527 * Run the command in a subprocess and return a file descriptor for the
1686 else 1548 else
1687#endif 1549#endif
1688 if (!pty->get ()) 1550 if (!pty->get ())
1689 rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); 1551 rxvt_fatal ("can't initialize pseudo-tty, aborting.\n");
1690 1552
1691 rxvt_get_ttymode (&tio); 1553 struct termios tio = def_tio;
1692 1554
1693#ifndef NO_BACKSPACE_KEY 1555#ifndef NO_BACKSPACE_KEY
1694 if (rs[Rs_backspace_key][0] && !rs[Rs_backspace_key][1]) 1556 if (rs[Rs_backspace_key][0] && !rs[Rs_backspace_key][1])
1695 tio.c_cc[VERASE] = rs[Rs_backspace_key][0]; 1557 tio.c_cc[VERASE] = rs[Rs_backspace_key][0];
1696 else if (strcmp (rs[Rs_backspace_key], "DEC") == 0) 1558 else if (strcmp (rs[Rs_backspace_key], "DEC") == 0)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines