… | |
… | |
11 | * Copyright (c) 1997 mj olesen <olesen@me.queensu.ca> |
11 | * Copyright (c) 1997 mj olesen <olesen@me.queensu.ca> |
12 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
12 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
13 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
13 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
14 | * - extensive modifications |
14 | * - extensive modifications |
15 | * Copyright (c) 2003-2008 Marc Lehmann <schmorp@schmorp.de> |
15 | * Copyright (c) 2003-2008 Marc Lehmann <schmorp@schmorp.de> |
|
|
16 | * Copyright (c) 2015 Emanuele Giaquinta <e.giaquinta@glauco.it> |
16 | * |
17 | * |
17 | * This program is free software; you can redistribute it and/or modify |
18 | * This program is free software; you can redistribute it and/or modify |
18 | * it under the terms of the GNU General Public License as published by |
19 | * it under the terms of the GNU General Public License as published by |
19 | * the Free Software Foundation; either version 2 of the License, or |
20 | * the Free Software Foundation; either version 3 of the License, or |
20 | * (at your option) any later version. |
21 | * (at your option) any later version. |
21 | * |
22 | * |
22 | * This program is distributed in the hope that it will be useful, |
23 | * This program is distributed in the hope that it will be useful, |
23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
… | |
… | |
38 | #include "init.h" |
39 | #include "init.h" |
39 | #include "keyboard.h" |
40 | #include "keyboard.h" |
40 | |
41 | |
41 | #include <limits> |
42 | #include <limits> |
42 | |
43 | |
43 | #include <csignal> |
44 | #include <signal.h> |
44 | |
45 | |
45 | #include <fcntl.h> |
46 | #include <fcntl.h> |
|
|
47 | |
|
|
48 | #ifdef HAVE_XMU |
|
|
49 | # include <X11/Xmu/CurUtil.h> |
|
|
50 | #endif |
46 | |
51 | |
47 | #ifdef HAVE_XSETLOCALE |
52 | #ifdef HAVE_XSETLOCALE |
48 | # define X_LOCALE |
53 | # define X_LOCALE |
49 | # include <X11/Xlocale.h> |
54 | # include <X11/Xlocale.h> |
50 | #else |
55 | #else |
51 | # ifdef HAVE_SETLOCALE |
|
|
52 | # include <clocale> |
56 | # include <locale.h> |
53 | # endif |
|
|
54 | #endif |
57 | #endif |
55 | |
58 | |
56 | #ifdef HAVE_NL_LANGINFO |
59 | #ifdef HAVE_NL_LANGINFO |
57 | # include <langinfo.h> |
60 | # include <langinfo.h> |
58 | #endif |
61 | #endif |
… | |
… | |
78 | #include <netinet/in.h> |
81 | #include <netinet/in.h> |
79 | #include <arpa/inet.h> |
82 | #include <arpa/inet.h> |
80 | #include <net/if.h> |
83 | #include <net/if.h> |
81 | #include <net/if_arp.h> |
84 | #include <net/if_arp.h> |
82 | |
85 | |
83 | static char * |
86 | static char * ecb_cold |
84 | rxvt_network_display (const char *display) |
87 | rxvt_network_display (const char *display) |
85 | { |
88 | { |
86 | char buffer[1024], *rval = NULL; |
89 | char buffer[1024], *rval = NULL; |
87 | struct ifconf ifc; |
90 | struct ifconf ifc; |
88 | struct ifreq *ifr; |
91 | struct ifreq *ifr; |
… | |
… | |
147 | close (skfd); |
150 | close (skfd); |
148 | |
151 | |
149 | return rval; |
152 | return rval; |
150 | } |
153 | } |
151 | #endif |
154 | #endif |
|
|
155 | |
|
|
156 | #define NULL_5 \ |
|
|
157 | NULL, \ |
|
|
158 | NULL, \ |
|
|
159 | NULL, \ |
|
|
160 | NULL, \ |
|
|
161 | NULL, |
|
|
162 | |
|
|
163 | #define NULL_10 \ |
|
|
164 | NULL_5 \ |
|
|
165 | NULL_5 |
|
|
166 | |
|
|
167 | #define NULL_40 \ |
|
|
168 | NULL_10 \ |
|
|
169 | NULL_10 \ |
|
|
170 | NULL_10 \ |
|
|
171 | NULL_10 |
|
|
172 | |
|
|
173 | #define NULL_50 \ |
|
|
174 | NULL_40 \ |
|
|
175 | NULL_10 |
|
|
176 | |
|
|
177 | #define NULL_100 \ |
|
|
178 | NULL_50 \ |
|
|
179 | NULL_50 |
152 | |
180 | |
153 | static const char *const def_colorName[] = |
181 | static const char *const def_colorName[] = |
154 | { |
182 | { |
155 | COLOR_FOREGROUND, |
183 | COLOR_FOREGROUND, |
156 | COLOR_BACKGROUND, |
184 | COLOR_BACKGROUND, |
… | |
… | |
253 | "rgb:8b/8b/8b", |
281 | "rgb:8b/8b/8b", |
254 | "rgb:a2/a2/a2", |
282 | "rgb:a2/a2/a2", |
255 | "rgb:b9/b9/b9", |
283 | "rgb:b9/b9/b9", |
256 | "rgb:d0/d0/d0", |
284 | "rgb:d0/d0/d0", |
257 | "rgb:e7/e7/e7", |
285 | "rgb:e7/e7/e7", |
|
|
286 | NULL_100 |
|
|
287 | NULL_40 |
|
|
288 | NULL, |
|
|
289 | NULL, |
|
|
290 | NULL, |
|
|
291 | NULL, |
258 | #else |
292 | #else |
259 | // 256 xterm colours |
293 | // 256 xterm colours |
260 | "rgb:00/00/00", |
294 | "rgb:00/00/00", |
261 | "rgb:00/00/5f", |
295 | "rgb:00/00/5f", |
262 | "rgb:00/00/87", |
296 | "rgb:00/00/87", |
… | |
… | |
495 | "rgb:c6/c6/c6", |
529 | "rgb:c6/c6/c6", |
496 | "rgb:d0/d0/d0", |
530 | "rgb:d0/d0/d0", |
497 | "rgb:da/da/da", |
531 | "rgb:da/da/da", |
498 | "rgb:e4/e4/e4", |
532 | "rgb:e4/e4/e4", |
499 | "rgb:ee/ee/ee", |
533 | "rgb:ee/ee/ee", |
|
|
534 | NULL_100 |
|
|
535 | NULL_100 |
|
|
536 | NULL_40 |
|
|
537 | NULL_5 |
500 | #endif |
538 | #endif |
501 | |
539 | |
502 | #ifndef NO_CURSORCOLOR |
540 | #ifndef NO_CURSORCOLOR |
503 | COLOR_CURSOR_BACKGROUND, |
541 | COLOR_CURSOR_BACKGROUND, |
504 | COLOR_CURSOR_FOREGROUND, |
542 | COLOR_CURSOR_FOREGROUND, |
… | |
… | |
521 | #endif |
559 | #endif |
522 | COLOR_SCROLLBAR, |
560 | COLOR_SCROLLBAR, |
523 | #ifdef RXVT_SCROLLBAR |
561 | #ifdef RXVT_SCROLLBAR |
524 | COLOR_SCROLLTROUGH, |
562 | COLOR_SCROLLTROUGH, |
525 | #endif |
563 | #endif |
526 | #if ENABLE_TRANSPARENCY |
|
|
527 | NULL, |
|
|
528 | #endif |
|
|
529 | #if OFF_FOCUS_FADING |
564 | #if OFF_FOCUS_FADING |
530 | "rgb:00/00/00", |
565 | "rgb:00/00/00", |
531 | #endif |
566 | #endif |
532 | }; |
567 | }; |
533 | |
568 | |
… | |
… | |
563 | set_option (Opt_iso14755); |
598 | set_option (Opt_iso14755); |
564 | set_option (Opt_iso14755_52); |
599 | set_option (Opt_iso14755_52); |
565 | set_option (Opt_buffered); |
600 | set_option (Opt_buffered); |
566 | } |
601 | } |
567 | |
602 | |
|
|
603 | #if ENABLE_PERL |
|
|
604 | static void |
|
|
605 | rxvt_perl_parse_resource (rxvt_term *term, const char *k, const char *v) |
|
|
606 | { |
|
|
607 | rxvt_perl.parse_resource (term, k, false, false, 0, v); |
|
|
608 | } |
|
|
609 | #endif |
|
|
610 | |
568 | /*----------------------------------------------------------------------*/ |
611 | /*----------------------------------------------------------------------*/ |
569 | const char ** |
612 | const char ** |
570 | rxvt_term::init_resources (int argc, const char *const *argv) |
613 | rxvt_term::init_resources (int argc, const char *const *argv) |
571 | { |
614 | { |
572 | int i, r_argc; |
615 | int i; |
573 | const char **cmd_argv, **r_argv; |
616 | 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 | { |
|
|
588 | cmd_argv = (const char **)rxvt_malloc (sizeof (char *) * (argc - r_argc)); |
|
|
589 | |
|
|
590 | for (i = 0; i < argc - r_argc - 1; i++) |
|
|
591 | cmd_argv[i] = (const char *)argv[i + r_argc + 1]; |
|
|
592 | |
|
|
593 | cmd_argv[i] = NULL; |
|
|
594 | } |
|
|
595 | |
|
|
596 | r_argv = (const char **)rxvt_malloc (sizeof (char *) * (r_argc + 1)); |
|
|
597 | |
|
|
598 | for (i = 0; i < r_argc; i++) |
|
|
599 | r_argv[i] = (const char *)argv[i]; |
|
|
600 | |
|
|
601 | r_argv[i] = NULL; |
|
|
602 | |
617 | |
603 | rs[Rs_name] = rxvt_basename (argv[0]); |
618 | rs[Rs_name] = rxvt_basename (argv[0]); |
604 | |
619 | |
605 | /* |
620 | /* |
606 | * Open display, get options/resources and create the window |
621 | * Open display, get options/resources and create the window |
607 | */ |
622 | */ |
608 | |
623 | |
609 | if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL) |
624 | if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL) |
610 | rs[Rs_display_name] = ":0"; |
625 | rs[Rs_display_name] = ":0"; |
611 | |
626 | |
612 | get_options (r_argc, r_argv); |
627 | cmd_argv = get_options (argc, argv); |
613 | |
628 | |
614 | if (!(display = displays.get (rs[Rs_display_name]))) |
629 | if (!(display = displays.get (rs[Rs_display_name]))) |
615 | rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]); |
630 | rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]); |
616 | |
631 | |
617 | // using a local pointer decreases code size a lot |
632 | // using a local pointer decreases code size a lot |
618 | xa = display->xa; |
633 | xa = display->xa; |
619 | |
634 | |
620 | set (display); |
635 | set (display); |
621 | extract_resources (); |
636 | extract_resources (); |
622 | |
637 | |
623 | #if XFT |
638 | #if ENABLE_FRILLS |
624 | if (rs[Rs_depth]) |
639 | if (rs[Rs_visual]) |
625 | select_visual (strtol (rs[Rs_depth], 0, 0)); |
640 | select_visual (strtol (rs[Rs_visual], 0, 0)); |
|
|
641 | else if (rs[Rs_depth]) |
|
|
642 | select_depth (strtol (rs[Rs_depth], 0, 0)); |
626 | #endif |
643 | #endif |
627 | |
|
|
628 | free (r_argv); |
|
|
629 | |
644 | |
630 | for (int i = NUM_RESOURCES; i--; ) |
645 | for (int i = NUM_RESOURCES; i--; ) |
631 | if (rs [i] == resval_undef) |
646 | if (rs [i] == resval_undef) |
632 | rs [i] = 0; |
647 | rs [i] = 0; |
633 | |
648 | |
… | |
… | |
638 | if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) |
653 | if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) |
639 | || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2]) |
654 | || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2]) |
640 | || (rs[Rs_perl_eval] && *rs[Rs_perl_eval])) |
655 | || (rs[Rs_perl_eval] && *rs[Rs_perl_eval])) |
641 | { |
656 | { |
642 | rxvt_perl.init (this); |
657 | rxvt_perl.init (this); |
|
|
658 | enumerate_resources (rxvt_perl_parse_resource); |
643 | HOOK_INVOKE ((this, HOOK_INIT, DT_END)); |
659 | HOOK_INVOKE ((this, HOOK_INIT, DT_END)); |
644 | } |
660 | } |
645 | #endif |
661 | #endif |
646 | |
662 | |
647 | // must be called after initialising the perl interpreter as it |
663 | // must be called after initialising the perl interpreter as it |
… | |
… | |
679 | ext_bwidth = min (i, std::numeric_limits<int16_t>::max ()); |
695 | ext_bwidth = min (i, std::numeric_limits<int16_t>::max ()); |
680 | |
696 | |
681 | if (rs[Rs_lineSpace] && (i = atoi (rs[Rs_lineSpace])) >= 0) |
697 | if (rs[Rs_lineSpace] && (i = atoi (rs[Rs_lineSpace])) >= 0) |
682 | lineSpace = min (i, std::numeric_limits<int16_t>::max ()); |
698 | lineSpace = min (i, std::numeric_limits<int16_t>::max ()); |
683 | |
699 | |
684 | if (rs[Rs_letterSpace]) |
700 | if (const char *v = rs[Rs_letterSpace]) |
685 | letterSpace = atoi (rs[Rs_letterSpace]); |
701 | letterSpace = atoi (v); |
|
|
702 | |
|
|
703 | rewrap_always = rewrap_never = 0; |
|
|
704 | if (const char *v = rs[Rs_rewrapMode]) |
|
|
705 | if (!strcmp (v, "never")) |
|
|
706 | rewrap_never = 1; |
|
|
707 | else if (!strcmp (v, "always")) |
|
|
708 | rewrap_always = 1; |
|
|
709 | else if (!strcmp (v, "auto")) |
|
|
710 | /* nop **/; |
|
|
711 | else |
|
|
712 | rxvt_warn ("invalid rewrapMode, must be auto, always or never.\n"); |
686 | #endif |
713 | #endif |
687 | |
714 | |
688 | #ifdef POINTER_BLANK |
715 | #ifdef POINTER_BLANK |
689 | if (rs[Rs_pointerBlankDelay] && (i = atoi (rs[Rs_pointerBlankDelay])) >= 0) |
716 | if (rs[Rs_pointerBlankDelay] && (i = atoi (rs[Rs_pointerBlankDelay])) >= 0) |
690 | pointerBlankDelay = i; |
717 | pointerBlankDelay = i; |
691 | else |
718 | else |
692 | pointerBlankDelay = 2; |
719 | pointerBlankDelay = 2; |
693 | #endif |
720 | #endif |
|
|
721 | |
|
|
722 | if (rs[Rs_multiClickTime] && (i = atoi (rs[Rs_multiClickTime])) >= 0) |
|
|
723 | multiClickTime = i; |
|
|
724 | else |
|
|
725 | multiClickTime = 500; |
|
|
726 | |
|
|
727 | cursor_type = option (Opt_cursorUnderline) ? 1 : 0; |
694 | |
728 | |
695 | /* no point having a scrollbar without having any scrollback! */ |
729 | /* no point having a scrollbar without having any scrollback! */ |
696 | if (!saveLines) |
730 | if (!saveLines) |
697 | set_option (Opt_scrollBar, 0); |
731 | set_option (Opt_scrollBar, 0); |
698 | |
732 | |
… | |
… | |
763 | return cmd_argv; |
797 | return cmd_argv; |
764 | } |
798 | } |
765 | |
799 | |
766 | /*----------------------------------------------------------------------*/ |
800 | /*----------------------------------------------------------------------*/ |
767 | void |
801 | void |
768 | rxvt_term::init (int argc, const char *const *argv, stringvec *envv) |
802 | rxvt_term::init (stringvec *argv, stringvec *envv) |
769 | { |
803 | { |
|
|
804 | argv->push_back (0); |
|
|
805 | envv->push_back (0); |
|
|
806 | |
|
|
807 | this->argv = argv; |
770 | this->envv = envv; |
808 | this->envv = envv; |
771 | |
809 | |
|
|
810 | env = new char *[this->envv->size ()]; |
|
|
811 | for (int i = 0; i < this->envv->size (); i++) |
|
|
812 | env[i] = this->envv->at (i); |
|
|
813 | |
|
|
814 | init2 (argv->size () - 1, argv->begin ()); |
|
|
815 | } |
|
|
816 | |
|
|
817 | void |
|
|
818 | rxvt_term::init (int argc, const char *const *argv, const char *const *envv) |
|
|
819 | { |
|
|
820 | #if ENABLE_PERL |
|
|
821 | // perl might want to access the stringvecs later, so we need to copy them |
|
|
822 | stringvec *args = new stringvec; |
|
|
823 | for (int i = 0; i < argc; i++) |
|
|
824 | args->push_back (strdup (argv [i])); |
|
|
825 | |
|
|
826 | stringvec *envs = new stringvec; |
|
|
827 | for (const char *const *var = envv; *var; var++) |
|
|
828 | envs->push_back (strdup (*var)); |
|
|
829 | |
|
|
830 | init (args, envs); |
|
|
831 | #else |
|
|
832 | init2 (argc, argv); |
|
|
833 | #endif |
|
|
834 | } |
|
|
835 | |
|
|
836 | void |
|
|
837 | rxvt_term::init2 (int argc, const char *const *argv) |
|
|
838 | { |
772 | SET_R (this); |
839 | SET_R (this); |
773 | set_locale (""); |
840 | set_locale (""); |
774 | set_environ (envv); // a few things in X do not call setlocale :( |
841 | set_environ (env); // a few things in X do not call setlocale :( |
775 | |
842 | |
776 | init_vars (); |
843 | init_vars (); |
777 | |
844 | |
778 | const char **cmd_argv = init_resources (argc, argv); |
845 | const char **cmd_argv = init_resources (argc, argv); |
779 | |
846 | |
780 | #ifdef KEYSYM_RESOURCE |
847 | #ifdef KEYSYM_RESOURCE |
781 | keyboard->register_done (); |
848 | keyboard->register_done (); |
782 | #endif |
849 | #endif |
|
|
850 | |
|
|
851 | { |
|
|
852 | ev_tstamp interval = 1. / 60.; |
|
|
853 | |
|
|
854 | #if ENABLE_FRILLS |
|
|
855 | if (rs[Rs_refreshRate]) |
|
|
856 | { |
|
|
857 | interval = atof (rs[Rs_refreshRate]); |
|
|
858 | if (interval <= 0.) |
|
|
859 | interval = -interval; |
|
|
860 | else |
|
|
861 | interval = 1. / interval; |
|
|
862 | } |
|
|
863 | #endif |
|
|
864 | |
|
|
865 | flush_ev.set (interval, interval); |
|
|
866 | } |
783 | |
867 | |
784 | if (const char *path = rs[Rs_chdir]) |
868 | if (const char *path = rs[Rs_chdir]) |
785 | if (*path) // ignored if empty |
869 | if (*path) // ignored if empty |
786 | { |
870 | { |
787 | if (*path != '/') |
871 | if (*path != '/') |
… | |
… | |
794 | if (option (Opt_scrollBar)) |
878 | if (option (Opt_scrollBar)) |
795 | scrollBar.state = SB_STATE_IDLE; /* set existence for size calculations */ |
879 | scrollBar.state = SB_STATE_IDLE; /* set existence for size calculations */ |
796 | |
880 | |
797 | pty = ptytty::create (); |
881 | pty = ptytty::create (); |
798 | |
882 | |
799 | #ifdef HAVE_AFTERIMAGE |
|
|
800 | set_application_name ((char *)rs[Rs_name]); |
|
|
801 | set_output_threshold (OUTPUT_LEVEL_WARNING); |
|
|
802 | #endif |
|
|
803 | |
|
|
804 | // must be called before create_windows, because the latter may call set_icon |
|
|
805 | #ifdef HAVE_PIXBUF |
|
|
806 | g_type_init (); |
|
|
807 | #endif |
|
|
808 | |
|
|
809 | create_windows (argc, argv); |
883 | create_windows (argc, argv); |
810 | |
884 | |
811 | init_xlocale (); |
885 | init_xlocale (); |
812 | |
886 | |
813 | scr_poweron (); // initialize screen |
887 | scr_poweron (); // initialize screen |
… | |
… | |
816 | XSynchronize (dpy, True); |
890 | XSynchronize (dpy, True); |
817 | #endif |
891 | #endif |
818 | |
892 | |
819 | if (option (Opt_scrollBar)) |
893 | if (option (Opt_scrollBar)) |
820 | scrollBar.resize (); /* create and map scrollbar */ |
894 | scrollBar.resize (); /* create and map scrollbar */ |
821 | #ifdef HAVE_BG_PIXMAP |
|
|
822 | { |
|
|
823 | bg_init (); |
|
|
824 | |
|
|
825 | #ifdef ENABLE_TRANSPARENCY |
|
|
826 | if (option (Opt_transparent)) |
|
|
827 | { |
|
|
828 | bg_set_transparent (); |
|
|
829 | |
|
|
830 | if (rs [Rs_blurradius]) |
|
|
831 | bg_set_blur (rs [Rs_blurradius]); |
|
|
832 | |
|
|
833 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
834 | bg_set_tint (pix_colors_focused [Color_tint]); |
|
|
835 | |
|
|
836 | if (rs [Rs_shade]) |
|
|
837 | bg_set_shade (rs [Rs_shade]); |
|
|
838 | |
|
|
839 | bg_set_root_pixmap (); |
|
|
840 | XSelectInput (dpy, display->root, PropertyChangeMask); |
|
|
841 | rootwin_ev.start (display, display->root); |
|
|
842 | } |
|
|
843 | #endif |
|
|
844 | |
|
|
845 | #ifdef BG_IMAGE_FROM_FILE |
|
|
846 | if (rs[Rs_backgroundPixmap]) |
|
|
847 | { |
|
|
848 | if (bg_set_file (rs[Rs_backgroundPixmap])) |
|
|
849 | if (!bg_window_position_sensitive ()) |
|
|
850 | update_background (); |
|
|
851 | } |
|
|
852 | #endif |
|
|
853 | } |
|
|
854 | #endif |
|
|
855 | |
895 | |
856 | #if ENABLE_PERL |
896 | #if ENABLE_PERL |
857 | rootwin_ev.start (display, display->root); |
897 | rootwin_ev.start (display, display->root); |
858 | #endif |
898 | #endif |
859 | |
899 | |
860 | set_colorfgbg (); |
900 | init_done = 1; |
861 | |
901 | |
862 | init_command (cmd_argv); |
902 | init_command (cmd_argv); |
863 | |
|
|
864 | free (cmd_argv); |
|
|
865 | |
903 | |
866 | if (pty->pty >= 0) |
904 | if (pty->pty >= 0) |
867 | pty_ev.start (pty->pty, ev::READ); |
905 | pty_ev.start (pty->pty, ev::READ); |
868 | |
906 | |
869 | HOOK_INVOKE ((this, HOOK_START, DT_END)); |
907 | HOOK_INVOKE ((this, HOOK_START, DT_END)); |
… | |
… | |
911 | /*----------------------------------------------------------------------*/ |
949 | /*----------------------------------------------------------------------*/ |
912 | void |
950 | void |
913 | rxvt_term::init_env () |
951 | rxvt_term::init_env () |
914 | { |
952 | { |
915 | char *val; |
953 | char *val; |
|
|
954 | char *env_display; |
|
|
955 | char *env_windowid; |
|
|
956 | char *env_colorfgbg; |
|
|
957 | char *env_term; |
916 | |
958 | |
917 | #ifdef DISPLAY_IS_IP |
959 | #ifdef DISPLAY_IS_IP |
918 | /* Fixup display_name for export over pty to any interested terminal |
960 | /* Fixup display_name for export over pty to any interested terminal |
919 | * clients via "ESC[7n" (e.g. shells). Note we use the pure IP number |
961 | * clients via "ESC[7n" (e.g. shells). Note we use the pure IP number |
920 | * (for the first non-loopback interface) that we get from |
962 | * (for the first non-loopback interface) that we get from |
… | |
… | |
937 | |
979 | |
938 | env_display = (char *)rxvt_malloc (strlen (val) + 9); |
980 | env_display = (char *)rxvt_malloc (strlen (val) + 9); |
939 | |
981 | |
940 | sprintf (env_display, "DISPLAY=%s", val); |
982 | sprintf (env_display, "DISPLAY=%s", val); |
941 | |
983 | |
|
|
984 | env_windowid = (char *)rxvt_malloc (21); |
942 | sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent); |
985 | sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent); |
943 | |
986 | |
944 | /* add entries to the environment: |
987 | /* add entries to the environment: |
945 | * @ DISPLAY: in case we started with -display |
988 | * @ DISPLAY: in case we started with -display |
946 | * @ WINDOWID: X window id number of the window |
989 | * @ WINDOWID: X window id number of the window |
… | |
… | |
950 | * @ COLORFGBG: fg;bg color codes |
993 | * @ COLORFGBG: fg;bg color codes |
951 | */ |
994 | */ |
952 | putenv (env_display); |
995 | putenv (env_display); |
953 | putenv (env_windowid); |
996 | putenv (env_windowid); |
954 | |
997 | |
955 | if (env_colorfgbg) |
998 | env_colorfgbg = get_colorfgbg (); |
956 | putenv (env_colorfgbg); |
999 | putenv (env_colorfgbg); |
957 | |
1000 | |
958 | #ifdef RXVT_TERMINFO |
1001 | #ifdef RXVT_TERMINFO |
959 | putenv ("TERMINFO=" RXVT_TERMINFO); |
1002 | putenv ("TERMINFO=" RXVT_TERMINFO); |
960 | #endif |
1003 | #endif |
961 | |
1004 | |
962 | if (depth <= 2) |
1005 | if (depth <= 2) |
963 | putenv ("COLORTERM=" COLORTERMENV "-mono"); |
1006 | putenv ((char *)"COLORTERM=" COLORTERMENV "-mono"); |
964 | else |
1007 | else |
965 | putenv ("COLORTERM=" COLORTERMENVFULL); |
1008 | putenv ((char *)"COLORTERM=" COLORTERMENVFULL); |
966 | |
1009 | |
967 | if (rs[Rs_term_name] != NULL) |
1010 | if (rs[Rs_term_name] != NULL) |
968 | { |
1011 | { |
969 | env_term = (char *)rxvt_malloc (strlen (rs[Rs_term_name]) + 6); |
1012 | env_term = (char *)rxvt_malloc (strlen (rs[Rs_term_name]) + 6); |
970 | sprintf (env_term, "TERM=%s", rs[Rs_term_name]); |
1013 | sprintf (env_term, "TERM=%s", rs[Rs_term_name]); |
971 | putenv (env_term); |
1014 | putenv (env_term); |
972 | } |
1015 | } |
973 | else |
1016 | else |
974 | putenv ("TERM=" TERMENV); |
1017 | putenv ((char *)"TERM=" TERMENV); |
975 | |
1018 | |
976 | #ifdef HAVE_UNSETENV |
1019 | #ifdef HAVE_UNSETENV |
977 | /* avoid passing old settings and confusing term size */ |
1020 | /* avoid passing old settings and confusing term size */ |
978 | unsetenv ("LINES"); |
1021 | unsetenv ("LINES"); |
979 | unsetenv ("COLUMNS"); |
1022 | unsetenv ("COLUMNS"); |
980 | unsetenv ("TERMCAP"); /* terminfo should be okay */ |
1023 | unsetenv ("TERMCAP"); /* terminfo should be okay */ |
981 | #endif /* HAVE_UNSETENV */ |
1024 | #endif /* HAVE_UNSETENV */ |
982 | } |
1025 | } |
983 | |
1026 | |
984 | /*----------------------------------------------------------------------*/ |
1027 | /*----------------------------------------------------------------------*/ |
985 | /* |
|
|
986 | * This is more or less stolen straight from XFree86 xterm. |
|
|
987 | * This should support all European type languages. |
|
|
988 | */ |
|
|
989 | void |
1028 | void |
990 | rxvt_term::set_locale (const char *locale) |
1029 | rxvt_term::set_locale (const char *locale) |
991 | { |
1030 | { |
992 | set_environ (envv); |
1031 | set_environ (env); |
993 | |
1032 | |
994 | #if HAVE_XSETLOCALE || HAVE_SETLOCALE |
|
|
995 | free (this->locale); |
1033 | free (this->locale); |
996 | this->locale = setlocale (LC_CTYPE, locale); |
1034 | this->locale = setlocale (LC_CTYPE, locale); |
997 | |
1035 | |
998 | if (!this->locale) |
1036 | if (!this->locale) |
999 | { |
1037 | { |
… | |
… | |
1003 | setlocale (LC_CTYPE, "C"); |
1041 | setlocale (LC_CTYPE, "C"); |
1004 | } |
1042 | } |
1005 | else |
1043 | else |
1006 | rxvt_warn ("default locale unavailable, check LC_* and LANG variables. Continuing.\n"); |
1044 | rxvt_warn ("default locale unavailable, check LC_* and LANG variables. Continuing.\n"); |
1007 | |
1045 | |
1008 | this->locale = "C"; |
1046 | this->locale = (char *)"C"; /* strdup'ed below */ |
1009 | } |
1047 | } |
1010 | |
1048 | |
1011 | |
1049 | |
1012 | this->locale = strdup (this->locale); |
1050 | this->locale = strdup (this->locale); |
1013 | SET_LOCALE (this->locale); |
1051 | SET_LOCALE (this->locale); |
1014 | mbstate.reset (); |
1052 | mbstate.reset (); |
1015 | #endif |
|
|
1016 | |
1053 | |
1017 | #if HAVE_NL_LANGINFO |
1054 | #if HAVE_NL_LANGINFO |
1018 | char *codeset = strdup (nl_langinfo (CODESET)); |
1055 | char *codeset = nl_langinfo (CODESET); |
1019 | // /^UTF.?8/i |
1056 | // /^UTF.?8/i |
1020 | enc_utf8 = (codeset[0] == 'U' || codeset[0] == 'u') |
1057 | enc_utf8 = (codeset[0] == 'U' || codeset[0] == 'u') |
1021 | && (codeset[1] == 'T' || codeset[1] == 't') |
1058 | && (codeset[1] == 'T' || codeset[1] == 't') |
1022 | && (codeset[2] == 'F' || codeset[2] == 'f') |
1059 | && (codeset[2] == 'F' || codeset[2] == 'f') |
1023 | && (codeset[3] == '8' || codeset[4] == '8'); |
1060 | && (codeset[3] == '8' || codeset[4] == '8'); |
1024 | free (codeset); |
|
|
1025 | #else |
1061 | #else |
1026 | enc_utf8 = 0; |
1062 | enc_utf8 = 0; |
1027 | #endif |
1063 | #endif |
1028 | } |
1064 | } |
1029 | |
1065 | |
1030 | void |
1066 | void |
1031 | rxvt_term::init_xlocale () |
1067 | rxvt_term::init_xlocale () |
1032 | { |
1068 | { |
1033 | set_environ (envv); |
1069 | set_environ (env); |
1034 | |
1070 | |
1035 | #ifdef USE_XIM |
1071 | #if USE_XIM |
1036 | if (!locale) |
1072 | if (!locale) |
1037 | rxvt_warn ("setting locale failed, working without locale support.\n"); |
1073 | rxvt_warn ("setting locale failed, continuing without locale support.\n"); |
1038 | else |
1074 | else |
1039 | { |
1075 | { |
1040 | set_string_property (xa[XA_WM_LOCALE_NAME], locale); |
1076 | set_string_property (xa[XA_WM_LOCALE_NAME], locale); |
1041 | |
1077 | |
1042 | if (!XSupportsLocale ()) |
1078 | if (!XSupportsLocale ()) |
1043 | { |
1079 | { |
1044 | rxvt_warn ("the locale is not supported by Xlib, working without locale support.\n"); |
1080 | rxvt_warn ("the locale is not supported by Xlib, continuing without locale support.\n"); |
1045 | return; |
1081 | return; |
1046 | } |
1082 | } |
1047 | |
1083 | |
1048 | im_ev.start (display); |
1084 | im_ev.start (display); |
1049 | |
1085 | |
… | |
… | |
1090 | run_command (argv); |
1126 | run_command (argv); |
1091 | } |
1127 | } |
1092 | |
1128 | |
1093 | /*----------------------------------------------------------------------*/ |
1129 | /*----------------------------------------------------------------------*/ |
1094 | void |
1130 | void |
1095 | rxvt_term::get_colours () |
1131 | rxvt_term::get_colors () |
1096 | { |
1132 | { |
1097 | int i; |
1133 | int i; |
1098 | |
1134 | |
1099 | #ifdef OFF_FOCUS_FADING |
1135 | #ifdef OFF_FOCUS_FADING |
1100 | pix_colors = pix_colors_focused; |
1136 | pix_colors = pix_colors_focused; |
1101 | #endif |
1137 | #endif |
1102 | |
1138 | |
1103 | for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) |
1139 | for (i = 0; i < NRS_COLORS; i++) |
1104 | { |
|
|
1105 | const char *name = rs[Rs_color + i]; |
1140 | if (const char *name = rs[Rs_color + i]) |
1106 | |
|
|
1107 | if (!name) |
|
|
1108 | continue; |
|
|
1109 | |
|
|
1110 | rxvt_color xcol; |
|
|
1111 | |
|
|
1112 | if (!set_color (xcol, name)) |
1141 | set_color (pix_colors [i], name); |
1113 | { |
|
|
1114 | #ifndef XTERM_REVERSE_VIDEO |
|
|
1115 | if (i < 2 && option (Opt_reverseVideo)) |
|
|
1116 | name = def_colorName [1 - i]; |
|
|
1117 | else |
|
|
1118 | #endif |
|
|
1119 | name = def_colorName [i]; |
|
|
1120 | |
|
|
1121 | if (!name) |
|
|
1122 | continue; |
|
|
1123 | |
|
|
1124 | if (!set_color (xcol, name)) |
|
|
1125 | { |
|
|
1126 | switch (i) |
|
|
1127 | { |
|
|
1128 | case Color_fg: |
|
|
1129 | case Color_bg: |
|
|
1130 | rxvt_warn ("unable to get foreground/background colour, continuing.\n"); |
|
|
1131 | name = ""; |
|
|
1132 | break; |
|
|
1133 | #ifndef NO_CURSORCOLOR |
|
|
1134 | case Color_cursor2: |
|
|
1135 | #endif |
|
|
1136 | case Color_pointer_fg: |
|
|
1137 | name = rs[Rs_color + Color_fg]; |
|
|
1138 | xcol.set (this, name); |
|
|
1139 | break; |
|
|
1140 | default: |
|
|
1141 | name = rs[Rs_color + Color_bg]; |
|
|
1142 | xcol.set (this, name); |
|
|
1143 | break; |
|
|
1144 | } |
|
|
1145 | } |
|
|
1146 | } |
|
|
1147 | |
|
|
1148 | pix_colors[i] = xcol; |
|
|
1149 | rs[Rs_color + i] = name; |
|
|
1150 | } |
|
|
1151 | |
|
|
1152 | if (depth <= 2) |
|
|
1153 | { |
|
|
1154 | if (!rs[Rs_color + Color_pointer_fg]) alias_color (Color_pointer_fg, Color_fg); |
|
|
1155 | if (!rs[Rs_color + Color_pointer_bg]) alias_color (Color_pointer_bg, Color_bg); |
|
|
1156 | if (!rs[Rs_color + Color_border] ) alias_color (Color_border, Color_fg); |
|
|
1157 | } |
|
|
1158 | |
1142 | |
1159 | /* |
1143 | /* |
1160 | * get scrollBar shadow colors |
1144 | * get scrollBar shadow colors |
1161 | * |
1145 | * |
1162 | * The calculations of topShadow/bottomShadow values are adapted |
1146 | * The calculations of topShadow/bottomShadow values are adapted |
1163 | * from the fvwm window manager. |
1147 | * from the fvwm window manager. |
1164 | */ |
1148 | */ |
1165 | #ifdef RXVT_SCROLLBAR |
1149 | #ifdef RXVT_SCROLLBAR |
1166 | if (depth <= 2) |
|
|
1167 | { |
|
|
1168 | /* Monochrome */ |
|
|
1169 | alias_color (Color_scroll, Color_fg); |
|
|
1170 | alias_color (Color_topShadow, Color_bg); |
|
|
1171 | alias_color (Color_bottomShadow, Color_bg); |
|
|
1172 | } |
|
|
1173 | else |
|
|
1174 | { |
|
|
1175 | pix_colors [Color_scroll].fade (this, 50, pix_colors [Color_bottomShadow]); |
1150 | pix_colors [Color_scroll].fade (this, 50, pix_colors [Color_bottomShadow]); |
1176 | |
1151 | |
1177 | rgba cscroll; |
1152 | rgba cscroll; |
1178 | pix_colors [Color_scroll].get (cscroll); |
1153 | pix_colors [Color_scroll].get (cscroll); |
1179 | |
1154 | |
1180 | /* topShadowColor */ |
1155 | /* topShadowColor */ |
1181 | if (!pix_colors[Color_topShadow].set (this, |
1156 | if (!pix_colors[Color_topShadow].set (this, |
1182 | rgba ( |
1157 | rgba ( |
1183 | min ((int)rgba::MAX_CC, max (cscroll.r / 5, cscroll.r) * 7 / 5), |
1158 | min ((int)rgba::MAX_CC, max (cscroll.r / 5, cscroll.r) * 7 / 5), |
1184 | min ((int)rgba::MAX_CC, max (cscroll.g / 5, cscroll.g) * 7 / 5), |
1159 | min ((int)rgba::MAX_CC, max (cscroll.g / 5, cscroll.g) * 7 / 5), |
1185 | min ((int)rgba::MAX_CC, max (cscroll.b / 5, cscroll.b) * 7 / 5), |
1160 | min ((int)rgba::MAX_CC, max (cscroll.b / 5, cscroll.b) * 7 / 5), |
1186 | cscroll.a) |
1161 | cscroll.a) |
1187 | )) |
1162 | )) |
1188 | alias_color (Color_topShadow, Color_White); |
1163 | alias_color (Color_topShadow, Color_White); |
1189 | } |
|
|
1190 | #endif |
1164 | #endif |
1191 | |
1165 | |
1192 | #ifdef OFF_FOCUS_FADING |
1166 | #ifdef OFF_FOCUS_FADING |
1193 | for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) |
1167 | for (i = 0; i < NRS_COLORS; i++) |
1194 | update_fade_color (i); |
1168 | update_fade_color (i, true); |
1195 | #endif |
1169 | #endif |
1196 | } |
1170 | } |
1197 | |
1171 | |
1198 | /*----------------------------------------------------------------------*/ |
1172 | /*----------------------------------------------------------------------*/ |
1199 | /* color aliases, fg/bg bright-bold */ |
1173 | /* color aliases, fg/bg bright-bold */ |
1200 | void |
1174 | void |
1201 | rxvt_term::color_aliases (int idx) |
1175 | rxvt_term::color_aliases (int idx) |
1202 | { |
1176 | { |
1203 | if (rs[Rs_color + idx] && isdigit (* (rs[Rs_color + idx]))) |
1177 | if (rs[Rs_color + idx] && isdigit (*rs[Rs_color + idx])) |
1204 | { |
1178 | { |
1205 | int i = atoi (rs[Rs_color + idx]); |
1179 | int i = atoi (rs[Rs_color + idx]); |
1206 | |
1180 | |
1207 | if (i >= 8 && i <= 15) |
1181 | if (i >= 8 && i <= 15) |
1208 | /* bright colors */ |
1182 | /* bright colors */ |
… | |
… | |
1248 | for (j = map->max_keypermod; j--; k++) |
1222 | for (j = map->max_keypermod; j--; k++) |
1249 | { |
1223 | { |
1250 | if (kc[k] == 0) |
1224 | if (kc[k] == 0) |
1251 | break; |
1225 | break; |
1252 | |
1226 | |
1253 | switch (XKeycodeToKeysym (dpy, kc[k], 0)) |
1227 | switch (rxvt_XKeycodeToKeysym (dpy, kc[k], 0)) |
1254 | { |
1228 | { |
1255 | case XK_Num_Lock: |
1229 | case XK_Num_Lock: |
1256 | ModNumLockMask = modmasks[i - 1]; |
1230 | ModNumLockMask = modmasks[i - 1]; |
1257 | continue; |
1231 | continue; |
1258 | |
1232 | |
… | |
… | |
1303 | } |
1277 | } |
1304 | |
1278 | |
1305 | void |
1279 | void |
1306 | rxvt_term::set_icon (const char *file) |
1280 | rxvt_term::set_icon (const char *file) |
1307 | { |
1281 | { |
1308 | #ifdef HAVE_AFTERIMAGE |
1282 | #if HAVE_PIXBUF && ENABLE_EWMH |
1309 | init_asv (); |
|
|
1310 | |
|
|
1311 | ASImage *im = file2ASImage (file, 0xFFFFFFFF, SCREEN_GAMMA, 0, NULL); |
|
|
1312 | if (!im) |
|
|
1313 | { |
|
|
1314 | rxvt_warn ("Loading image icon failed, continuing without.\n"); |
|
|
1315 | return; |
|
|
1316 | } |
|
|
1317 | |
|
|
1318 | unsigned int w = im->width; |
|
|
1319 | unsigned int h = im->height; |
|
|
1320 | |
|
|
1321 | if (!IN_RANGE_INC (w, 1, 16383) || !IN_RANGE_INC (h, 1, 16383)) |
|
|
1322 | { |
|
|
1323 | rxvt_warn ("Icon image too big, continuing without.\n"); |
|
|
1324 | destroy_asimage (&im); |
|
|
1325 | return; |
|
|
1326 | } |
|
|
1327 | |
|
|
1328 | ASImage *result = scale_asimage (asv, im, |
|
|
1329 | w, h, ASA_ARGB32, |
|
|
1330 | 100, ASIMAGE_QUALITY_DEFAULT); |
|
|
1331 | destroy_asimage (&im); |
|
|
1332 | |
|
|
1333 | if (!result) |
|
|
1334 | { |
|
|
1335 | rxvt_warn ("Icon image transformation to ARGB failed, continuing without.\n"); |
|
|
1336 | return; |
|
|
1337 | } |
|
|
1338 | |
|
|
1339 | long *buffer = (long *)malloc ((2 + w * h) * sizeof (long)); |
|
|
1340 | if (buffer) |
|
|
1341 | { |
|
|
1342 | ARGB32 *asbuf = result->alt.argb32; |
|
|
1343 | buffer [0] = w; |
|
|
1344 | buffer [1] = h; |
|
|
1345 | |
|
|
1346 | for (unsigned int i = 0; i < w * h; ++i) |
|
|
1347 | buffer [i + 2] = asbuf [i]; |
|
|
1348 | |
|
|
1349 | XChangeProperty (dpy, parent, xa[XA_NET_WM_ICON], XA_CARDINAL, 32, |
|
|
1350 | PropModeReplace, (const unsigned char *) buffer, 2 + w * h); |
|
|
1351 | free (buffer); |
|
|
1352 | } |
|
|
1353 | else |
|
|
1354 | rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); |
|
|
1355 | |
|
|
1356 | destroy_asimage (&result); |
|
|
1357 | #endif |
|
|
1358 | |
|
|
1359 | #ifdef HAVE_PIXBUF |
|
|
1360 | GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (file, NULL); |
1283 | GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (file, NULL); |
1361 | if (!pixbuf) |
1284 | if (!pixbuf) |
1362 | { |
1285 | { |
1363 | rxvt_warn ("Loading image icon failed, continuing without.\n"); |
1286 | rxvt_warn ("Loading image icon failed, continuing without.\n"); |
1364 | return; |
1287 | return; |
… | |
… | |
1429 | Window top, parent; |
1352 | Window top, parent; |
1430 | |
1353 | |
1431 | dLocal (Display *, dpy); |
1354 | dLocal (Display *, dpy); |
1432 | |
1355 | |
1433 | /* grab colors before netscape does */ |
1356 | /* grab colors before netscape does */ |
1434 | get_colours (); |
1357 | get_colors (); |
1435 | |
1358 | |
1436 | if (!set_fonts ()) |
1359 | if (!set_fonts ()) |
1437 | rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); |
1360 | rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); |
1438 | |
1361 | |
1439 | parent = display->root; |
1362 | parent = display->root; |
… | |
… | |
1484 | CWColormap | CWBackPixel | CWBorderPixel | CWOverrideRedirect, |
1407 | CWColormap | CWBackPixel | CWBorderPixel | CWOverrideRedirect, |
1485 | &attributes); |
1408 | &attributes); |
1486 | |
1409 | |
1487 | this->parent = top; |
1410 | this->parent = top; |
1488 | |
1411 | |
1489 | old_width = szHint.width; |
|
|
1490 | old_height = szHint.height; |
|
|
1491 | |
|
|
1492 | set_title (rs [Rs_title]); |
1412 | set_title (rs [Rs_title]); |
1493 | set_icon_name (rs [Rs_iconName]); |
1413 | set_icon_name (rs [Rs_iconName]); |
1494 | |
1414 | |
1495 | classHint.res_name = (char *)rs[Rs_name]; |
1415 | classHint.res_name = (char *)rs[Rs_name]; |
1496 | classHint.res_class = (char *)RESCLASS; |
1416 | classHint.res_class = (char *)RESCLASS; |
1497 | |
1417 | |
1498 | wmHint.flags = InputHint | StateHint | WindowGroupHint; |
1418 | wmHint.flags = InputHint | StateHint | WindowGroupHint; |
1499 | wmHint.input = True; |
1419 | wmHint.input = True; |
1500 | wmHint.initial_state = option (Opt_iconic) ? IconicState : NormalState; |
1420 | wmHint.initial_state = option (Opt_iconic) ? IconicState |
|
|
1421 | : option (Opt_dockapp) ? WithdrawnState |
|
|
1422 | : NormalState; |
1501 | wmHint.window_group = top; |
1423 | wmHint.window_group = top; |
1502 | |
1424 | |
1503 | XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc, |
1425 | XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc, |
1504 | &szHint, &wmHint, &classHint); |
1426 | &szHint, &wmHint, &classHint); |
1505 | #if ENABLE_EWMH |
1427 | #if ENABLE_EWMH |
… | |
… | |
1507 | * set up icon hint |
1429 | * set up icon hint |
1508 | * rs [Rs_iconfile] is path to icon |
1430 | * rs [Rs_iconfile] is path to icon |
1509 | */ |
1431 | */ |
1510 | |
1432 | |
1511 | if (rs [Rs_iconfile]) |
1433 | if (rs [Rs_iconfile]) |
1512 | { |
|
|
1513 | set_icon (rs [Rs_iconfile]); |
1434 | set_icon (rs [Rs_iconfile]); |
1514 | } |
|
|
1515 | #endif |
1435 | #endif |
1516 | |
1436 | |
1517 | #if ENABLE_FRILLS |
1437 | #if ENABLE_FRILLS |
1518 | if (mwmhints.flags) |
1438 | if (mwmhints.flags) |
1519 | XChangeProperty (dpy, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, |
1439 | XChangeProperty (dpy, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, |
… | |
… | |
1553 | | ExposureMask | StructureNotifyMask); |
1473 | | ExposureMask | StructureNotifyMask); |
1554 | |
1474 | |
1555 | termwin_ev.start (display, top); |
1475 | termwin_ev.start (display, top); |
1556 | |
1476 | |
1557 | /* vt cursor: Black-on-White is standard, but this is more popular */ |
1477 | /* vt cursor: Black-on-White is standard, but this is more popular */ |
|
|
1478 | unsigned int shape = XC_xterm; |
|
|
1479 | |
|
|
1480 | #ifdef HAVE_XMU |
|
|
1481 | if (rs[Rs_pointerShape]) |
|
|
1482 | { |
|
|
1483 | int stmp = XmuCursorNameToIndex (rs[Rs_pointerShape]); |
|
|
1484 | if (stmp >= 0) |
|
|
1485 | shape = stmp; |
|
|
1486 | } |
|
|
1487 | #endif |
|
|
1488 | |
1558 | TermWin_cursor = XCreateFontCursor (dpy, XC_xterm); |
1489 | TermWin_cursor = XCreateFontCursor (dpy, shape); |
1559 | |
1490 | |
1560 | /* the vt window */ |
1491 | /* the vt window */ |
1561 | vt = XCreateSimpleWindow (dpy, top, |
1492 | vt = XCreateSimpleWindow (dpy, top, |
1562 | window_vt_x, window_vt_y, |
1493 | window_vt_x, window_vt_y, |
1563 | width, height, |
1494 | vt_width, vt_height, |
1564 | 0, |
1495 | 0, |
1565 | pix_colors_focused[Color_fg], |
1496 | pix_colors_focused[Color_fg], |
1566 | pix_colors_focused[Color_bg]); |
1497 | pix_colors_focused[Color_bg]); |
1567 | |
1498 | |
1568 | attributes.bit_gravity = NorthWestGravity; |
1499 | attributes.bit_gravity = NorthWestGravity; |
… | |
… | |
1595 | if (rs[Rs_fade]) |
1526 | if (rs[Rs_fade]) |
1596 | pix_colors = pix_colors_unfocused; |
1527 | pix_colors = pix_colors_unfocused; |
1597 | #endif |
1528 | #endif |
1598 | |
1529 | |
1599 | pointer_unblank (); |
1530 | pointer_unblank (); |
1600 | scr_recolour (); |
1531 | scr_recolor (); |
1601 | } |
1532 | } |
1602 | |
1533 | |
1603 | /*----------------------------------------------------------------------*/ |
1534 | /*----------------------------------------------------------------------*/ |
1604 | /* |
1535 | /* |
1605 | * Run the command in a subprocess and return a file descriptor for the |
1536 | * Run the command in a subprocess and return a file descriptor for the |
… | |
… | |
1617 | if (pty->pty >= 0) |
1548 | if (pty->pty >= 0) |
1618 | { |
1549 | { |
1619 | if (getfd_hook) |
1550 | if (getfd_hook) |
1620 | pty->pty = (*getfd_hook) (pty->pty); |
1551 | pty->pty = (*getfd_hook) (pty->pty); |
1621 | |
1552 | |
1622 | if (pty->pty < 0 || fcntl (pty->pty, F_SETFL, O_NONBLOCK)) |
1553 | if (pty->pty < 0) |
1623 | rxvt_fatal ("unusable pty-fd filehandle, aborting.\n"); |
1554 | rxvt_fatal ("unusable pty-fd filehandle, aborting.\n"); |
1624 | } |
1555 | } |
1625 | } |
1556 | } |
1626 | else |
1557 | else |
1627 | #endif |
1558 | #endif |
1628 | if (!pty->get ()) |
1559 | if (!pty->get ()) |
1629 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
1560 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
|
|
1561 | |
|
|
1562 | fcntl (pty->pty, F_SETFL, O_NONBLOCK); |
1630 | |
1563 | |
1631 | struct termios tio = def_tio; |
1564 | struct termios tio = def_tio; |
1632 | |
1565 | |
1633 | #ifndef NO_BACKSPACE_KEY |
1566 | #ifndef NO_BACKSPACE_KEY |
1634 | if (rs[Rs_backspace_key][0] && !rs[Rs_backspace_key][1]) |
1567 | if (rs[Rs_backspace_key][0] && !rs[Rs_backspace_key][1]) |
… | |
… | |
1684 | |
1617 | |
1685 | _exit (EXIT_FAILURE); |
1618 | _exit (EXIT_FAILURE); |
1686 | |
1619 | |
1687 | default: |
1620 | default: |
1688 | if (!option (Opt_utmpInhibit)) |
1621 | if (!option (Opt_utmpInhibit)) |
|
|
1622 | { |
|
|
1623 | #ifdef LOG_ONLY_ON_LOGIN |
|
|
1624 | bool login_shell = option (Opt_loginShell); |
|
|
1625 | #else |
|
|
1626 | bool login_shell = true; |
|
|
1627 | #endif |
1689 | pty->login (cmd_pid, option (Opt_loginShell), rs[Rs_display_name]); |
1628 | pty->login (cmd_pid, login_shell, rs[Rs_display_name]); |
|
|
1629 | } |
1690 | |
1630 | |
1691 | pty->close_tty (); |
1631 | pty->close_tty (); |
1692 | |
1632 | |
1693 | child_ev.start (cmd_pid); |
1633 | child_ev.start (cmd_pid); |
1694 | |
1634 | |
… | |
… | |
1719 | #elif defined (SRIOCSREDIR) |
1659 | #elif defined (SRIOCSREDIR) |
1720 | int fd; |
1660 | int fd; |
1721 | |
1661 | |
1722 | fd = open (CONSOLE, O_WRONLY, 0); |
1662 | fd = open (CONSOLE, O_WRONLY, 0); |
1723 | if (fd >= 0) |
1663 | if (fd >= 0) |
1724 | if (ioctl (fd, SRIOCSREDIR, NULL) < 0) |
1664 | { |
|
|
1665 | ioctl (fd, SRIOCSREDIR, STDIN_FILENO); |
1725 | close (fd); |
1666 | close (fd); |
|
|
1667 | } |
1726 | #endif /* SRIOCSREDIR */ |
1668 | #endif /* SRIOCSREDIR */ |
1727 | } |
1669 | } |
1728 | |
1670 | |
1729 | /* reset signals and spin off the command interpreter */ |
1671 | /* reset signals and spin off the command interpreter */ |
1730 | signal (SIGINT, SIG_DFL); |
1672 | signal (SIGINT, SIG_DFL); |