… | |
… | |
10 | * Copyright (c) 1996 Chuck Blake <cblake@BBN.COM> |
10 | * Copyright (c) 1996 Chuck Blake <cblake@BBN.COM> |
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-2007 Marc Lehmann <pcg@goof.com> |
15 | * Copyright (c) 2003-2008 Marc Lehmann <pcg@goof.com> |
16 | * |
16 | * |
17 | * This program is free software; you can redistribute it and/or modify |
17 | * 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 |
18 | * 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 |
19 | * the Free Software Foundation; either version 2 of the License, or |
20 | * (at your option) any later version. |
20 | * (at your option) any later version. |
… | |
… | |
34 | |
34 | |
35 | #include "../config.h" /* NECESSARY */ |
35 | #include "../config.h" /* NECESSARY */ |
36 | #include "rxvt.h" /* NECESSARY */ |
36 | #include "rxvt.h" /* NECESSARY */ |
37 | #include "rxvtutil.h" |
37 | #include "rxvtutil.h" |
38 | #include "init.h" |
38 | #include "init.h" |
|
|
39 | #include "keyboard.h" |
39 | |
40 | |
40 | #include <limits> |
41 | #include <limits> |
41 | |
42 | |
42 | #include <csignal> |
43 | #include <csignal> |
43 | |
44 | |
… | |
… | |
266 | NULL, // Color_underline |
267 | NULL, // Color_underline |
267 | #endif |
268 | #endif |
268 | #ifdef OPTION_HC |
269 | #ifdef OPTION_HC |
269 | NULL, |
270 | NULL, |
270 | #endif |
271 | #endif |
271 | #ifdef KEEP_SCROLLCOLOR |
272 | #ifdef HAVE_SCROLLBARS |
272 | COLOR_SCROLLBAR, |
273 | COLOR_SCROLLBAR, |
|
|
274 | #endif |
|
|
275 | #ifdef RXVT_SCROLLBAR |
273 | COLOR_SCROLLTROUGH, |
276 | COLOR_SCROLLTROUGH, |
274 | #endif /* KEEP_SCROLLCOLOR */ |
277 | #endif |
275 | #if ENABLE_TRANSPARENCY |
278 | #if ENABLE_TRANSPARENCY |
276 | NULL, |
279 | NULL, |
277 | #endif |
280 | #endif |
278 | #if OFF_FOCUS_FADING |
281 | #if OFF_FOCUS_FADING |
279 | "rgb:00/00/00", |
282 | "rgb:00/00/00", |
… | |
… | |
307 | set_option (Opt_secondaryScreen); |
310 | set_option (Opt_secondaryScreen); |
308 | set_option (Opt_secondaryScroll); |
311 | set_option (Opt_secondaryScroll); |
309 | set_option (Opt_pastableTabs); |
312 | set_option (Opt_pastableTabs); |
310 | set_option (Opt_intensityStyles); |
313 | set_option (Opt_intensityStyles); |
311 | set_option (Opt_iso14755_52); |
314 | set_option (Opt_iso14755_52); |
|
|
315 | set_option (Opt_buffered); |
312 | } |
316 | } |
313 | |
317 | |
314 | void |
318 | static void |
315 | rxvt_term::init_secondary () |
319 | init_secondary () |
316 | { |
320 | { |
317 | int i; |
321 | int i; |
318 | |
322 | |
319 | /* |
|
|
320 | * Close all unused file descriptors |
|
|
321 | * We don't want them, we don't need them. |
|
|
322 | */ |
|
|
323 | if ((i = open ("/dev/null", O_RDONLY)) < 0) |
323 | if ((i = open ("/dev/null", O_RDONLY)) < 0) |
324 | { |
324 | { |
325 | /* TODO: BOO HISS */ |
|
|
326 | dup2 (STDERR_FILENO, STDIN_FILENO); |
325 | dup2 (STDERR_FILENO, STDIN_FILENO); |
327 | } |
326 | } |
328 | else if (i != STDIN_FILENO) |
327 | else if (i != STDIN_FILENO) |
329 | { |
328 | { |
330 | dup2 (i, STDIN_FILENO); |
329 | dup2 (i, STDIN_FILENO); |
331 | close (i); |
330 | close (i); |
332 | } |
331 | } |
333 | |
332 | |
334 | dup2 (STDERR_FILENO, STDOUT_FILENO); |
333 | dup2 (STDERR_FILENO, STDOUT_FILENO); |
335 | |
|
|
336 | #if 0 // schmorp sayz closing filies is murder |
|
|
337 | for (i = STDERR_FILENO + 1; i < num_fds; i++) |
|
|
338 | { |
|
|
339 | #ifdef __sgi /* Alex Coventry says we need 4 & 7 too */ |
|
|
340 | if (i == 4 || i == 7) |
|
|
341 | continue; |
|
|
342 | #endif |
|
|
343 | close (i); |
|
|
344 | } |
|
|
345 | #endif |
|
|
346 | } |
334 | } |
347 | |
335 | |
348 | /*----------------------------------------------------------------------*/ |
336 | /*----------------------------------------------------------------------*/ |
349 | const char ** |
337 | const char ** |
350 | rxvt_term::init_resources (int argc, const char *const *argv) |
338 | rxvt_term::init_resources (int argc, const char *const *argv) |
… | |
… | |
549 | return cmd_argv; |
537 | return cmd_argv; |
550 | } |
538 | } |
551 | |
539 | |
552 | /*----------------------------------------------------------------------*/ |
540 | /*----------------------------------------------------------------------*/ |
553 | void |
541 | void |
|
|
542 | rxvt_term::init (int argc, const char *const *argv, stringvec *envv) |
|
|
543 | { |
|
|
544 | this->envv = envv; |
|
|
545 | |
|
|
546 | SET_R (this); |
|
|
547 | set_locale (""); |
|
|
548 | set_environ (envv); // few things in X do not call setlocale :( |
|
|
549 | |
|
|
550 | init_vars (); |
|
|
551 | |
|
|
552 | init_secondary (); |
|
|
553 | |
|
|
554 | const char **cmd_argv = init_resources (argc, argv); |
|
|
555 | |
|
|
556 | #ifdef KEYSYM_RESOURCE |
|
|
557 | keyboard->register_done (); |
|
|
558 | #endif |
|
|
559 | |
|
|
560 | #ifdef HAVE_SCROLLBARS |
|
|
561 | if (option (Opt_scrollBar)) |
|
|
562 | scrollBar.setIdle (); /* set existence for size calculations */ |
|
|
563 | #endif |
|
|
564 | |
|
|
565 | pty = ptytty::create (); |
|
|
566 | |
|
|
567 | create_windows (argc, argv); |
|
|
568 | |
|
|
569 | init_xlocale (); |
|
|
570 | |
|
|
571 | scr_reset (); // initialize screen |
|
|
572 | |
|
|
573 | #if 0 |
|
|
574 | XSynchronize (dpy, True); |
|
|
575 | #endif |
|
|
576 | |
|
|
577 | #ifdef HAVE_SCROLLBARS |
|
|
578 | if (option (Opt_scrollBar)) |
|
|
579 | resize_scrollbar (); /* create and map scrollbar */ |
|
|
580 | #endif |
|
|
581 | #ifdef HAVE_BG_PIXMAP |
|
|
582 | { |
|
|
583 | bgPixmap.set_target (this); |
|
|
584 | bgPixmap.invalidate (); |
|
|
585 | |
|
|
586 | #ifdef ENABLE_TRANSPARENCY |
|
|
587 | if (option (Opt_transparent)) |
|
|
588 | { |
|
|
589 | bgPixmap.set_transparent (); |
|
|
590 | |
|
|
591 | #ifdef HAVE_AFTERIMAGE |
|
|
592 | if (rs [Rs_blurradius]) |
|
|
593 | bgPixmap.set_blur_radius (rs [Rs_blurradius]); |
|
|
594 | #endif |
|
|
595 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
596 | bgPixmap.set_tint (pix_colors_focused [Color_tint]); |
|
|
597 | |
|
|
598 | if (rs [Rs_shade]) |
|
|
599 | bgPixmap.set_shade (rs [Rs_shade]); |
|
|
600 | |
|
|
601 | bgPixmap.set_root_pixmap (); |
|
|
602 | XSelectInput (dpy, display->root, PropertyChangeMask); |
|
|
603 | rootwin_ev.start (display, display->root); |
|
|
604 | } |
|
|
605 | #endif |
|
|
606 | |
|
|
607 | #ifdef BG_IMAGE_FROM_FILE |
|
|
608 | if (rs[Rs_backgroundPixmap]) |
|
|
609 | { |
|
|
610 | const char *p = rs[Rs_backgroundPixmap]; |
|
|
611 | |
|
|
612 | if ((p = strchr (p, ';')) != 0) |
|
|
613 | { |
|
|
614 | p++; |
|
|
615 | bgPixmap.set_geometry (p); |
|
|
616 | } |
|
|
617 | else |
|
|
618 | bgPixmap.set_defaultGeometry (); |
|
|
619 | |
|
|
620 | if (bgPixmap.set_file (rs[Rs_backgroundPixmap])) |
|
|
621 | if (!bgPixmap.window_position_sensitive ()) |
|
|
622 | update_background (); |
|
|
623 | } |
|
|
624 | #endif |
|
|
625 | } |
|
|
626 | #endif |
|
|
627 | |
|
|
628 | #if ENABLE_PERL |
|
|
629 | rootwin_ev.start (display, display->root); |
|
|
630 | #endif |
|
|
631 | |
|
|
632 | set_colorfgbg (); |
|
|
633 | |
|
|
634 | init_command (cmd_argv); |
|
|
635 | |
|
|
636 | free (cmd_argv); |
|
|
637 | |
|
|
638 | if (pty->pty >= 0) |
|
|
639 | pty_ev.start (pty->pty, ev::READ); |
|
|
640 | |
|
|
641 | HOOK_INVOKE ((this, HOOK_START, DT_END)); |
|
|
642 | |
|
|
643 | #if ENABLE_XEMBED |
|
|
644 | if (rs[Rs_embed]) |
|
|
645 | { |
|
|
646 | long info[2] = { 0, XEMBED_MAPPED }; |
|
|
647 | |
|
|
648 | XChangeProperty (dpy, parent[0], xa[XA_XEMBED_INFO], xa[XA_XEMBED_INFO], |
|
|
649 | 32, PropModeReplace, (unsigned char *)&info, 2); |
|
|
650 | } |
|
|
651 | #endif |
|
|
652 | |
|
|
653 | XMapWindow (dpy, vt); |
|
|
654 | XMapWindow (dpy, parent[0]); |
|
|
655 | |
|
|
656 | refresh_check (); |
|
|
657 | } |
|
|
658 | |
|
|
659 | /*----------------------------------------------------------------------*/ |
|
|
660 | void |
554 | rxvt_term::init_env () |
661 | rxvt_term::init_env () |
555 | { |
662 | { |
556 | int i; |
663 | int i; |
557 | char *val; |
664 | char *val; |
558 | |
665 | |
… | |
… | |
803 | * get scrollBar shadow colors |
910 | * get scrollBar shadow colors |
804 | * |
911 | * |
805 | * The calculations of topShadow/bottomShadow values are adapted |
912 | * The calculations of topShadow/bottomShadow values are adapted |
806 | * from the fvwm window manager. |
913 | * from the fvwm window manager. |
807 | */ |
914 | */ |
808 | #ifdef KEEP_SCROLLCOLOR |
915 | #ifdef RXVT_SCROLLBAR |
809 | if (depth <= 2) |
916 | if (depth <= 2) |
810 | { |
917 | { |
811 | /* Monochrome */ |
918 | /* Monochrome */ |
812 | alias_color (Color_scroll, Color_fg); |
919 | alias_color (Color_scroll, Color_fg); |
813 | alias_color (Color_topShadow, Color_bg); |
920 | alias_color (Color_topShadow, Color_bg); |
… | |
… | |
828 | min ((int)rgba::MAX_CC, max (cscroll.b / 5, cscroll.b) * 7 / 5), |
935 | min ((int)rgba::MAX_CC, max (cscroll.b / 5, cscroll.b) * 7 / 5), |
829 | cscroll.a) |
936 | cscroll.a) |
830 | )) |
937 | )) |
831 | alias_color (Color_topShadow, Color_White); |
938 | alias_color (Color_topShadow, Color_White); |
832 | } |
939 | } |
833 | #endif /* KEEP_SCROLLCOLOR */ |
940 | #endif |
834 | |
941 | |
835 | #ifdef OFF_FOCUS_FADING |
942 | #ifdef OFF_FOCUS_FADING |
836 | for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) |
943 | for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) |
837 | update_fade_color (i); |
944 | update_fade_color (i); |
838 | #endif |
945 | #endif |
… | |
… | |
1074 | |
1181 | |
1075 | termwin_ev.start (display, top); |
1182 | termwin_ev.start (display, top); |
1076 | |
1183 | |
1077 | /* vt cursor: Black-on-White is standard, but this is more popular */ |
1184 | /* vt cursor: Black-on-White is standard, but this is more popular */ |
1078 | TermWin_cursor = XCreateFontCursor (dpy, XC_xterm); |
1185 | TermWin_cursor = XCreateFontCursor (dpy, XC_xterm); |
1079 | |
|
|
1080 | #ifdef HAVE_SCROLLBARS |
|
|
1081 | /* cursor scrollBar: Black-on-White */ |
|
|
1082 | leftptr_cursor = XCreateFontCursor (dpy, XC_left_ptr); |
|
|
1083 | #endif |
|
|
1084 | |
1186 | |
1085 | /* the vt window */ |
1187 | /* the vt window */ |
1086 | vt = XCreateSimpleWindow (dpy, top, |
1188 | vt = XCreateSimpleWindow (dpy, top, |
1087 | window_vt_x, window_vt_y, |
1189 | window_vt_x, window_vt_y, |
1088 | width, height, |
1190 | width, height, |