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.307 by root, Sat Dec 17 23:17:33 2011 UTC vs.
Revision 1.317 by sf-exg, Mon Jan 9 21:12:08 2012 UTC

567 567
568/*----------------------------------------------------------------------*/ 568/*----------------------------------------------------------------------*/
569const char ** 569const char **
570rxvt_term::init_resources (int argc, const char *const *argv) 570rxvt_term::init_resources (int argc, const char *const *argv)
571{ 571{
572 int i, r_argc; 572 int i;
573 const char **cmd_argv; 573 const char **cmd_argv;
574
575 /*
576 * Look for -e option. Find => split and make cmd_argv[] of command args
577 */
578 for (r_argc = 0; r_argc < argc; r_argc++)
579 if (!strcmp (argv[r_argc], "-e"))
580 break;
581
582 if (r_argc == argc)
583 cmd_argv = NULL;
584 else if (!argv[r_argc + 1])
585 rxvt_fatal ("option '-e' requires an argument, aborting.\n");
586 else
587 cmd_argv = (const char **)argv + r_argc + 1;
588 574
589 rs[Rs_name] = rxvt_basename (argv[0]); 575 rs[Rs_name] = rxvt_basename (argv[0]);
590 576
591 /* 577 /*
592 * Open display, get options/resources and create the window 578 * Open display, get options/resources and create the window
593 */ 579 */
594 580
595 if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL) 581 if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL)
596 rs[Rs_display_name] = ":0"; 582 rs[Rs_display_name] = ":0";
597 583
598 get_options (r_argc, argv); 584 cmd_argv = get_options (argc, argv);
599 585
600 if (!(display = displays.get (rs[Rs_display_name]))) 586 if (!(display = displays.get (rs[Rs_display_name])))
601 rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]); 587 rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]);
602 588
603 // using a local pointer decreases code size a lot 589 // using a local pointer decreases code size a lot
866 852
867#if ENABLE_PERL 853#if ENABLE_PERL
868 rootwin_ev.start (display, display->root); 854 rootwin_ev.start (display, display->root);
869#endif 855#endif
870 856
871 set_colorfgbg (); 857 init_done = 1;
872 858
873 init_command (cmd_argv); 859 init_command (cmd_argv);
874 860
875 if (pty->pty >= 0) 861 if (pty->pty >= 0)
876 pty_ev.start (pty->pty, ev::READ); 862 pty_ev.start (pty->pty, ev::READ);
920/*----------------------------------------------------------------------*/ 906/*----------------------------------------------------------------------*/
921void 907void
922rxvt_term::init_env () 908rxvt_term::init_env ()
923{ 909{
924 char *val; 910 char *val;
911 char *env_display;
912 char *env_windowid;
913 char *env_colorfgbg;
914 char *env_term;
925 915
926#ifdef DISPLAY_IS_IP 916#ifdef DISPLAY_IS_IP
927 /* Fixup display_name for export over pty to any interested terminal 917 /* Fixup display_name for export over pty to any interested terminal
928 * clients via "ESC[7n" (e.g. shells). Note we use the pure IP number 918 * clients via "ESC[7n" (e.g. shells). Note we use the pure IP number
929 * (for the first non-loopback interface) that we get from 919 * (for the first non-loopback interface) that we get from
946 936
947 env_display = (char *)rxvt_malloc (strlen (val) + 9); 937 env_display = (char *)rxvt_malloc (strlen (val) + 9);
948 938
949 sprintf (env_display, "DISPLAY=%s", val); 939 sprintf (env_display, "DISPLAY=%s", val);
950 940
941 env_windowid = (char *)rxvt_malloc (21);
951 sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent); 942 sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent);
952 943
953 /* add entries to the environment: 944 /* add entries to the environment:
954 * @ DISPLAY: in case we started with -display 945 * @ DISPLAY: in case we started with -display
955 * @ WINDOWID: X window id number of the window 946 * @ WINDOWID: X window id number of the window
959 * @ COLORFGBG: fg;bg color codes 950 * @ COLORFGBG: fg;bg color codes
960 */ 951 */
961 putenv (env_display); 952 putenv (env_display);
962 putenv (env_windowid); 953 putenv (env_windowid);
963 954
964 if (env_colorfgbg) 955 env_colorfgbg = get_colorfgbg ();
965 putenv (env_colorfgbg); 956 putenv (env_colorfgbg);
966 957
967#ifdef RXVT_TERMINFO 958#ifdef RXVT_TERMINFO
968 putenv ("TERMINFO=" RXVT_TERMINFO); 959 putenv ("TERMINFO=" RXVT_TERMINFO);
969#endif 960#endif
970 961
1488 CWColormap | CWBackPixel | CWBorderPixel | CWOverrideRedirect, 1479 CWColormap | CWBackPixel | CWBorderPixel | CWOverrideRedirect,
1489 &attributes); 1480 &attributes);
1490 1481
1491 this->parent = top; 1482 this->parent = top;
1492 1483
1493 old_width = szHint.width;
1494 old_height = szHint.height;
1495
1496 set_title (rs [Rs_title]); 1484 set_title (rs [Rs_title]);
1497 set_icon_name (rs [Rs_iconName]); 1485 set_icon_name (rs [Rs_iconName]);
1498 1486
1499 classHint.res_name = (char *)rs[Rs_name]; 1487 classHint.res_name = (char *)rs[Rs_name];
1500 classHint.res_class = (char *)RESCLASS; 1488 classHint.res_class = (char *)RESCLASS;
1562 TermWin_cursor = XCreateFontCursor (dpy, XC_xterm); 1550 TermWin_cursor = XCreateFontCursor (dpy, XC_xterm);
1563 1551
1564 /* the vt window */ 1552 /* the vt window */
1565 vt = XCreateSimpleWindow (dpy, top, 1553 vt = XCreateSimpleWindow (dpy, top,
1566 window_vt_x, window_vt_y, 1554 window_vt_x, window_vt_y,
1567 width, height, 1555 vt_width, vt_height,
1568 0, 1556 0,
1569 pix_colors_focused[Color_fg], 1557 pix_colors_focused[Color_fg],
1570 pix_colors_focused[Color_bg]); 1558 pix_colors_focused[Color_bg]);
1571 1559
1572 attributes.bit_gravity = NorthWestGravity; 1560 attributes.bit_gravity = NorthWestGravity;
1621 if (pty->pty >= 0) 1609 if (pty->pty >= 0)
1622 { 1610 {
1623 if (getfd_hook) 1611 if (getfd_hook)
1624 pty->pty = (*getfd_hook) (pty->pty); 1612 pty->pty = (*getfd_hook) (pty->pty);
1625 1613
1626 if (pty->pty < 0 || fcntl (pty->pty, F_SETFL, O_NONBLOCK)) 1614 if (pty->pty < 0)
1627 rxvt_fatal ("unusable pty-fd filehandle, aborting.\n"); 1615 rxvt_fatal ("unusable pty-fd filehandle, aborting.\n");
1628 } 1616 }
1629 } 1617 }
1630 else 1618 else
1631#endif 1619#endif
1632 if (!pty->get ()) 1620 if (!pty->get ())
1633 rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); 1621 rxvt_fatal ("can't initialize pseudo-tty, aborting.\n");
1622
1623 fcntl (pty->pty, F_SETFL, O_NONBLOCK);
1634 1624
1635 struct termios tio = def_tio; 1625 struct termios tio = def_tio;
1636 1626
1637#ifndef NO_BACKSPACE_KEY 1627#ifndef NO_BACKSPACE_KEY
1638 if (rs[Rs_backspace_key][0] && !rs[Rs_backspace_key][1]) 1628 if (rs[Rs_backspace_key][0] && !rs[Rs_backspace_key][1])
1688 1678
1689 _exit (EXIT_FAILURE); 1679 _exit (EXIT_FAILURE);
1690 1680
1691 default: 1681 default:
1692 if (!option (Opt_utmpInhibit)) 1682 if (!option (Opt_utmpInhibit))
1683 {
1684#ifdef LOG_ONLY_ON_LOGIN
1685 bool login_shell = option (Opt_loginShell);
1686#else
1687 bool login_shell = true;
1688#endif
1693 pty->login (cmd_pid, option (Opt_loginShell), rs[Rs_display_name]); 1689 pty->login (cmd_pid, login_shell, rs[Rs_display_name]);
1690 }
1694 1691
1695 pty->close_tty (); 1692 pty->close_tty ();
1696 1693
1697 child_ev.start (cmd_pid); 1694 child_ev.start (cmd_pid);
1698 1695
1723#elif defined (SRIOCSREDIR) 1720#elif defined (SRIOCSREDIR)
1724 int fd; 1721 int fd;
1725 1722
1726 fd = open (CONSOLE, O_WRONLY, 0); 1723 fd = open (CONSOLE, O_WRONLY, 0);
1727 if (fd >= 0) 1724 if (fd >= 0)
1728 if (ioctl (fd, SRIOCSREDIR, NULL) < 0) 1725 {
1726 ioctl (fd, SRIOCSREDIR, STDIN_FILENO);
1729 close (fd); 1727 close (fd);
1728 }
1730#endif /* SRIOCSREDIR */ 1729#endif /* SRIOCSREDIR */
1731 } 1730 }
1732 1731
1733 /* reset signals and spin off the command interpreter */ 1732 /* reset signals and spin off the command interpreter */
1734 signal (SIGINT, SIG_DFL); 1733 signal (SIGINT, SIG_DFL);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines