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.160 by root, Wed Jan 4 05:35:34 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
42 46
43#ifdef HAVE_TERMIOS_H 47#ifdef HAVE_TERMIOS_H
44# include <termios.h> 48# include <termios.h>
45#endif 49#endif
46 50
47#ifdef KEYSYM_RESOURCE
48# include "keyboard.h"
49#endif
50
51vector<rxvt_term *> rxvt_term::termlist; 51vector<rxvt_term *> rxvt_term::termlist;
52 52
53static char curlocale[128]; 53static char curlocale[128], savelocale[128];
54 54
55bool 55bool
56rxvt_set_locale (const char *locale) 56rxvt_set_locale (const char *locale)
57{ 57{
58 if (!locale || !strncmp (locale, curlocale, 128)) 58 if (!locale || !strncmp (locale, curlocale, 128))
59 return false; 59 return false;
60 60
61 strncpy (curlocale, locale, 128); 61 strncpy (curlocale, locale, 128);
62 setlocale (LC_CTYPE, curlocale); 62 setlocale (LC_CTYPE, curlocale);
63 return true; 63 return true;
64}
65
66bool
67rxvt_push_locale (const char *locale)
68{
69 strcpy (savelocale, curlocale);
70 rxvt_set_locale (locale);
71}
72
73void
74rxvt_pop_locale ()
75{
76 rxvt_set_locale (savelocale);
64} 77}
65 78
66#if ENABLE_COMBINING 79#if ENABLE_COMBINING
67class rxvt_composite_vec rxvt_composite; 80class rxvt_composite_vec rxvt_composite;
68 81
193 pty.put (); 206 pty.put ();
194} 207}
195 208
196rxvt_term::~rxvt_term () 209rxvt_term::~rxvt_term ()
197{ 210{
211 PERL_INVOKE ((this, HOOK_DESTROY, DT_END));
212
198 termlist.erase (find (termlist.begin (), termlist.end(), this)); 213 termlist.erase (find (termlist.begin (), termlist.end(), this));
199 214
200 emergency_cleanup (); 215 emergency_cleanup ();
201 216
202#if ENABLE_STYLES 217#if ENABLE_STYLES
284 delete argv; 299 delete argv;
285 300
286#ifdef KEYSYM_RESOURCE 301#ifdef KEYSYM_RESOURCE
287 delete keyboard; 302 delete keyboard;
288#endif 303#endif
304}
305
306void
307rxvt_term::child_exit ()
308{
309 cmd_pid = 0;
310
311 if (!OPTION (Opt_hold))
312 destroy ();
289} 313}
290 314
291void 315void
292rxvt_term::destroy () 316rxvt_term::destroy ()
293{ 317{
458 482
459#if MENUBAR_MAX 483#if MENUBAR_MAX
460 menubar_read (rs[Rs_menu]); 484 menubar_read (rs[Rs_menu]);
461#endif 485#endif
462#ifdef HAVE_SCROLLBARS 486#ifdef HAVE_SCROLLBARS
463 if (options & Opt_scrollBar) 487 if (OPTION (Opt_scrollBar))
464 scrollBar.setIdle (); /* set existence for size calculations */ 488 scrollBar.setIdle (); /* set existence for size calculations */
489#endif
490
491#if ENABLE_PERL
492 if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1])
493 || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2])
494 || (rs[Rs_perl_eval] && *rs[Rs_perl_eval]))
495 {
496 rxvt_perl.init ();
497 PERL_INVOKE ((this, HOOK_INIT, DT_END));
498 }
465#endif 499#endif
466 500
467 create_windows (argc, argv); 501 create_windows (argc, argv);
468 502
469 dDisp; 503 dDisp;
475#if 0 509#if 0
476 XSynchronize (disp, True); 510 XSynchronize (disp, True);
477#endif 511#endif
478 512
479#ifdef HAVE_SCROLLBARS 513#ifdef HAVE_SCROLLBARS
480 if (options & Opt_scrollBar) 514 if (OPTION (Opt_scrollBar))
481 resize_scrollbar (); /* create and map scrollbar */ 515 resize_scrollbar (); /* create and map scrollbar */
482#endif 516#endif
483#if (MENUBAR_MAX) 517#if (MENUBAR_MAX)
484 if (menubar_visible ()) 518 if (menubar_visible ())
485 XMapWindow (disp, menuBar.win); 519 XMapWindow (disp, menuBar.win);
486#endif 520#endif
487#ifdef TRANSPARENT 521#ifdef TRANSPARENT
488 if (options & Opt_transparent) 522 if (OPTION (Opt_transparent))
489 { 523 {
490 XSelectInput (disp, display->root, PropertyChangeMask); 524 XSelectInput (disp, display->root, PropertyChangeMask);
491 check_our_parents (); 525 check_our_parents ();
492 rootwin_ev.start (display, display->root); 526 rootwin_ev.start (display, display->root);
493 } 527 }
503 free (cmd_argv); 537 free (cmd_argv);
504 538
505 pty_ev.start (pty.pty, EVENT_READ); 539 pty_ev.start (pty.pty, EVENT_READ);
506 540
507 check_ev.start (); 541 check_ev.start ();
542
543 PERL_INVOKE ((this, HOOK_START, DT_END));
508 544
509 return true; 545 return true;
510} 546}
511 547
512static struct sig_handlers 548static struct sig_handlers
520 556
521 while ((pid = waitpid (-1, NULL, WNOHANG)) > 0) 557 while ((pid = waitpid (-1, NULL, WNOHANG)) > 0)
522 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) 558 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
523 if (pid == (*t)->cmd_pid) 559 if (pid == (*t)->cmd_pid)
524 { 560 {
525 (*t)->destroy (); 561 (*t)->child_exit ();
526 break; 562 break;
527 } 563 }
528 } 564 }
529 565
530 /* 566 /*
670 706
671#ifdef UTMP_SUPPORT 707#ifdef UTMP_SUPPORT
672void 708void
673rxvt_term::privileged_utmp (rxvt_privaction action) 709rxvt_term::privileged_utmp (rxvt_privaction action)
674{ 710{
675 if ((options & Opt_utmpInhibit) 711 if (OPTION (Opt_utmpInhibit)
676 || !pty.name || !*pty.name) 712 || !pty.name || !*pty.name)
677 return; 713 return;
678 714
679 rxvt_privileges (RESTORE); 715 rxvt_privileges (RESTORE);
680 716
718 if (rs[Rs_geometry]) 754 if (rs[Rs_geometry])
719 flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); 755 flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h);
720 756
721 if (flags & WidthValue) 757 if (flags & WidthValue)
722 { 758 {
723 ncol = clamp (w, 0, MAX_POSITIVE_INT16); 759 ncol = clamp (w, 0, std::numeric_limits<int16_t>::max ());
724 szHint.flags |= USSize; 760 szHint.flags |= USSize;
725 } 761 }
726 762
727 if (flags & HeightValue) 763 if (flags & HeightValue)
728 { 764 {
729 nrow = clamp (h, 0, MAX_POSITIVE_INT16); 765 nrow = clamp (h, 0, std::numeric_limits<int16_t>::max ());
730 szHint.flags |= USSize; 766 szHint.flags |= USSize;
731 } 767 }
732 768
733 if (flags & XValue) 769 if (flags & XValue)
734 { 770 {
772 808
773 if (scrollbar_visible ()) 809 if (scrollbar_visible ())
774 { 810 {
775 sb_w = scrollbar_TotalWidth (); 811 sb_w = scrollbar_TotalWidth ();
776 szHint.base_width += sb_w; 812 szHint.base_width += sb_w;
777 if (!(options & Opt_scrollBar_right)) 813 if (!OPTION (Opt_scrollBar_right))
778 window_vt_x += sb_w; 814 window_vt_x += sb_w;
779 } 815 }
780 816
781 if (menubar_visible ()) 817 if (menubar_visible ())
782 { 818 {
810 { 846 {
811 min_it (height, max_height); 847 min_it (height, max_height);
812 szHint.height = szHint.base_height + height; 848 szHint.height = szHint.base_height + height;
813 } 849 }
814 850
815 if (scrollbar_visible () && (options & Opt_scrollBar_right)) 851 if (scrollbar_visible () && OPTION (Opt_scrollBar_right))
816 window_sb_x = szHint.width - sb_w; 852 window_sb_x = szHint.width - sb_w;
817 853
818 if (recalc_x) 854 if (recalc_x)
819 szHint.x += DisplayWidth (disp, display->screen) - szHint.width - 2 * ext_bwidth; 855 szHint.x += DisplayWidth (disp, display->screen) - szHint.width - 2 * ext_bwidth;
820 if (recalc_y) 856 if (recalc_y)
889 prop.height += lineSpace; 925 prop.height += lineSpace;
890 fs->set_prop (prop); 926 fs->set_prop (prop);
891 927
892 fwidth = prop.width; 928 fwidth = prop.width;
893 fheight = prop.height; 929 fheight = prop.height;
894 fweight = prop.weight; 930 fbase = prop.ascent;
895 fslant = prop.slant;
896 fbase = (*fs)[1]->ascent;
897 931
898 for (int style = 1; style < 4; style++) 932 for (int style = 1; style < 4; style++)
899 { 933 {
900#if ENABLE_STYLES 934#if ENABLE_STYLES
901 const char *res = rs[Rs_font + style]; 935 const char *res = rs[Rs_font + style];
935 return true; 969 return true;
936} 970}
937 971
938void rxvt_term::set_string_property (Atom prop, const char *str, int len) 972void rxvt_term::set_string_property (Atom prop, const char *str, int len)
939{ 973{
940 // TODO: SMART_WINDOW_TITLE
941 XChangeProperty (display->display, parent[0], 974 XChangeProperty (display->display, parent[0],
942 prop, XA_STRING, 8, PropModeReplace, 975 prop, XA_STRING, 8, PropModeReplace,
943 (const unsigned char *)str, len >= 0 ? len : strlen (str)); 976 (const unsigned char *)str, len >= 0 ? len : strlen (str));
944} 977}
945 978
946void rxvt_term::set_utf8_property (Atom prop, const char *str, int len) 979void rxvt_term::set_utf8_property (Atom prop, const char *str, int len)
947{ 980{
948 // TODO: SMART_WINDOW_TITLE
949 wchar_t *ws = rxvt_mbstowcs (str, len); 981 wchar_t *ws = rxvt_mbstowcs (str, len);
950 char *s = rxvt_wcstoutf8 (ws); 982 char *s = rxvt_wcstoutf8 (ws);
951 983
952 XChangeProperty (display->display, parent[0], 984 XChangeProperty (display->display, parent[0],
953 prop, xa[XA_UTF8_STRING], 8, PropModeReplace, 985 prop, xa[XA_UTF8_STRING], 8, PropModeReplace,
1192 } 1224 }
1193 1225
1194 if (menubar_visible ()) 1226 if (menubar_visible ())
1195 XMoveResizeWindow (disp, menuBar.win, 1227 XMoveResizeWindow (disp, menuBar.win,
1196 window_vt_x, 0, 1228 window_vt_x, 0,
1197 TermWin_TotalWidth (), menuBar_TotalHeight ()); 1229 width, menuBar_TotalHeight ());
1198 1230
1199 XMoveResizeWindow (disp, vt, 1231 XMoveResizeWindow (disp, vt,
1200 window_vt_x, window_vt_y, 1232 window_vt_x, window_vt_y,
1201 TermWin_TotalWidth (), TermWin_TotalHeight ()); 1233 width, height);
1202 1234
1203 scr_clear (); 1235 scr_clear ();
1204#ifdef XPM_BACKGROUND 1236#ifdef XPM_BACKGROUND
1205 resize_pixmap (); 1237 resize_pixmap ();
1206#endif 1238#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines