ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/main.C
(Generate patch)

Comparing rxvt-unicode/src/main.C (file contents):
Revision 1.150 by root, Wed Dec 21 14:19:19 2005 UTC vs.
Revision 1.155 by root, Mon Jan 2 15:35:43 2006 UTC

30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 *---------------------------------------------------------------------*/ 31 *---------------------------------------------------------------------*/
32 32
33#include "../config.h" /* NECESSARY */ 33#include "../config.h" /* NECESSARY */
34#include "rxvt.h" /* NECESSARY */ 34#include "rxvt.h" /* NECESSARY */
35#include "keyboard.h"
36#include "rxvtperl.h"
37
38#include <limits>
35 39
36#include <csignal> 40#include <csignal>
37#include <cstring> 41#include <cstring>
38 42
39#ifdef TTY_GID_SUPPORT 43#ifdef TTY_GID_SUPPORT
40# include <grp.h> 44# include <grp.h>
41#endif 45#endif
42 46
43#ifdef HAVE_TERMIOS_H 47#ifdef HAVE_TERMIOS_H
44# include <termios.h> 48# include <termios.h>
45#endif
46
47#ifdef KEYSYM_RESOURCE
48# include "keyboard.h"
49#endif 49#endif
50 50
51vector<rxvt_term *> rxvt_term::termlist; 51vector<rxvt_term *> rxvt_term::termlist;
52 52
53static char curlocale[128]; 53static char curlocale[128];
193 pty.put (); 193 pty.put ();
194} 194}
195 195
196rxvt_term::~rxvt_term () 196rxvt_term::~rxvt_term ()
197{ 197{
198 PERL_INVOKE ((this, HOOK_DESTROY, DT_END));
199
198 termlist.erase (find (termlist.begin (), termlist.end(), this)); 200 termlist.erase (find (termlist.begin (), termlist.end(), this));
199 201
200 emergency_cleanup (); 202 emergency_cleanup ();
201 203
202#if ENABLE_STYLES 204#if ENABLE_STYLES
284 delete argv; 286 delete argv;
285 287
286#ifdef KEYSYM_RESOURCE 288#ifdef KEYSYM_RESOURCE
287 delete keyboard; 289 delete keyboard;
288#endif 290#endif
291}
292
293void
294rxvt_term::child_exit ()
295{
296 cmd_pid = 0;
297
298 if (!OPTION (Opt_hold))
299 destroy ();
289} 300}
290 301
291void 302void
292rxvt_term::destroy () 303rxvt_term::destroy ()
293{ 304{
458 469
459#if MENUBAR_MAX 470#if MENUBAR_MAX
460 menubar_read (rs[Rs_menu]); 471 menubar_read (rs[Rs_menu]);
461#endif 472#endif
462#ifdef HAVE_SCROLLBARS 473#ifdef HAVE_SCROLLBARS
463 if (options & Opt_scrollBar) 474 if (OPTION (Opt_scrollBar))
464 scrollBar.setIdle (); /* set existence for size calculations */ 475 scrollBar.setIdle (); /* set existence for size calculations */
465#endif 476#endif
477
478#if ENABLE_PERL
479 rxvt_perl.init ();
480#endif
481
482 PERL_INVOKE ((this, HOOK_INIT, DT_END));
466 483
467 create_windows (argc, argv); 484 create_windows (argc, argv);
468 485
469 dDisp; 486 dDisp;
470 487
475#if 0 492#if 0
476 XSynchronize (disp, True); 493 XSynchronize (disp, True);
477#endif 494#endif
478 495
479#ifdef HAVE_SCROLLBARS 496#ifdef HAVE_SCROLLBARS
480 if (options & Opt_scrollBar) 497 if (OPTION (Opt_scrollBar))
481 resize_scrollbar (); /* create and map scrollbar */ 498 resize_scrollbar (); /* create and map scrollbar */
482#endif 499#endif
483#if (MENUBAR_MAX) 500#if (MENUBAR_MAX)
484 if (menubar_visible ()) 501 if (menubar_visible ())
485 XMapWindow (disp, menuBar.win); 502 XMapWindow (disp, menuBar.win);
486#endif 503#endif
487#ifdef TRANSPARENT 504#ifdef TRANSPARENT
488 if (options & Opt_transparent) 505 if (OPTION (Opt_transparent))
489 { 506 {
490 XSelectInput (disp, display->root, PropertyChangeMask); 507 XSelectInput (disp, display->root, PropertyChangeMask);
491 check_our_parents (); 508 check_our_parents ();
492 rootwin_ev.start (display, display->root); 509 rootwin_ev.start (display, display->root);
493 } 510 }
503 free (cmd_argv); 520 free (cmd_argv);
504 521
505 pty_ev.start (pty.pty, EVENT_READ); 522 pty_ev.start (pty.pty, EVENT_READ);
506 523
507 check_ev.start (); 524 check_ev.start ();
525
526 PERL_INVOKE ((this, HOOK_START, DT_END));
508 527
509 return true; 528 return true;
510} 529}
511 530
512static struct sig_handlers 531static struct sig_handlers
520 539
521 while ((pid = waitpid (-1, NULL, WNOHANG)) > 0) 540 while ((pid = waitpid (-1, NULL, WNOHANG)) > 0)
522 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) 541 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
523 if (pid == (*t)->cmd_pid) 542 if (pid == (*t)->cmd_pid)
524 { 543 {
525 (*t)->destroy (); 544 (*t)->child_exit ();
526 break; 545 break;
527 } 546 }
528 } 547 }
529 548
530 /* 549 /*
670 689
671#ifdef UTMP_SUPPORT 690#ifdef UTMP_SUPPORT
672void 691void
673rxvt_term::privileged_utmp (rxvt_privaction action) 692rxvt_term::privileged_utmp (rxvt_privaction action)
674{ 693{
675 if ((options & Opt_utmpInhibit) 694 if (OPTION (Opt_utmpInhibit)
676 || !pty.name || !*pty.name) 695 || !pty.name || !*pty.name)
677 return; 696 return;
678 697
679 rxvt_privileges (RESTORE); 698 rxvt_privileges (RESTORE);
680 699
718 if (rs[Rs_geometry]) 737 if (rs[Rs_geometry])
719 flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); 738 flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h);
720 739
721 if (flags & WidthValue) 740 if (flags & WidthValue)
722 { 741 {
723 ncol = clamp (w, 0, MAX_POSITIVE_INT16); 742 ncol = clamp (w, 0, std::numeric_limits<int16_t>::max ());
724 szHint.flags |= USSize; 743 szHint.flags |= USSize;
725 } 744 }
726 745
727 if (flags & HeightValue) 746 if (flags & HeightValue)
728 { 747 {
729 nrow = clamp (h, 0, MAX_POSITIVE_INT16); 748 nrow = clamp (h, 0, std::numeric_limits<int16_t>::max ());
730 szHint.flags |= USSize; 749 szHint.flags |= USSize;
731 } 750 }
732 751
733 if (flags & XValue) 752 if (flags & XValue)
734 { 753 {
772 791
773 if (scrollbar_visible ()) 792 if (scrollbar_visible ())
774 { 793 {
775 sb_w = scrollbar_TotalWidth (); 794 sb_w = scrollbar_TotalWidth ();
776 szHint.base_width += sb_w; 795 szHint.base_width += sb_w;
777 if (!(options & Opt_scrollBar_right)) 796 if (!OPTION (Opt_scrollBar_right))
778 window_vt_x += sb_w; 797 window_vt_x += sb_w;
779 } 798 }
780 799
781 if (menubar_visible ()) 800 if (menubar_visible ())
782 { 801 {
810 { 829 {
811 min_it (height, max_height); 830 min_it (height, max_height);
812 szHint.height = szHint.base_height + height; 831 szHint.height = szHint.base_height + height;
813 } 832 }
814 833
815 if (scrollbar_visible () && (options & Opt_scrollBar_right)) 834 if (scrollbar_visible () && OPTION (Opt_scrollBar_right))
816 window_sb_x = szHint.width - sb_w; 835 window_sb_x = szHint.width - sb_w;
817 836
818 if (recalc_x) 837 if (recalc_x)
819 szHint.x += DisplayWidth (disp, display->screen) - szHint.width - 2 * ext_bwidth; 838 szHint.x += DisplayWidth (disp, display->screen) - szHint.width - 2 * ext_bwidth;
820 if (recalc_y) 839 if (recalc_y)
889 prop.height += lineSpace; 908 prop.height += lineSpace;
890 fs->set_prop (prop); 909 fs->set_prop (prop);
891 910
892 fwidth = prop.width; 911 fwidth = prop.width;
893 fheight = prop.height; 912 fheight = prop.height;
894 fweight = prop.weight;
895 fslant = prop.slant;
896 fbase = (*fs)[1]->ascent; 913 fbase = (*fs)[1]->ascent;
897 914
898 for (int style = 1; style < 4; style++) 915 for (int style = 1; style < 4; style++)
899 { 916 {
900#if ENABLE_STYLES 917#if ENABLE_STYLES
935 return true; 952 return true;
936} 953}
937 954
938void rxvt_term::set_string_property (Atom prop, const char *str, int len) 955void rxvt_term::set_string_property (Atom prop, const char *str, int len)
939{ 956{
940 // TODO: SMART_WINDOW_TITLE
941 XChangeProperty (display->display, parent[0], 957 XChangeProperty (display->display, parent[0],
942 prop, XA_STRING, 8, PropModeReplace, 958 prop, XA_STRING, 8, PropModeReplace,
943 (const unsigned char *)str, len >= 0 ? len : strlen (str)); 959 (const unsigned char *)str, len >= 0 ? len : strlen (str));
944} 960}
945 961
946void rxvt_term::set_utf8_property (Atom prop, const char *str, int len) 962void rxvt_term::set_utf8_property (Atom prop, const char *str, int len)
947{ 963{
948 // TODO: SMART_WINDOW_TITLE
949 wchar_t *ws = rxvt_mbstowcs (str, len); 964 wchar_t *ws = rxvt_mbstowcs (str, len);
950 char *s = rxvt_wcstoutf8 (ws); 965 char *s = rxvt_wcstoutf8 (ws);
951 966
952 XChangeProperty (display->display, parent[0], 967 XChangeProperty (display->display, parent[0],
953 prop, xa[XA_UTF8_STRING], 8, PropModeReplace, 968 prop, xa[XA_UTF8_STRING], 8, PropModeReplace,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines