… | |
… | |
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 | |
271 | void |
264 | void |
272 | rxvt_term::init_secondary () |
265 | rxvt_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 | */ |
583 | void |
573 | void |
584 | rxvt_term::set_locale (const char *locale) |
574 | rxvt_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 | |
624 | void |
614 | void |
625 | rxvt_term::init_xlocale () |
615 | rxvt_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 | */ |
1415 | void |
1369 | void |
1416 | rxvt_term::run_command (const char *const *argv) |
1370 | rxvt_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 | |
1425 | if (pty.pty >= 0) |
1377 | if (pty->pty >= 0) |
1426 | { |
1378 | { |
1427 | if (getfd_hook) |
1379 | if (getfd_hook) |
1428 | pty.pty = (*getfd_hook) (pty.pty); |
1380 | pty->pty = (*getfd_hook) (pty->pty); |
1429 | |
1381 | |
1430 | if (pty.pty < 0 || fcntl (pty.pty, F_SETFL, O_NONBLOCK)) |
1382 | if (pty->pty < 0 || fcntl (pty->pty, F_SETFL, O_NONBLOCK)) |
1431 | rxvt_fatal ("unusable pty-fd filehandle, aborting.\n"); |
1383 | rxvt_fatal ("unusable pty-fd filehandle, aborting.\n"); |
1432 | } |
1384 | } |
1433 | } |
1385 | } |
1434 | else |
1386 | else |
1435 | #endif |
1387 | #endif |
1436 | if (!pty.get ()) |
1388 | if (!pty->get ()) |
1437 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
1389 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
1438 | |
1390 | |
1439 | pty.set_utf8_mode (enc_utf8); |
1391 | pty->set_utf8_mode (enc_utf8); |
1440 | |
1392 | |
1441 | /* set initial window size */ |
1393 | /* set initial window size */ |
1442 | tt_winch (); |
1394 | tt_winch (); |
1443 | |
1395 | |
1444 | int er; |
1396 | int er; |
… | |
… | |
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 | { |
… | |
… | |
1469 | rxvt_fatal ("can't fork, aborting.\n"); |
1420 | rxvt_fatal ("can't fork, aborting.\n"); |
1470 | } |
1421 | } |
1471 | case 0: |
1422 | case 0: |
1472 | init_env (); |
1423 | init_env (); |
1473 | |
1424 | |
1474 | if (!pty.make_controlling_tty ()) |
1425 | if (!pty->make_controlling_tty ()) |
1475 | fprintf (stderr, "%s: could not obtain control of tty.", RESNAME); |
1426 | fprintf (stderr, "%s: could not obtain control of tty.", RESNAME); |
1476 | else |
1427 | else |
1477 | { |
1428 | { |
1478 | /* Reopen stdin, stdout and stderr over the tty file descriptor */ |
1429 | /* Reopen stdin, stdout and stderr over the tty file descriptor */ |
1479 | dup2 (pty.tty, STDIN_FILENO); |
1430 | dup2 (pty->tty, STDIN_FILENO); |
1480 | dup2 (pty.tty, STDOUT_FILENO); |
1431 | dup2 (pty->tty, STDOUT_FILENO); |
1481 | dup2 (pty.tty, STDERR_FILENO); |
1432 | dup2 (pty->tty, STDERR_FILENO); |
1482 | |
1433 | |
1483 | // close all our file handles that we do no longer need |
1434 | // close all our file handles that we do no longer need |
1484 | for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++) |
1435 | for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++) |
1485 | { |
1436 | { |
1486 | if ((*t)->pty.pty > 2) close ((*t)->pty.pty); |
1437 | if ((*t)->pty->pty > 2) close ((*t)->pty->pty); |
1487 | if ((*t)->pty.tty > 2) close ((*t)->pty.tty); |
1438 | if ((*t)->pty->tty > 2) close ((*t)->pty->tty); |
1488 | } |
1439 | } |
1489 | |
1440 | |
1490 | run_child (argv); |
1441 | run_child (argv); |
1491 | fprintf (stderr, "%s: unable to exec child.", RESNAME); |
1442 | fprintf (stderr, "%s: unable to exec child.", RESNAME); |
1492 | } |
1443 | } |
1493 | |
1444 | |
1494 | _exit (EXIT_FAILURE); |
1445 | _exit (EXIT_FAILURE); |
1495 | |
1446 | |
1496 | default: |
1447 | default: |
1497 | { |
1448 | if (!OPTION (Opt_utmpInhibit)) |
1498 | #if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT) |
1449 | pty->login (cmd_pid, OPTION (Opt_loginShell), rs[Rs_display_name]); |
1499 | int fdstdin; |
|
|
1500 | |
1450 | |
1501 | fdstdin = dup (STDIN_FILENO); |
1451 | pty->close_tty (); |
1502 | dup2 (pty.tty, STDIN_FILENO); |
|
|
1503 | #endif |
|
|
1504 | |
|
|
1505 | #ifdef UTMP_SUPPORT |
|
|
1506 | privileged_utmp (SAVE); |
|
|
1507 | #endif |
|
|
1508 | |
|
|
1509 | #if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT) |
|
|
1510 | |
|
|
1511 | dup2 (fdstdin, STDIN_FILENO); |
|
|
1512 | close (fdstdin); |
|
|
1513 | #endif |
|
|
1514 | } |
|
|
1515 | |
|
|
1516 | pty.close_tty (); /* keep STDERR_FILENO, pty.pty, display->fd () open */ |
|
|
1517 | break; |
1452 | break; |
1518 | } |
1453 | } |
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 | } |
1454 | } |
1528 | |
1455 | |
1529 | /* ------------------------------------------------------------------------- * |
1456 | /* ------------------------------------------------------------------------- * |
1530 | * CHILD PROCESS OPERATIONS * |
1457 | * CHILD PROCESS OPERATIONS * |
1531 | * ------------------------------------------------------------------------- */ |
1458 | * ------------------------------------------------------------------------- */ |
… | |
… | |
1575 | // unblock signals (signals are blocked by iom.C |
1502 | // unblock signals (signals are blocked by iom.C |
1576 | sigset_t ss; |
1503 | sigset_t ss; |
1577 | sigemptyset (&ss); |
1504 | sigemptyset (&ss); |
1578 | sigprocmask (SIG_SETMASK, &ss, 0); |
1505 | sigprocmask (SIG_SETMASK, &ss, 0); |
1579 | |
1506 | |
1580 | #ifndef __QNX__ |
|
|
1581 | /* command interpreter path */ |
1507 | /* command interpreter path */ |
1582 | if (argv != NULL) |
1508 | if (argv != NULL) |
1583 | { |
1509 | { |
1584 | # ifdef DEBUG_CMD |
1510 | # ifdef DEBUG_CMD |
1585 | int i; |
1511 | int i; |
… | |
… | |
1611 | |
1537 | |
1612 | execlp (shell, argv0, NULL); |
1538 | execlp (shell, argv0, NULL); |
1613 | /* no error message: STDERR is closed! */ |
1539 | /* no error message: STDERR is closed! */ |
1614 | } |
1540 | } |
1615 | |
1541 | |
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; |
1542 | return -1; |
1673 | } |
1543 | } |
1674 | |
1544 | |
1675 | /*----------------------- end-of-file (C source) -----------------------*/ |
1545 | /*----------------------- end-of-file (C source) -----------------------*/ |