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.22 by pcg, Sat Jan 31 03:27:45 2004 UTC vs.
Revision 1.23 by pcg, Sun Feb 1 01:34:41 2004 UTC

326#endif 326#endif
327#ifdef KEEP_SCROLLCOLOR 327#ifdef KEEP_SCROLLCOLOR
328 COLOR_SCROLLBAR, 328 COLOR_SCROLLBAR,
329 COLOR_SCROLLTROUGH, 329 COLOR_SCROLLTROUGH,
330#endif /* KEEP_SCROLLCOLOR */ 330#endif /* KEEP_SCROLLCOLOR */
331
331 }; 332 };
332 333
333const char *const xa_names[NUM_XA] = 334const char *const xa_names[NUM_XA] =
334 { 335 {
335 "TEXT", 336 "TEXT",
444 ttymode = S_IRUSR | S_IWUSR | S_IWGRP; 445 ttymode = S_IRUSR | S_IWUSR | S_IWGRP;
445 ttygid = gr->gr_gid; 446 ttygid = gr->gr_gid;
446 } 447 }
447 else 448 else
448#endif /* TTY_GID_SUPPORT */ 449#endif /* TTY_GID_SUPPORT */
450
449 { 451 {
450 ttymode = S_IRUSR | S_IWUSR | S_IWGRP | S_IWOTH; 452 ttymode = S_IRUSR | S_IWUSR | S_IWGRP | S_IWOTH;
451 ttygid = getgid (); 453 ttygid = getgid ();
452 } 454 }
453 455
657#ifndef NO_OLD_SELECTION 659#ifndef NO_OLD_SELECTION
658 660
659 else if (STRNCASECMP(rs[Rs_selectstyle], "old", 3) == 0) 661 else if (STRNCASECMP(rs[Rs_selectstyle], "old", 3) == 0)
660 selection_style = OLD_SELECT; 662 selection_style = OLD_SELECT;
661#endif 663#endif
664
662 } 665 }
663 666
664#ifdef HAVE_SCROLLBARS 667#ifdef HAVE_SCROLLBARS
665 setup_scrollbar (rs[Rs_scrollBar_align], rs[Rs_scrollstyle], 668 setup_scrollbar (rs[Rs_scrollBar_align], rs[Rs_scrollstyle],
666 rs[Rs_scrollBar_thickness]); 669 rs[Rs_scrollBar_thickness]);
667#endif 670#endif
668 671
669 TermWin.fontset = new rxvt_fontset (this); 672 TermWin.fontset = new rxvt_fontset (this);
670 TermWin.fontset->populate (rs[Rs_font]); 673 TermWin.fontset->populate (rs[Rs_font]);
671 TermWin.fwidth = TermWin.fontset->base_font ()->width; 674 TermWin.fwidth = TermWin.fontset->base_font ()->width;
805#endif 808#endif
806#if HAVE_NL_LANGINFO 809#if HAVE_NL_LANGINFO
807 free (codeset); 810 free (codeset);
808 codeset = strdup (nl_langinfo (CODESET)); 811 codeset = strdup (nl_langinfo (CODESET));
809 enc_utf8 = !STRCASECMP (codeset, "UTF-8") 812 enc_utf8 = !STRCASECMP (codeset, "UTF-8")
810 || !STRCASECMP (codeset, "UTF8"); 813 || !STRCASECMP (codeset, "UTF8");
811#else 814#else
812 enc_utf8 = 1; 815 enc_utf8 = 1;
813#endif 816#endif
814} 817}
815 818
945 948
946 if (!rXParseAllocColor (&xcol, rs[Rs_color + i])) 949 if (!rXParseAllocColor (&xcol, rs[Rs_color + i]))
947 { 950 {
948 switch (i) 951 switch (i)
949 { 952 {
950 case Color_fg: 953 case Color_fg:
951 case Color_bg: 954 case Color_bg:
952 /* fatal: need bg/fg color */ 955 /* fatal: need bg/fg color */
953 rxvt_print_error ("aborting"); 956 rxvt_print_error ("aborting");
954 exit (EXIT_FAILURE); 957 exit (EXIT_FAILURE);
955 /* NOTREACHED */ 958 /* NOTREACHED */
956 break; 959 break;
957#ifndef NO_CURSORCOLOR 960#ifndef NO_CURSORCOLOR
958 case Color_cursor2: 961 case Color_cursor2:
959 xcol = PixColors[Color_fg]; 962 xcol = PixColors[Color_fg];
960 break; 963 break;
961#endif /* ! NO_CURSORCOLOR */ 964#endif /* ! NO_CURSORCOLOR */
962 case Color_pointer: 965 case Color_pointer:
963 xcol = PixColors[Color_fg]; 966 xcol = PixColors[Color_fg];
964 break; 967 break;
965 default: 968 default:
966 xcol = PixColors[Color_bg]; /* None */ 969 xcol = PixColors[Color_bg]; /* None */
967 break; 970 break;
968 } 971 }
969 } 972 }
970 } 973 }
971 974
972 PixColors[i] = xcol; 975 PixColors[i] = xcol;
1044 i -= 8; 1047 i -= 8;
1045#ifndef NO_BRIGHTCOLOR 1048#ifndef NO_BRIGHTCOLOR
1046 rs[Rs_color + idx] = rs[Rs_color + minBrightCOLOR + i]; 1049 rs[Rs_color + idx] = rs[Rs_color + minBrightCOLOR + i];
1047 return; 1050 return;
1048#endif 1051#endif
1052
1049 } 1053 }
1050 1054
1051 if (i >= 0 && i <= 7) /* normal colors */ 1055 if (i >= 0 && i <= 7) /* normal colors */
1052 rs[Rs_color + idx] = rs[Rs_color + minCOLOR + i]; 1056 rs[Rs_color + idx] = rs[Rs_color + minCOLOR + i];
1053 } 1057 }
1086 { 1090 {
1087 if (kc[k] == 0) 1091 if (kc[k] == 0)
1088 break; 1092 break;
1089 switch (XKeycodeToKeysym(Xdisplay, kc[k], 0)) 1093 switch (XKeycodeToKeysym(Xdisplay, kc[k], 0))
1090 { 1094 {
1091 case XK_Num_Lock: 1095 case XK_Num_Lock:
1092 ModNumLockMask = modmasks[i - 1]; 1096 ModNumLockMask = modmasks[i - 1];
1093 /* FALLTHROUGH */ 1097 /* FALLTHROUGH */
1094 default: 1098 default:
1095 continue; /* for(;;) */ 1099 continue; /* for(;;) */
1096 case XK_Meta_L: 1100 case XK_Meta_L:
1097 case XK_Meta_R: 1101 case XK_Meta_R:
1098 cm = "meta"; 1102 cm = "meta";
1099 realmeta = i; 1103 realmeta = i;
1100 break; 1104 break;
1101 case XK_Alt_L: 1105 case XK_Alt_L:
1102 case XK_Alt_R: 1106 case XK_Alt_R:
1103 cm = "alt"; 1107 cm = "alt";
1104 realalt = i; 1108 realalt = i;
1105 break; 1109 break;
1106 case XK_Super_L: 1110 case XK_Super_L:
1107 case XK_Super_R: 1111 case XK_Super_R:
1108 cm = "super"; 1112 cm = "super";
1109 break; 1113 break;
1110 case XK_Hyper_L: 1114 case XK_Hyper_L:
1111 case XK_Hyper_R: 1115 case XK_Hyper_R:
1112 cm = "hyper"; 1116 cm = "hyper";
1113 break; 1117 break;
1114 } 1118 }
1115 if (rsmod && STRNCASECMP(rsmod, cm, STRLEN(cm)) == 0) 1119 if (rsmod && STRNCASECMP(rsmod, cm, STRLEN(cm)) == 0)
1116 requestedmeta = i; 1120 requestedmeta = i;
1117 } 1121 }
1118 } 1122 }
1164 RootWindow(Xdisplay, Xscreen), 1168 RootWindow(Xdisplay, Xscreen),
1165 Xvisual, AllocNone); 1169 Xvisual, AllocNone);
1166 } 1170 }
1167 } 1171 }
1168#endif 1172#endif
1173
1169 } 1174 }
1170 1175
1171 /* grab colors before netscape does */ 1176 /* grab colors before netscape does */
1172 Get_Colours (); 1177 Get_Colours ();
1173 1178
1185 1190
1186 attributes.background_pixel = PixColors[Color_fg]; 1191 attributes.background_pixel = PixColors[Color_fg];
1187 attributes.border_pixel = PixColors[Color_border]; 1192 attributes.border_pixel = PixColors[Color_border];
1188 attributes.colormap = Xcmap; 1193 attributes.colormap = Xcmap;
1189 TermWin.parent[0] = XCreateWindow (Xdisplay, DefaultRootWindow (Xdisplay), 1194 TermWin.parent[0] = XCreateWindow (Xdisplay, DefaultRootWindow (Xdisplay),
1190 szHint.x, szHint.y, 1195 szHint.x, szHint.y,
1191 szHint.width, szHint.height, 1196 szHint.width, szHint.height,
1192 TermWin.ext_bwidth, 1197 TermWin.ext_bwidth,
1193 Xdepth, InputOutput, 1198 Xdepth, InputOutput,
1194 Xvisual, 1199 Xvisual,
1195 CWBackPixel | CWBorderPixel 1200 CWBackPixel | CWBorderPixel
1196 | CWColormap, &attributes); 1201 | CWColormap, &attributes);
1197#else 1202#else
1198 TermWin.parent[0] = XCreateSimpleWindow (Xdisplay, DefaultRootWindow (Xdisplay), 1203 TermWin.parent[0] = XCreateSimpleWindow (Xdisplay, DefaultRootWindow (Xdisplay),
1199 szHint.x, szHint.y, 1204 szHint.x, szHint.y,
1200 szHint.width, 1205 szHint.width,
1201 szHint.height, 1206 szHint.height,
1202 TermWin.ext_bwidth, 1207 TermWin.ext_bwidth,
1203 PixColors[Color_border], 1208 PixColors[Color_border],
1204 PixColors[Color_fg]); 1209 PixColors[Color_fg]);
1205#endif 1210#endif
1206 1211
1207 xterm_seq (XTerm_title, rs[Rs_title], CHAR_ST); 1212 xterm_seq (XTerm_title, rs[Rs_title], CHAR_ST);
1208 xterm_seq (XTerm_iconName, rs[Rs_iconName], CHAR_ST); 1213 xterm_seq (XTerm_iconName, rs[Rs_iconName], CHAR_ST);
1209 1214
1241 blackcolour.red = 0; 1246 blackcolour.red = 0;
1242 blackcolour.green = 0; 1247 blackcolour.green = 0;
1243 blackcolour.blue = 0; 1248 blackcolour.blue = 0;
1244 Font f = XLoadFont (Xdisplay, "fixed"); 1249 Font f = XLoadFont (Xdisplay, "fixed");
1245 blank_cursor = XCreateGlyphCursor (Xdisplay, f, f, ' ', ' ', 1250 blank_cursor = XCreateGlyphCursor (Xdisplay, f, f, ' ', ' ',
1246 &blackcolour, &blackcolour); 1251 &blackcolour, &blackcolour);
1247 XUnloadFont (Xdisplay, f); 1252 XUnloadFont (Xdisplay, f);
1248 } 1253 }
1249#endif 1254#endif
1250 1255
1251 /* the vt window */ 1256 /* the vt window */
1252 TermWin.vt = XCreateSimpleWindow(Xdisplay, TermWin.parent[0], 1257 TermWin.vt = XCreateSimpleWindow(Xdisplay, TermWin.parent[0],
1253 window_vt_x, window_vt_y, 1258 window_vt_x, window_vt_y,
1254 TermWin_TotalWidth(), 1259 TermWin_TotalWidth(),
1255 TermWin_TotalHeight(), 1260 TermWin_TotalHeight(),
1256 0, 1261 0,
1257 PixColors[Color_fg], 1262 PixColors[Color_fg],
1258 PixColors[Color_bg]); 1263 PixColors[Color_bg]);
1259#ifdef DEBUG_X 1264#ifdef DEBUG_X
1260 XStoreName(Xdisplay, TermWin.vt, "vt window"); 1265 XStoreName(Xdisplay, TermWin.vt, "vt window");
1261#endif 1266#endif
1262 1267
1263 vt_emask = (ExposureMask | ButtonPressMask | ButtonReleaseMask 1268 vt_emask = (ExposureMask | ButtonPressMask | ButtonReleaseMask
1277#if defined(MENUBAR) && (MENUBAR_MAX > 1) 1282#if defined(MENUBAR) && (MENUBAR_MAX > 1)
1278 1283
1279 if (menuBar_height()) 1284 if (menuBar_height())
1280 { 1285 {
1281 menuBar.win = XCreateSimpleWindow(Xdisplay, TermWin.parent[0], 1286 menuBar.win = XCreateSimpleWindow(Xdisplay, TermWin.parent[0],
1282 window_vt_x, 0, 1287 window_vt_x, 0,
1283 TermWin_TotalWidth(), 1288 TermWin_TotalWidth(),
1284 menuBar_TotalHeight(), 1289 menuBar_TotalHeight(),
1285 0, 1290 0,
1286 PixColors[Color_fg], 1291 PixColors[Color_fg],
1287 PixColors[Color_scroll]); 1292 PixColors[Color_scroll]);
1288#ifdef DEBUG_X 1293#ifdef DEBUG_X
1289 1294
1290 XStoreName(Xdisplay, menuBar.win, "menubar"); 1295 XStoreName(Xdisplay, menuBar.win, "menubar");
1291#endif 1296#endif
1292 1297
1315 /* graphics context for the vt window */ 1320 /* graphics context for the vt window */
1316 gcvalue.foreground = PixColors[Color_fg]; 1321 gcvalue.foreground = PixColors[Color_fg];
1317 gcvalue.background = PixColors[Color_bg]; 1322 gcvalue.background = PixColors[Color_bg];
1318 gcvalue.graphics_exposures = 1; 1323 gcvalue.graphics_exposures = 1;
1319 TermWin.gc = XCreateGC(Xdisplay, TermWin.vt, 1324 TermWin.gc = XCreateGC(Xdisplay, TermWin.vt,
1320 GCForeground | GCBackground 1325 GCForeground | GCBackground
1321 | GCGraphicsExposures, &gcvalue); 1326 | GCGraphicsExposures, &gcvalue);
1322 1327
1323#if defined(MENUBAR) || defined(RXVT_SCROLLBAR) 1328#if defined(MENUBAR) || defined(RXVT_SCROLLBAR)
1324 1329
1325 gcvalue.foreground = PixColors[Color_topShadow]; 1330 gcvalue.foreground = PixColors[Color_topShadow];
1326 topShadowGC = XCreateGC(Xdisplay, TermWin.vt, 1331 topShadowGC = XCreateGC(Xdisplay, TermWin.vt,
1327 GCForeground, &gcvalue); 1332 GCForeground, &gcvalue);
1328 gcvalue.foreground = PixColors[Color_bottomShadow]; 1333 gcvalue.foreground = PixColors[Color_bottomShadow];
1329 botShadowGC = XCreateGC(Xdisplay, TermWin.vt, 1334 botShadowGC = XCreateGC(Xdisplay, TermWin.vt,
1330 GCForeground, &gcvalue); 1335 GCForeground, &gcvalue);
1331 gcvalue.foreground = PixColors[(XDEPTH <= 2 ? Color_fg 1336 gcvalue.foreground = PixColors[(XDEPTH <= 2 ? Color_fg
1332 : Color_scroll)]; 1337 : Color_scroll)];
1333 scrollbarGC = XCreateGC(Xdisplay, TermWin.vt, 1338 scrollbarGC = XCreateGC(Xdisplay, TermWin.vt,
1334 GCForeground, &gcvalue); 1339 GCForeground, &gcvalue);
1335#endif 1340#endif
1336} 1341}
1337 1342
1338/*----------------------------------------------------------------------*/ 1343/*----------------------------------------------------------------------*/
1339/* 1344/*
1392 1397
1393#ifndef __QNX__ 1398#ifndef __QNX__
1394 /* spin off the command interpreter */ 1399 /* spin off the command interpreter */
1395 switch (cmd_pid = fork ()) 1400 switch (cmd_pid = fork ())
1396 { 1401 {
1397 case -1: 1402 case -1:
1398 rxvt_print_error("can't fork"); 1403 rxvt_print_error("can't fork");
1399 return -1; 1404 return -1;
1400 case 0: 1405 case 0:
1401 close (cfd); /* only keep tty_fd and STDERR open */ 1406 close (cfd); /* only keep tty_fd and STDERR open */
1402 close (Xfd); 1407 close (Xfd);
1403 if (rxvt_control_tty (tty_fd, ttydev) < 0) 1408 if (rxvt_control_tty (tty_fd, ttydev) < 0)
1404 rxvt_print_error ("could not obtain control of tty"); 1409 rxvt_print_error ("could not obtain control of tty");
1405 else 1410 else
1411 {
1412 /* Reopen stdin, stdout and stderr over the tty file descriptor */
1413 dup2 (tty_fd, STDIN_FILENO);
1414 dup2 (tty_fd, STDOUT_FILENO);
1415 dup2 (tty_fd, STDERR_FILENO);
1416
1417 if (tty_fd > 2)
1418 close (tty_fd);
1419
1420 run_child (argv);
1421 }
1422 exit (EXIT_FAILURE);
1423 /* NOTREACHED */
1424 default:
1406 { 1425 {
1407 /* Reopen stdin, stdout and stderr over the tty file descriptor */ 1426#if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT)
1427 int fdstdin;
1428
1429 fdstdin = dup (STDIN_FILENO);
1408 dup2 (tty_fd, STDIN_FILENO); 1430 dup2 (tty_fd, STDIN_FILENO);
1431#endif
1432
1433#ifdef UTMP_SUPPORT
1434 privileged_utmp (SAVE);
1435#endif
1436
1437#if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT)
1438
1409 dup2 (tty_fd, STDOUT_FILENO); 1439 dup2 (fdstdin, STDIN_FILENO);
1410 dup2 (tty_fd, STDERR_FILENO);
1411
1412 if (tty_fd > 2)
1413 close (tty_fd); 1440 close (fdstdin);
1441#endif
1414 1442
1415 run_child (argv);
1416 } 1443 }
1417 exit (EXIT_FAILURE);
1418 /* NOTREACHED */
1419 default:
1420 {
1421#if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT)
1422 int fdstdin;
1423
1424 fdstdin = dup (STDIN_FILENO);
1425 dup2 (tty_fd, STDIN_FILENO);
1426#endif
1427
1428#ifdef UTMP_SUPPORT
1429 privileged_utmp (SAVE);
1430#endif
1431
1432#if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT)
1433
1434 dup2 (fdstdin, STDIN_FILENO);
1435 close (fdstdin);
1436#endif
1437
1438 }
1439 close (tty_fd); /* keep STDERR_FILENO, cmd_fd, Xfd open */ 1444 close (tty_fd); /* keep STDERR_FILENO, cmd_fd, Xfd open */
1440 break; 1445 break;
1441 } 1446 }
1442#else /* __QNX__ uses qnxspawn() */ 1447#else /* __QNX__ uses qnxspawn() */
1443 fchmod (tty_fd, 0622); 1448 fchmod (tty_fd, 0622);
1444 fcntl (tty_fd, F_SETFD, FD_CLOEXEC); 1449 fcntl (tty_fd, F_SETFD, FD_CLOEXEC);
1445 fcntl (cfd, F_SETFD, FD_CLOEXEC); 1450 fcntl (cfd, F_SETFD, FD_CLOEXEC);
1479 { 1484 {
1480 if (ioctl (fd, SRIOCSREDIR, NULL) < 0) 1485 if (ioctl (fd, SRIOCSREDIR, NULL) < 0)
1481 close (fd); 1486 close (fd);
1482 } 1487 }
1483#endif /* SRIOCSREDIR */ 1488#endif /* SRIOCSREDIR */
1489
1484 } 1490 }
1485 1491
1486 /* reset signals and spin off the command interpreter */ 1492 /* reset signals and spin off the command interpreter */
1487 signal (SIGINT, SIG_DFL); 1493 signal (SIGINT, SIG_DFL);
1488 signal (SIGQUIT, SIG_DFL); 1494 signal (SIGQUIT, SIG_DFL);
1583 } 1589 }
1584 arg_v = arg_a; 1590 arg_v = arg_a;
1585 } 1591 }
1586 iov_a[0] = iov_a[1] = iov_a[2] = tty_fd; 1592 iov_a[0] = iov_a[1] = iov_a[2] = tty_fd;
1587 cmd_pid = qnx_spawn(0, 0, 0, -1, -1, 1593 cmd_pid = qnx_spawn(0, 0, 0, -1, -1,
1588 _SPAWN_SETSID | _SPAWN_TCSETPGRP, 1594 _SPAWN_SETSID | _SPAWN_TCSETPGRP,
1589 command, arg_v, environ, iov_a, 0); 1595 command, arg_v, environ, iov_a, 0);
1590 if (login) 1596 if (login)
1591 free(login); 1597 free(login);
1592 1598
1593 close(tty_fd); 1599 close(tty_fd);
1594 return cmd_fd; 1600 return cmd_fd;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines