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.139 by root, Wed Jan 11 03:13:26 2006 UTC vs.
Revision 1.144 by root, Tue Jan 17 11:02:10 2006 UTC

256 bgPixmap.pixmap = None; 256 bgPixmap.pixmap = None;
257#endif 257#endif
258 258
259 last_bot = last_state = -1; 259 last_bot = last_state = -1;
260 260
261#ifdef MENUBAR
262 menu_readonly = 1;
263# if ! (MENUBAR_MAX > 1)
264 CurrentBar = &BarList;
265# endif /* (MENUBAR_MAX > 1) */
266#endif
267
268 return true; 261 return true;
269} 262}
270 263
271void 264void
272rxvt_term::init_secondary () 265rxvt_term::init_secondary ()
339 rs[Rs_name] = rxvt_r_basename (argv[0]); 332 rs[Rs_name] = rxvt_r_basename (argv[0]);
340 333
341 /* 334 /*
342 * Open display, get options/resources and create the window 335 * Open display, get options/resources and create the window
343 */ 336 */
344 {
345 TEMP_ENV;
346 337
347 if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL) 338 if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL)
348 rs[Rs_display_name] = ":0"; 339 rs[Rs_display_name] = ":0";
349 340
350 get_options (r_argc, r_argv); 341 get_options (r_argc, r_argv);
351 342
352 if (!(display = displays.get (rs[Rs_display_name]))) 343 if (!(display = displays.get (rs[Rs_display_name])))
353 rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]); 344 rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]);
354 345
355 extract_resources (); 346 extract_resources ();
356 }
357 347
358 free (r_argv); 348 free (r_argv);
359 349
360 /* 350 /*
361 * set any defaults not already set 351 * set any defaults not already set
581 * This should support all European type languages. 571 * This should support all European type languages.
582 */ 572 */
583void 573void
584rxvt_term::set_locale (const char *locale) 574rxvt_term::set_locale (const char *locale)
585{ 575{
586 TEMP_ENV; 576 set_environ (envv);
587 577
588#if HAVE_XSETLOCALE || HAVE_SETLOCALE 578#if HAVE_XSETLOCALE || HAVE_SETLOCALE
589 free (this->locale); 579 free (this->locale);
590 this->locale = setlocale (LC_CTYPE, locale); 580 this->locale = setlocale (LC_CTYPE, locale);
591 581
622} 612}
623 613
624void 614void
625rxvt_term::init_xlocale () 615rxvt_term::init_xlocale ()
626{ 616{
627 TEMP_ENV; 617 set_environ (envv);
628 618
629#ifdef USE_XIM 619#ifdef USE_XIM
630 if (!locale) 620 if (!locale)
631 rxvt_warn ("setting locale failed, working without locale support.\n"); 621 rxvt_warn ("setting locale failed, working without locale support.\n");
632 else 622 else
673 if (strcmp (key_backspace, "DEC") == 0) 663 if (strcmp (key_backspace, "DEC") == 0)
674 priv_modes |= PrivMode_HaveBackSpace; 664 priv_modes |= PrivMode_HaveBackSpace;
675#endif 665#endif
676 666
677 /* add value for scrollBar */ 667 /* add value for scrollBar */
678 if (scrollbar_visible ()) 668 if (scrollBar.state)
679 { 669 {
680 priv_modes |= PrivMode_scrollBar; 670 priv_modes |= PrivMode_scrollBar;
681 SavedModes |= PrivMode_scrollBar; 671 SavedModes |= PrivMode_scrollBar;
682 }
683
684 if (menubar_visible ())
685 {
686 priv_modes |= PrivMode_menuBar;
687 SavedModes |= PrivMode_menuBar;
688 } 672 }
689 673
690 run_command (argv); 674 run_command (argv);
691} 675}
692 676
760 if (!rs[Rs_color + Color_pointer_bg]) pix_colors[Color_pointer_bg] = pix_colors[Color_bg]; 744 if (!rs[Rs_color + Color_pointer_bg]) pix_colors[Color_pointer_bg] = pix_colors[Color_bg];
761 if (!rs[Rs_color + Color_border] ) pix_colors[Color_border] = pix_colors[Color_fg]; 745 if (!rs[Rs_color + Color_border] ) pix_colors[Color_border] = pix_colors[Color_fg];
762 } 746 }
763 747
764 /* 748 /*
765 * get scrollBar/menuBar shadow colors 749 * get scrollBar shadow colors
766 * 750 *
767 * The calculations of topShadow/bottomShadow values are adapted 751 * The calculations of topShadow/bottomShadow values are adapted
768 * from the fvwm window manager. 752 * from the fvwm window manager.
769 */ 753 */
770#ifdef KEEP_SCROLLCOLOR 754#ifdef KEEP_SCROLLCOLOR
925#if ENABLE_FRILLS 909#if ENABLE_FRILLS
926 Atom prop = None; 910 Atom prop = None;
927 MWMHints mwmhints; 911 MWMHints mwmhints;
928#endif 912#endif
929 XGCValues gcvalue; 913 XGCValues gcvalue;
930 long vt_emask;
931 XSetWindowAttributes attributes; 914 XSetWindowAttributes attributes;
932 XWindowAttributes gattr; 915 XWindowAttributes gattr;
933 Window top, parent; 916 Window top, parent;
934 dDisp; 917 dDisp;
935 918
1075#endif 1058#endif
1076 1059
1077 /* vt cursor: Black-on-White is standard, but this is more popular */ 1060 /* vt cursor: Black-on-White is standard, but this is more popular */
1078 TermWin_cursor = XCreateFontCursor (disp, XC_xterm); 1061 TermWin_cursor = XCreateFontCursor (disp, XC_xterm);
1079 1062
1080#if defined(HAVE_SCROLLBARS) || defined(MENUBAR) 1063#ifdef HAVE_SCROLLBARS
1081 /* cursor (menuBar/scrollBar): Black-on-White */ 1064 /* cursor scrollBar: Black-on-White */
1082 leftptr_cursor = XCreateFontCursor (disp, XC_left_ptr); 1065 leftptr_cursor = XCreateFontCursor (disp, XC_left_ptr);
1083#endif 1066#endif
1084 1067
1085 /* the vt window */ 1068 /* the vt window */
1086 vt = XCreateSimpleWindow (disp, top, 1069 vt = XCreateSimpleWindow (disp, top,
1098 attributes.bit_gravity = NorthWestGravity; 1081 attributes.bit_gravity = NorthWestGravity;
1099 XChangeWindowAttributes (disp, vt, CWBitGravity, &attributes); 1082 XChangeWindowAttributes (disp, vt, CWBitGravity, &attributes);
1100 1083
1101 vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; 1084 vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask;
1102 1085
1103 if (OPTION (Opt_pointerBlank) 1086 if (OPTION (Opt_pointerBlank))
1104#ifdef ENABLE_PERL
1105 || perl.self
1106#endif
1107 )
1108 vt_emask |= PointerMotionMask; 1087 vt_emask |= PointerMotionMask;
1109 else 1088 else
1110 vt_emask |= Button1MotionMask | Button3MotionMask; 1089 vt_emask |= Button1MotionMask | Button3MotionMask;
1111 1090
1112 XSelectInput (disp, vt, vt_emask); 1091 vt_select_input ();
1092
1113 vt_ev.start (display, vt); 1093 vt_ev.start (display, vt);
1114
1115#if defined(MENUBAR) && (MENUBAR_MAX > 1)
1116 if (menuBar_height ())
1117 {
1118 menuBar.win = XCreateSimpleWindow (disp, top,
1119 window_vt_x, 0,
1120 width,
1121 menuBar_TotalHeight (),
1122 0,
1123 pix_colors_focused[Color_fg],
1124 pix_colors_focused[Color_scroll]);
1125
1126#ifdef DEBUG_X
1127 XStoreName (disp, menuBar.win, "menubar");
1128#endif
1129
1130 menuBar.drawable = new rxvt_drawable (display, menuBar.win);
1131
1132 XDefineCursor (disp, menuBar.win,
1133 XCreateFontCursor (disp, XC_left_ptr));
1134
1135 XSelectInput (disp, menuBar.win,
1136 (ExposureMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask));
1137 menubar_ev.start (display, menuBar.win);
1138 }
1139#endif
1140 1094
1141#ifdef XPM_BACKGROUND 1095#ifdef XPM_BACKGROUND
1142 if (rs[Rs_backgroundPixmap] != NULL 1096 if (rs[Rs_backgroundPixmap] != NULL
1143 && ! OPTION (Opt_transparent)) 1097 && ! OPTION (Opt_transparent))
1144 { 1098 {
1163 GCForeground | GCBackground | GCGraphicsExposures, 1117 GCForeground | GCBackground | GCGraphicsExposures,
1164 &gcvalue); 1118 &gcvalue);
1165 1119
1166 drawable = new rxvt_drawable (display, vt); 1120 drawable = new rxvt_drawable (display, vt);
1167 1121
1168#if defined(MENUBAR) || defined(RXVT_SCROLLBAR) 1122#ifdef RXVT_SCROLLBAR
1169 gcvalue.foreground = pix_colors[Color_topShadow]; 1123 gcvalue.foreground = pix_colors[Color_topShadow];
1170 topShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue); 1124 topShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue);
1171 gcvalue.foreground = pix_colors[Color_bottomShadow]; 1125 gcvalue.foreground = pix_colors[Color_bottomShadow];
1172 botShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue); 1126 botShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue);
1173 gcvalue.foreground = pix_colors[ (display->depth <= 2 ? Color_fg : Color_scroll)]; 1127 gcvalue.foreground = pix_colors[ (display->depth <= 2 ? Color_fg : Color_scroll)];
1413 * the slave. 1367 * the slave.
1414 */ 1368 */
1415void 1369void
1416rxvt_term::run_command (const char *const *argv) 1370rxvt_term::run_command (const char *const *argv)
1417{ 1371{
1418 TEMP_ENV; // not very temporary...
1419
1420#if ENABLE_FRILLS 1372#if ENABLE_FRILLS
1421 if (rs[Rs_pty_fd]) 1373 if (rs[Rs_pty_fd])
1422 { 1374 {
1423 pty.pty = atoi (rs[Rs_pty_fd]); 1375 pty.pty = atoi (rs[Rs_pty_fd]);
1424 1376
1457#if ENABLE_FRILLS 1409#if ENABLE_FRILLS
1458 if (rs[Rs_pty_fd]) 1410 if (rs[Rs_pty_fd])
1459 return; 1411 return;
1460#endif 1412#endif
1461 1413
1462#ifndef __QNX__
1463 /* spin off the command interpreter */ 1414 /* spin off the command interpreter */
1464 switch (cmd_pid = fork ()) 1415 switch (cmd_pid = fork ())
1465 { 1416 {
1466 case -1: 1417 case -1:
1467 { 1418 {
1514 } 1465 }
1515 1466
1516 pty.close_tty (); /* keep STDERR_FILENO, pty.pty, display->fd () open */ 1467 pty.close_tty (); /* keep STDERR_FILENO, pty.pty, display->fd () open */
1517 break; 1468 break;
1518 } 1469 }
1519#else /* __QNX__ uses qnxspawn () */
1520 fchmod (pty.tty, 0622);
1521 fcntl (pty.tty, F_SETFD, FD_CLOEXEC);
1522 fcntl (pty.pty, F_SETFD, FD_CLOEXEC);
1523
1524 if (run_child (argv) == -1)
1525 exit (EXIT_FAILURE);
1526#endif
1527} 1470}
1528 1471
1529/* ------------------------------------------------------------------------- * 1472/* ------------------------------------------------------------------------- *
1530 * CHILD PROCESS OPERATIONS * 1473 * CHILD PROCESS OPERATIONS *
1531 * ------------------------------------------------------------------------- */ 1474 * ------------------------------------------------------------------------- */
1575 // unblock signals (signals are blocked by iom.C 1518 // unblock signals (signals are blocked by iom.C
1576 sigset_t ss; 1519 sigset_t ss;
1577 sigemptyset (&ss); 1520 sigemptyset (&ss);
1578 sigprocmask (SIG_SETMASK, &ss, 0); 1521 sigprocmask (SIG_SETMASK, &ss, 0);
1579 1522
1580#ifndef __QNX__
1581 /* command interpreter path */ 1523 /* command interpreter path */
1582 if (argv != NULL) 1524 if (argv != NULL)
1583 { 1525 {
1584# ifdef DEBUG_CMD 1526# ifdef DEBUG_CMD
1585 int i; 1527 int i;
1611 1553
1612 execlp (shell, argv0, NULL); 1554 execlp (shell, argv0, NULL);
1613 /* no error message: STDERR is closed! */ 1555 /* no error message: STDERR is closed! */
1614 } 1556 }
1615 1557
1616#else /* __QNX__ uses qnxspawn () */
1617
1618 char iov_a[10] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
1619 char *command = NULL, fullcommand[_MAX_PATH];
1620 char **arg_v, *arg_a[2] = { NULL, NULL };
1621
1622 if (argv != NULL)
1623 {
1624 if (access (argv[0], X_OK) == -1)
1625 {
1626 if (strchr (argv[0], '/') == NULL)
1627 {
1628 searchenv (argv[0], "PATH", fullcommand);
1629
1630 if (fullcommand[0] != '\0')
1631 command = fullcommand;
1632 }
1633
1634 if (access (command, X_OK) == -1)
1635 return -1;
1636 }
1637 else
1638 command = argv[0];
1639
1640 arg_v = argv;
1641 }
1642 else
1643 {
1644 if ((command = getenv ("SHELL")) == NULL || *command == '\0')
1645 command = "/bin/sh";
1646
1647 arg_a[0] = my_basename (command);
1648
1649 if (OPTION (Opt_loginShell))
1650 {
1651 login = rxvt_malloc ((strlen (arg_a[0]) + 2) * sizeof (char));
1652
1653 login[0] = '-';
1654 strcpy (&login[1], arg_a[0]);
1655 arg_a[0] = login;
1656 }
1657
1658 arg_v = arg_a;
1659 }
1660
1661 iov_a[0] = iov_a[1] = iov_a[2] = pty.tty;
1662 cmd_pid = qnx_spawn (0, 0, 0, -1, -1,
1663 _SPAWN_SETSID | _SPAWN_TCSETPGRP,
1664 command, arg_v, environ, iov_a, 0);
1665 if (login)
1666 free (login);
1667
1668 pty.close_tty ();
1669 return pty.pty;
1670#endif
1671
1672 return -1; 1558 return -1;
1673} 1559}
1674 1560
1675/*----------------------- end-of-file (C source) -----------------------*/ 1561/*----------------------- end-of-file (C source) -----------------------*/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines