… | |
… | |
9 | * - extensive modifications |
9 | * - extensive modifications |
10 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
10 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
11 | * - extensive modifications |
11 | * - extensive modifications |
12 | * Copyright (c) 1999 D J Hawkey Jr <hawkeyd@visi.com> |
12 | * Copyright (c) 1999 D J Hawkey Jr <hawkeyd@visi.com> |
13 | * - QNX support |
13 | * - QNX support |
14 | * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com> |
14 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
15 | * |
15 | * |
16 | * This program is free software; you can redistribute it and/or modify |
16 | * This program is free software; you can redistribute it and/or modify |
17 | * it under the terms of the GNU General Public License as published by |
17 | * it under the terms of the GNU General Public License as published by |
18 | * the Free Software Foundation; either version 2 of the License, or |
18 | * the Free Software Foundation; either version 2 of the License, or |
19 | * (at your option) any later version. |
19 | * (at your option) any later version. |
… | |
… | |
34 | #include "../config.h" /* NECESSARY */ |
34 | #include "../config.h" /* NECESSARY */ |
35 | #include "rxvt.h" /* NECESSARY */ |
35 | #include "rxvt.h" /* NECESSARY */ |
36 | #include "rxvtutil.h" |
36 | #include "rxvtutil.h" |
37 | #include "init.h" |
37 | #include "init.h" |
38 | |
38 | |
|
|
39 | #include <limits> |
|
|
40 | |
39 | #include <csignal> |
41 | #include <csignal> |
40 | |
42 | |
41 | const char *const def_colorName[] = |
43 | const char *const def_colorName[] = |
42 | { |
44 | { |
43 | COLOR_FOREGROUND, |
45 | COLOR_FOREGROUND, |
44 | COLOR_BACKGROUND, |
46 | COLOR_BACKGROUND, |
45 | /* low-intensity colors */ |
47 | /* low-intensity colors */ |
46 | "Black", /* 0: black (#000000) */ |
48 | "Black", /* 0: black (#000000) */ |
47 | #ifndef NO_BRIGHTCOLOR |
|
|
48 | "Red3", /* 1: red (#CD0000) */ |
49 | "Red3", /* 1: red (#CD0000) */ |
49 | "Green3", /* 2: green (#00CD00) */ |
50 | "Green3", /* 2: green (#00CD00) */ |
50 | "Yellow3", /* 3: yellow (#CDCD00) */ |
51 | "Yellow3", /* 3: yellow (#CDCD00) */ |
51 | "Blue3", /* 4: blue (#0000CD) */ |
52 | "Blue3", /* 4: blue (#0000CD) */ |
52 | "Magenta3", /* 5: magenta (#CD00CD) */ |
53 | "Magenta3", /* 5: magenta (#CD00CD) */ |
… | |
… | |
60 | # ifdef XTERM_COLORS |
61 | # ifdef XTERM_COLORS |
61 | "Grey30", /* 8: bright black (#4D4D4D) */ |
62 | "Grey30", /* 8: bright black (#4D4D4D) */ |
62 | # else |
63 | # else |
63 | "Grey25", /* 8: bright black (#404040) */ |
64 | "Grey25", /* 8: bright black (#404040) */ |
64 | # endif |
65 | # endif |
65 | #endif /* NO_BRIGHTCOLOR */ |
|
|
66 | "Red", /* 1/9: bright red (#FF0000) */ |
66 | "Red", /* 1/9: bright red (#FF0000) */ |
67 | "Green", /* 2/10: bright green (#00FF00) */ |
67 | "Green", /* 2/10: bright green (#00FF00) */ |
68 | "Yellow", /* 3/11: bright yellow (#FFFF00) */ |
68 | "Yellow", /* 3/11: bright yellow (#FFFF00) */ |
69 | "Blue", /* 4/12: bright blue (#0000FF) */ |
69 | "Blue", /* 4/12: bright blue (#0000FF) */ |
70 | "Magenta", /* 5/13: bright magenta (#FF00FF) */ |
70 | "Magenta", /* 5/13: bright magenta (#FF00FF) */ |
… | |
… | |
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 | */ |
|
|
337 | |
344 | if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL) |
338 | if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL) |
345 | rs[Rs_display_name] = ":0"; |
339 | rs[Rs_display_name] = ":0"; |
346 | |
340 | |
347 | get_options (r_argc, r_argv); |
341 | get_options (r_argc, r_argv); |
348 | |
342 | |
349 | if (!(display = displays.get (rs[Rs_display_name]))) |
343 | if (!(display = displays.get (rs[Rs_display_name]))) |
350 | 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]); |
351 | |
345 | |
352 | extract_resources (); |
346 | extract_resources (); |
|
|
347 | |
353 | free (r_argv); |
348 | free (r_argv); |
354 | |
349 | |
355 | /* |
350 | /* |
356 | * set any defaults not already set |
351 | * set any defaults not already set |
357 | */ |
352 | */ |
… | |
… | |
369 | if (!rs[Rs_iconName]) |
364 | if (!rs[Rs_iconName]) |
370 | rs[Rs_iconName] = rs[Rs_name]; |
365 | rs[Rs_iconName] = rs[Rs_name]; |
371 | } |
366 | } |
372 | |
367 | |
373 | if (rs[Rs_saveLines] && (i = atoi (rs[Rs_saveLines])) >= 0) |
368 | if (rs[Rs_saveLines] && (i = atoi (rs[Rs_saveLines])) >= 0) |
374 | saveLines = BOUND_POSITIVE_INT16 (i); |
369 | saveLines = min (i, MAX_SAVELINES); |
375 | |
370 | |
376 | #if ENABLE_FRILLS |
371 | #if ENABLE_FRILLS |
377 | if (rs[Rs_int_bwidth] && (i = atoi (rs[Rs_int_bwidth])) >= 0) |
372 | if (rs[Rs_int_bwidth] && (i = atoi (rs[Rs_int_bwidth])) >= 0) |
378 | int_bwidth = min (i, 100); /* arbitrary limit */ |
373 | int_bwidth = min (i, std::numeric_limits<int16_t>::max ()); |
|
|
374 | |
379 | if (rs[Rs_ext_bwidth] && (i = atoi (rs[Rs_ext_bwidth])) >= 0) |
375 | if (rs[Rs_ext_bwidth] && (i = atoi (rs[Rs_ext_bwidth])) >= 0) |
380 | ext_bwidth = min (i, 100); /* arbitrary limit */ |
376 | ext_bwidth = min (i, std::numeric_limits<int16_t>::max ()); |
|
|
377 | |
381 | if (rs[Rs_lineSpace] && (i = atoi (rs[Rs_lineSpace])) >= 0) |
378 | if (rs[Rs_lineSpace] && (i = atoi (rs[Rs_lineSpace])) >= 0) |
382 | lineSpace = min (i, 100); /* arbitrary limit */ |
379 | lineSpace = min (i, std::numeric_limits<int16_t>::max ()); |
383 | #endif |
380 | #endif |
384 | |
381 | |
385 | #ifdef POINTER_BLANK |
382 | #ifdef POINTER_BLANK |
386 | if (rs[Rs_pointerBlankDelay] && (i = atoi (rs[Rs_pointerBlankDelay])) >= 0) |
383 | if (rs[Rs_pointerBlankDelay] && (i = atoi (rs[Rs_pointerBlankDelay])) >= 0) |
387 | pointerBlankDelay = i; |
384 | pointerBlankDelay = i; |
… | |
… | |
389 | pointerBlankDelay = 2; |
386 | pointerBlankDelay = 2; |
390 | #endif |
387 | #endif |
391 | |
388 | |
392 | /* no point having a scrollbar without having any scrollback! */ |
389 | /* no point having a scrollbar without having any scrollback! */ |
393 | if (!saveLines) |
390 | if (!saveLines) |
394 | options &= ~Opt_scrollBar; |
391 | set_option (Opt_scrollBar, 0); |
395 | |
392 | |
396 | #ifdef PRINTPIPE |
393 | #ifdef PRINTPIPE |
397 | if (!rs[Rs_print_pipe]) |
394 | if (!rs[Rs_print_pipe]) |
398 | rs[Rs_print_pipe] = PRINTPIPE; |
395 | rs[Rs_print_pipe] = PRINTPIPE; |
399 | #endif |
396 | #endif |
… | |
… | |
442 | setup_scrollbar (rs[Rs_scrollBar_align], rs[Rs_scrollstyle], rs[Rs_scrollBar_thickness]); |
439 | setup_scrollbar (rs[Rs_scrollBar_align], rs[Rs_scrollstyle], rs[Rs_scrollBar_thickness]); |
443 | #endif |
440 | #endif |
444 | |
441 | |
445 | #ifdef XTERM_REVERSE_VIDEO |
442 | #ifdef XTERM_REVERSE_VIDEO |
446 | /* this is how xterm implements reverseVideo */ |
443 | /* this is how xterm implements reverseVideo */ |
447 | if (options & Opt_reverseVideo) |
444 | if (OPTION (Opt_reverseVideo)) |
448 | { |
445 | { |
449 | if (!rs[Rs_color + Color_fg]) |
446 | if (!rs[Rs_color + Color_fg]) |
450 | rs[Rs_color + Color_fg] = def_colorName[Color_bg]; |
447 | rs[Rs_color + Color_fg] = def_colorName[Color_bg]; |
451 | if (!rs[Rs_color + Color_bg]) |
448 | if (!rs[Rs_color + Color_bg]) |
452 | rs[Rs_color + Color_bg] = def_colorName[Color_fg]; |
449 | rs[Rs_color + Color_bg] = def_colorName[Color_fg]; |
… | |
… | |
457 | if (!rs[Rs_color + i]) |
454 | if (!rs[Rs_color + i]) |
458 | rs[Rs_color + i] = def_colorName[i]; |
455 | rs[Rs_color + i] = def_colorName[i]; |
459 | |
456 | |
460 | #ifndef XTERM_REVERSE_VIDEO |
457 | #ifndef XTERM_REVERSE_VIDEO |
461 | /* this is how we implement reverseVideo */ |
458 | /* this is how we implement reverseVideo */ |
462 | if (options & Opt_reverseVideo) |
459 | if (OPTION (Opt_reverseVideo)) |
463 | SWAP_IT (rs[Rs_color + Color_fg], rs[Rs_color + Color_bg], const char *); |
460 | ::swap (rs[Rs_color + Color_fg], rs[Rs_color + Color_bg]); |
464 | #endif |
461 | #endif |
465 | |
462 | |
466 | /* convenient aliases for setting fg/bg to colors */ |
463 | /* convenient aliases for setting fg/bg to colors */ |
467 | color_aliases (Color_fg); |
464 | color_aliases (Color_fg); |
468 | color_aliases (Color_bg); |
465 | color_aliases (Color_bg); |
… | |
… | |
521 | |
518 | |
522 | /* avoiding the math library: |
519 | /* avoiding the math library: |
523 | * i = (int) (ceil (log10 ((unsigned int)parent[0]))) */ |
520 | * i = (int) (ceil (log10 ((unsigned int)parent[0]))) */ |
524 | for (i = 0, u = (unsigned int)parent[0]; u; u /= 10, i++) |
521 | for (i = 0, u = (unsigned int)parent[0]; u; u /= 10, i++) |
525 | ; |
522 | ; |
526 | MAX_IT (i, 1); |
523 | max_it (i, 1); |
527 | env_windowid = (char *)rxvt_malloc ((i + 10) * sizeof (char)); |
524 | env_windowid = (char *)rxvt_malloc ((i + 10) * sizeof (char)); |
528 | |
525 | |
529 | sprintf (env_windowid, "WINDOWID=%u", |
526 | sprintf (env_windowid, "WINDOWID=%u", |
530 | (unsigned int)parent[0]); |
527 | (unsigned int)parent[0]); |
531 | |
528 | |
… | |
… | |
574 | * This should support all European type languages. |
571 | * This should support all European type languages. |
575 | */ |
572 | */ |
576 | void |
573 | void |
577 | rxvt_term::set_locale (const char *locale) |
574 | rxvt_term::set_locale (const char *locale) |
578 | { |
575 | { |
|
|
576 | set_environ (envv); |
|
|
577 | |
579 | #if HAVE_XSETLOCALE || HAVE_SETLOCALE |
578 | #if HAVE_XSETLOCALE || HAVE_SETLOCALE |
580 | free (this->locale); |
579 | free (this->locale); |
581 | this->locale = setlocale (LC_CTYPE, locale); |
580 | this->locale = setlocale (LC_CTYPE, locale); |
582 | |
581 | |
583 | if (!this->locale) |
582 | if (!this->locale) |
584 | { |
583 | { |
585 | if (*locale) |
584 | if (*locale) |
586 | { |
585 | { |
587 | rxvt_warn ("unable to set locale \"%s\", using default locale instead.\n", locale); |
586 | rxvt_warn ("unable to set locale \"%s\", using C locale instead.\n", locale); |
588 | setlocale (LC_CTYPE, ""); |
587 | setlocale (LC_CTYPE, "C"); |
589 | } |
588 | } |
590 | else |
589 | else |
591 | rxvt_warn ("default locale unavailable, check LC_* and LANG variables. Continuing.\n"); |
590 | rxvt_warn ("default locale unavailable, check LC_* and LANG variables. Continuing.\n"); |
592 | |
591 | |
593 | this->locale = ""; |
592 | this->locale = "C"; |
594 | } |
593 | } |
595 | |
594 | |
596 | |
595 | |
597 | this->locale = rxvt_strdup (this->locale); |
596 | this->locale = rxvt_strdup (this->locale); |
598 | SET_LOCALE (this->locale); |
597 | SET_LOCALE (this->locale); |
… | |
… | |
613 | } |
612 | } |
614 | |
613 | |
615 | void |
614 | void |
616 | rxvt_term::init_xlocale () |
615 | rxvt_term::init_xlocale () |
617 | { |
616 | { |
|
|
617 | set_environ (envv); |
|
|
618 | |
618 | #ifdef USE_XIM |
619 | #ifdef USE_XIM |
619 | if (!locale) |
620 | if (!locale) |
620 | rxvt_warn ("setting locale failed, working without locale support.\n"); |
621 | rxvt_warn ("setting locale failed, working without locale support.\n"); |
621 | else |
622 | else |
622 | { |
623 | { |
… | |
… | |
644 | * Initialize the command connection. |
645 | * Initialize the command connection. |
645 | * This should be called after the X server connection is established. |
646 | * This should be called after the X server connection is established. |
646 | */ |
647 | */ |
647 | |
648 | |
648 | #ifdef META8_OPTION |
649 | #ifdef META8_OPTION |
649 | meta_char = (options & Opt_meta8 ? 0x80 : C0_ESC); |
650 | meta_char = OPTION (Opt_meta8) ? 0x80 : C0_ESC; |
650 | #endif |
651 | #endif |
651 | |
652 | |
652 | get_ourmods (); |
653 | get_ourmods (); |
653 | |
654 | |
654 | if (!(options & Opt_scrollTtyOutput)) |
655 | if (!OPTION (Opt_scrollTtyOutput)) |
655 | priv_modes |= PrivMode_TtyOutputInh; |
656 | priv_modes |= PrivMode_TtyOutputInh; |
656 | if (options & Opt_scrollTtyKeypress) |
657 | if (OPTION (Opt_scrollTtyKeypress)) |
657 | priv_modes |= PrivMode_Keypress; |
658 | priv_modes |= PrivMode_Keypress; |
658 | if (!(options & Opt_jumpScroll)) |
659 | if (!OPTION (Opt_jumpScroll)) |
659 | priv_modes |= PrivMode_smoothScroll; |
660 | priv_modes |= PrivMode_smoothScroll; |
660 | |
661 | |
661 | #ifndef NO_BACKSPACE_KEY |
662 | #ifndef NO_BACKSPACE_KEY |
662 | if (strcmp (key_backspace, "DEC") == 0) |
663 | if (strcmp (key_backspace, "DEC") == 0) |
663 | priv_modes |= PrivMode_HaveBackSpace; |
664 | priv_modes |= PrivMode_HaveBackSpace; |
664 | #endif |
665 | #endif |
665 | |
666 | |
666 | /* add value for scrollBar */ |
667 | /* add value for scrollBar */ |
667 | if (scrollbar_visible ()) |
668 | if (scrollBar.state) |
668 | { |
669 | { |
669 | priv_modes |= PrivMode_scrollBar; |
670 | priv_modes |= PrivMode_scrollBar; |
670 | SavedModes |= PrivMode_scrollBar; |
671 | SavedModes |= PrivMode_scrollBar; |
671 | } |
672 | } |
672 | |
|
|
673 | if (menubar_visible ()) |
|
|
674 | { |
|
|
675 | priv_modes |= PrivMode_menuBar; |
|
|
676 | SavedModes |= PrivMode_menuBar; |
|
|
677 | } |
|
|
678 | |
|
|
679 | #ifdef CURSOR_BLINK |
|
|
680 | if (options & Opt_cursorBlink) |
|
|
681 | (void)gettimeofday (&lastcursorchange, NULL); |
|
|
682 | #endif |
|
|
683 | |
673 | |
684 | run_command (argv); |
674 | run_command (argv); |
685 | } |
675 | } |
686 | |
676 | |
687 | /*----------------------------------------------------------------------*/ |
677 | /*----------------------------------------------------------------------*/ |
… | |
… | |
702 | continue; |
692 | continue; |
703 | |
693 | |
704 | if (!rXParseAllocColor (&xcol, rs[Rs_color + i])) |
694 | if (!rXParseAllocColor (&xcol, rs[Rs_color + i])) |
705 | { |
695 | { |
706 | #ifndef XTERM_REVERSE_VIDEO |
696 | #ifndef XTERM_REVERSE_VIDEO |
707 | if (i < 2 && (options & Opt_reverseVideo)) |
697 | if (i < 2 && OPTION (Opt_reverseVideo)) |
708 | rs[Rs_color + i] = def_colorName[!i]; |
698 | rs[Rs_color + i] = def_colorName[!i]; |
709 | else |
699 | else |
710 | #endif |
700 | #endif |
711 | rs[Rs_color + i] = def_colorName[i]; |
701 | rs[Rs_color + i] = def_colorName[i]; |
712 | |
702 | |
… | |
… | |
754 | 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]; |
755 | 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]; |
756 | } |
746 | } |
757 | |
747 | |
758 | /* |
748 | /* |
759 | * get scrollBar/menuBar shadow colors |
749 | * get scrollBar shadow colors |
760 | * |
750 | * |
761 | * The calculations of topShadow/bottomShadow values are adapted |
751 | * The calculations of topShadow/bottomShadow values are adapted |
762 | * from the fvwm window manager. |
752 | * from the fvwm window manager. |
763 | */ |
753 | */ |
764 | #ifdef KEEP_SCROLLCOLOR |
754 | #ifdef KEEP_SCROLLCOLOR |
… | |
… | |
809 | int i = atoi (rs[Rs_color + idx]); |
799 | int i = atoi (rs[Rs_color + idx]); |
810 | |
800 | |
811 | if (i >= 8 && i <= 15) |
801 | if (i >= 8 && i <= 15) |
812 | { /* bright colors */ |
802 | { /* bright colors */ |
813 | i -= 8; |
803 | i -= 8; |
814 | #ifndef NO_BRIGHTCOLOR |
|
|
815 | rs[Rs_color + idx] = rs[Rs_color + minBrightCOLOR + i]; |
804 | rs[Rs_color + idx] = rs[Rs_color + minBrightCOLOR + i]; |
816 | return; |
805 | return; |
817 | #endif |
|
|
818 | } |
806 | } |
819 | |
807 | |
820 | if (i >= 0 && i <= 7) /* normal colors */ |
808 | if (i >= 0 && i <= 7) /* normal colors */ |
821 | rs[Rs_color + idx] = rs[Rs_color + minCOLOR + i]; |
809 | rs[Rs_color + idx] = rs[Rs_color + minCOLOR + i]; |
822 | } |
810 | } |
… | |
… | |
921 | #if ENABLE_FRILLS |
909 | #if ENABLE_FRILLS |
922 | Atom prop = None; |
910 | Atom prop = None; |
923 | MWMHints mwmhints; |
911 | MWMHints mwmhints; |
924 | #endif |
912 | #endif |
925 | XGCValues gcvalue; |
913 | XGCValues gcvalue; |
926 | long vt_emask; |
|
|
927 | XSetWindowAttributes attributes; |
914 | XSetWindowAttributes attributes; |
928 | XWindowAttributes gattr; |
915 | XWindowAttributes gattr; |
929 | Window top, parent; |
916 | Window top, parent; |
930 | dDisp; |
917 | dDisp; |
931 | |
918 | |
… | |
… | |
935 | #endif |
922 | #endif |
936 | |
923 | |
937 | assert (sizeof (xa_names) / sizeof (char *) == NUM_XA); |
924 | assert (sizeof (xa_names) / sizeof (char *) == NUM_XA); |
938 | XInternAtoms (disp, (char **)xa_names, NUM_XA, False, xa); |
925 | XInternAtoms (disp, (char **)xa_names, NUM_XA, False, xa); |
939 | |
926 | |
940 | if (options & Opt_transparent) |
927 | if (OPTION (Opt_transparent)) |
941 | { |
928 | { |
942 | XGetWindowAttributes (disp, RootWindow (disp, display->screen), &gattr); |
929 | XGetWindowAttributes (disp, RootWindow (disp, display->screen), &gattr); |
943 | display->depth = gattr.depth; // doh //TODO, per-term not per-display? |
930 | display->depth = gattr.depth; // doh //TODO, per-term not per-display? |
944 | } |
931 | } |
945 | |
932 | |
946 | #if ENABLE_FRILLS |
933 | #if ENABLE_FRILLS |
947 | if (options & Opt_borderLess) |
934 | if (OPTION (Opt_borderLess)) |
948 | { |
935 | { |
949 | prop = XInternAtom(disp, "_MOTIF_WM_INFO", True); |
936 | prop = XInternAtom(disp, "_MOTIF_WM_INFO", True); |
950 | |
937 | |
951 | if (prop == None) |
938 | if (prop == None) |
952 | { |
939 | { |
… | |
… | |
1022 | classHint.res_name = (char *)rs[Rs_name]; |
1009 | classHint.res_name = (char *)rs[Rs_name]; |
1023 | classHint.res_class = (char *)RESCLASS; |
1010 | classHint.res_class = (char *)RESCLASS; |
1024 | |
1011 | |
1025 | wmHint.flags = InputHint | StateHint | WindowGroupHint; |
1012 | wmHint.flags = InputHint | StateHint | WindowGroupHint; |
1026 | wmHint.input = True; |
1013 | wmHint.input = True; |
1027 | wmHint.initial_state = options & Opt_iconic ? IconicState : NormalState; |
1014 | wmHint.initial_state = OPTION (Opt_iconic) ? IconicState : NormalState; |
1028 | wmHint.window_group = top; |
1015 | wmHint.window_group = top; |
1029 | |
1016 | |
1030 | XmbSetWMProperties (disp, top, NULL, NULL, (char **)argv, argc, |
1017 | XmbSetWMProperties (disp, top, NULL, NULL, (char **)argv, argc, |
1031 | &szHint, &wmHint, &classHint); |
1018 | &szHint, &wmHint, &classHint); |
1032 | |
1019 | |
… | |
… | |
1037 | #endif |
1024 | #endif |
1038 | }; |
1025 | }; |
1039 | |
1026 | |
1040 | XSetWMProtocols (disp, top, protocols, sizeof (protocols) / sizeof (protocols[0])); |
1027 | XSetWMProtocols (disp, top, protocols, sizeof (protocols) / sizeof (protocols[0])); |
1041 | |
1028 | |
|
|
1029 | #if ENABLE_FRILLS |
|
|
1030 | if (rs[Rs_transient_for]) |
|
|
1031 | XSetTransientForHint (disp, top, (Window)strtol (rs[Rs_transient_for], 0, 0)); |
|
|
1032 | #endif |
|
|
1033 | |
1042 | #if ENABLE_EWMH |
1034 | #if ENABLE_EWMH |
1043 | long pid = getpid (); |
1035 | long pid = getpid (); |
1044 | |
1036 | |
1045 | XChangeProperty (disp, top, |
1037 | XChangeProperty (disp, top, |
1046 | xa[XA_NET_WM_PID], XA_CARDINAL, 32, |
1038 | xa[XA_NET_WM_PID], XA_CARDINAL, 32, |
… | |
… | |
1066 | #endif |
1058 | #endif |
1067 | |
1059 | |
1068 | /* 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 */ |
1069 | TermWin_cursor = XCreateFontCursor (disp, XC_xterm); |
1061 | TermWin_cursor = XCreateFontCursor (disp, XC_xterm); |
1070 | |
1062 | |
1071 | #if defined(HAVE_SCROLLBARS) || defined(MENUBAR) |
1063 | #ifdef HAVE_SCROLLBARS |
1072 | /* cursor (menuBar/scrollBar): Black-on-White */ |
1064 | /* cursor scrollBar: Black-on-White */ |
1073 | leftptr_cursor = XCreateFontCursor (disp, XC_left_ptr); |
1065 | leftptr_cursor = XCreateFontCursor (disp, XC_left_ptr); |
1074 | #endif |
1066 | #endif |
1075 | |
1067 | |
1076 | /* the vt window */ |
1068 | /* the vt window */ |
1077 | vt = XCreateSimpleWindow (disp, top, |
1069 | vt = XCreateSimpleWindow (disp, top, |
1078 | window_vt_x, |
1070 | window_vt_x, |
1079 | window_vt_y, |
1071 | window_vt_y, |
1080 | TermWin_TotalWidth (), |
1072 | width, |
1081 | TermWin_TotalHeight (), |
1073 | height, |
1082 | 0, |
1074 | 0, |
1083 | pix_colors_focused[Color_fg], |
1075 | pix_colors_focused[Color_fg], |
1084 | pix_colors_focused[Color_bg]); |
1076 | pix_colors_focused[Color_bg]); |
1085 | #ifdef DEBUG_X |
1077 | #ifdef DEBUG_X |
1086 | XStoreName (disp, vt, "vt window"); |
1078 | XStoreName (disp, vt, "vt window"); |
… | |
… | |
1089 | attributes.bit_gravity = NorthWestGravity; |
1081 | attributes.bit_gravity = NorthWestGravity; |
1090 | XChangeWindowAttributes (disp, vt, CWBitGravity, &attributes); |
1082 | XChangeWindowAttributes (disp, vt, CWBitGravity, &attributes); |
1091 | |
1083 | |
1092 | vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; |
1084 | vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; |
1093 | |
1085 | |
1094 | #ifdef POINTER_BLANK |
1086 | if (OPTION (Opt_pointerBlank)) |
1095 | if (options & Opt_pointerBlank) |
|
|
1096 | vt_emask |= PointerMotionMask; |
1087 | vt_emask |= PointerMotionMask; |
1097 | else |
1088 | else |
1098 | #endif |
|
|
1099 | vt_emask |= Button1MotionMask | Button3MotionMask; |
1089 | vt_emask |= Button1MotionMask | Button3MotionMask; |
1100 | |
1090 | |
1101 | XSelectInput (disp, vt, vt_emask); |
1091 | vt_select_input (); |
|
|
1092 | |
1102 | vt_ev.start (display, vt); |
1093 | vt_ev.start (display, vt); |
1103 | |
|
|
1104 | #if defined(MENUBAR) && (MENUBAR_MAX > 1) |
|
|
1105 | if (menuBar_height ()) |
|
|
1106 | { |
|
|
1107 | menuBar.win = XCreateSimpleWindow (disp, top, |
|
|
1108 | window_vt_x, 0, |
|
|
1109 | TermWin_TotalWidth (), |
|
|
1110 | menuBar_TotalHeight (), |
|
|
1111 | 0, |
|
|
1112 | pix_colors_focused[Color_fg], |
|
|
1113 | pix_colors_focused[Color_scroll]); |
|
|
1114 | |
|
|
1115 | #ifdef DEBUG_X |
|
|
1116 | XStoreName (disp, menuBar.win, "menubar"); |
|
|
1117 | #endif |
|
|
1118 | |
|
|
1119 | menuBar.drawable = new rxvt_drawable (display, menuBar.win); |
|
|
1120 | |
|
|
1121 | XDefineCursor (disp, menuBar.win, |
|
|
1122 | XCreateFontCursor (disp, XC_left_ptr)); |
|
|
1123 | |
|
|
1124 | XSelectInput (disp, menuBar.win, |
|
|
1125 | (ExposureMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask)); |
|
|
1126 | menubar_ev.start (display, menuBar.win); |
|
|
1127 | } |
|
|
1128 | #endif |
|
|
1129 | |
1094 | |
1130 | #ifdef XPM_BACKGROUND |
1095 | #ifdef XPM_BACKGROUND |
1131 | if (rs[Rs_backgroundPixmap] != NULL |
1096 | if (rs[Rs_backgroundPixmap] != NULL |
1132 | && ! (options & Opt_transparent)) |
1097 | && ! OPTION (Opt_transparent)) |
1133 | { |
1098 | { |
1134 | const char *p = rs[Rs_backgroundPixmap]; |
1099 | const char *p = rs[Rs_backgroundPixmap]; |
1135 | |
1100 | |
1136 | if ((p = strchr (p, ';')) != NULL) |
1101 | if ((p = strchr (p, ';')) != NULL) |
1137 | { |
1102 | { |
… | |
… | |
1152 | GCForeground | GCBackground | GCGraphicsExposures, |
1117 | GCForeground | GCBackground | GCGraphicsExposures, |
1153 | &gcvalue); |
1118 | &gcvalue); |
1154 | |
1119 | |
1155 | drawable = new rxvt_drawable (display, vt); |
1120 | drawable = new rxvt_drawable (display, vt); |
1156 | |
1121 | |
1157 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
1122 | #ifdef RXVT_SCROLLBAR |
1158 | gcvalue.foreground = pix_colors[Color_topShadow]; |
1123 | gcvalue.foreground = pix_colors[Color_topShadow]; |
1159 | topShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue); |
1124 | topShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue); |
1160 | gcvalue.foreground = pix_colors[Color_bottomShadow]; |
1125 | gcvalue.foreground = pix_colors[Color_bottomShadow]; |
1161 | botShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue); |
1126 | botShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue); |
1162 | gcvalue.foreground = pix_colors[ (display->depth <= 2 ? Color_fg : Color_scroll)]; |
1127 | gcvalue.foreground = pix_colors[ (display->depth <= 2 ? Color_fg : Color_scroll)]; |
… | |
… | |
1193 | /* |
1158 | /* |
1194 | * standard System V termios interface |
1159 | * standard System V termios interface |
1195 | */ |
1160 | */ |
1196 | if (GET_TERMIOS (STDIN_FILENO, tio) < 0) |
1161 | if (GET_TERMIOS (STDIN_FILENO, tio) < 0) |
1197 | { |
1162 | { |
1198 | /* return error - use system defaults */ |
1163 | // return error - use system defaults, |
|
|
1164 | // where possible, and zero elsewhere |
|
|
1165 | memset (tio, 0, sizeof (ttymode_t)); |
|
|
1166 | |
1199 | tio->c_cc[VINTR] = CINTR; |
1167 | tio->c_cc[VINTR] = CINTR; |
1200 | tio->c_cc[VQUIT] = CQUIT; |
1168 | tio->c_cc[VQUIT] = CQUIT; |
1201 | tio->c_cc[VERASE] = CERASE; |
1169 | tio->c_cc[VERASE] = CERASE; |
|
|
1170 | #ifdef VERASE2 |
|
|
1171 | tio->c_cc[VERASE2] = CERASE2; |
|
|
1172 | #endif |
1202 | tio->c_cc[VKILL] = CKILL; |
1173 | tio->c_cc[VKILL] = CKILL; |
1203 | tio->c_cc[VSTART] = CSTART; |
1174 | tio->c_cc[VSTART] = CSTART; |
1204 | tio->c_cc[VSTOP] = CSTOP; |
1175 | tio->c_cc[VSTOP] = CSTOP; |
1205 | tio->c_cc[VSUSP] = CSUSP; |
1176 | tio->c_cc[VSUSP] = CSUSP; |
1206 | # ifdef VDSUSP |
1177 | # ifdef VDSUSP |
… | |
… | |
1400 | { |
1371 | { |
1401 | #if ENABLE_FRILLS |
1372 | #if ENABLE_FRILLS |
1402 | if (rs[Rs_pty_fd]) |
1373 | if (rs[Rs_pty_fd]) |
1403 | { |
1374 | { |
1404 | pty.pty = atoi (rs[Rs_pty_fd]); |
1375 | pty.pty = atoi (rs[Rs_pty_fd]); |
|
|
1376 | |
|
|
1377 | if (pty.pty >= 0) |
|
|
1378 | { |
|
|
1379 | if (getfd_hook) |
|
|
1380 | pty.pty = (*getfd_hook) (pty.pty); |
|
|
1381 | |
1405 | fcntl (pty.pty, F_SETFL, O_NONBLOCK); |
1382 | if (pty.pty < 0 || fcntl (pty.pty, F_SETFL, O_NONBLOCK)) |
|
|
1383 | rxvt_fatal ("unusable pty-fd filehandle, aborting.\n"); |
|
|
1384 | } |
1406 | } |
1385 | } |
1407 | else |
1386 | else |
1408 | #endif |
1387 | #endif |
1409 | if (!pty.get ()) |
1388 | if (!pty.get ()) |
1410 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
1389 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
… | |
… | |
1511 | { |
1490 | { |
1512 | char *login; |
1491 | char *login; |
1513 | |
1492 | |
1514 | SET_TTYMODE (STDIN_FILENO, &tio); /* init terminal attributes */ |
1493 | SET_TTYMODE (STDIN_FILENO, &tio); /* init terminal attributes */ |
1515 | |
1494 | |
1516 | if (options & Opt_console) |
1495 | if (OPTION (Opt_console)) |
1517 | { /* be virtual console, fail silently */ |
1496 | { /* be virtual console, fail silently */ |
1518 | #ifdef TIOCCONS |
1497 | #ifdef TIOCCONS |
1519 | unsigned int on = 1; |
1498 | unsigned int on = 1; |
1520 | |
1499 | |
1521 | ioctl (STDIN_FILENO, TIOCCONS, &on); |
1500 | ioctl (STDIN_FILENO, TIOCCONS, &on); |
… | |
… | |
1564 | execvp (argv[0], (char *const *)argv); |
1543 | execvp (argv[0], (char *const *)argv); |
1565 | /* no error message: STDERR is closed! */ |
1544 | /* no error message: STDERR is closed! */ |
1566 | } |
1545 | } |
1567 | else |
1546 | else |
1568 | { |
1547 | { |
1569 | const char *argv0, *shell; |
1548 | const char *argv0, *shell; |
1570 | |
1549 | |
1571 | if ((shell = getenv ("SHELL")) == NULL || *shell == '\0') |
1550 | if ((shell = getenv ("SHELL")) == NULL || *shell == '\0') |
1572 | shell = "/bin/sh"; |
1551 | shell = "/bin/sh"; |
1573 | |
1552 | |
1574 | argv0 = (const char *)rxvt_r_basename (shell); |
1553 | argv0 = (const char *)rxvt_r_basename (shell); |
1575 | |
1554 | |
1576 | if (options & Opt_loginShell) |
1555 | if (OPTION (Opt_loginShell)) |
1577 | { |
1556 | { |
1578 | login = (char *)rxvt_malloc ((strlen (argv0) + 2) * sizeof (char)); |
1557 | login = (char *)rxvt_malloc ((strlen (argv0) + 2) * sizeof (char)); |
1579 | |
1558 | |
1580 | login[0] = '-'; |
1559 | login[0] = '-'; |
1581 | strcpy (&login[1], argv0); |
1560 | strcpy (&login[1], argv0); |
1582 | argv0 = login; |
1561 | argv0 = login; |
1583 | } |
1562 | } |
|
|
1563 | |
1584 | execlp (shell, argv0, NULL); |
1564 | execlp (shell, argv0, NULL); |
1585 | /* no error message: STDERR is closed! */ |
1565 | /* no error message: STDERR is closed! */ |
1586 | } |
1566 | } |
1587 | |
1567 | |
1588 | #else /* __QNX__ uses qnxspawn () */ |
1568 | #else /* __QNX__ uses qnxspawn () */ |
… | |
… | |
1616 | if ((command = getenv ("SHELL")) == NULL || *command == '\0') |
1596 | if ((command = getenv ("SHELL")) == NULL || *command == '\0') |
1617 | command = "/bin/sh"; |
1597 | command = "/bin/sh"; |
1618 | |
1598 | |
1619 | arg_a[0] = my_basename (command); |
1599 | arg_a[0] = my_basename (command); |
1620 | |
1600 | |
1621 | if (options & Opt_loginShell) |
1601 | if (OPTION (Opt_loginShell)) |
1622 | { |
1602 | { |
1623 | login = rxvt_malloc ((strlen (arg_a[0]) + 2) * sizeof (char)); |
1603 | login = rxvt_malloc ((strlen (arg_a[0]) + 2) * sizeof (char)); |
1624 | |
1604 | |
1625 | login[0] = '-'; |
1605 | login[0] = '-'; |
1626 | strcpy (&login[1], arg_a[0]); |
1606 | strcpy (&login[1], arg_a[0]); |