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.171 by root, Wed Jan 11 03:13:26 2006 UTC vs.
Revision 1.183 by root, Tue Jan 17 10:19:13 2006 UTC

161 rootwin_ev (this, &rxvt_term::rootwin_cb), 161 rootwin_ev (this, &rxvt_term::rootwin_cb),
162#endif 162#endif
163#ifdef HAVE_SCROLLBARS 163#ifdef HAVE_SCROLLBARS
164 scrollbar_ev (this, &rxvt_term::x_cb), 164 scrollbar_ev (this, &rxvt_term::x_cb),
165#endif 165#endif
166#ifdef MENUBAR
167 menubar_ev (this, &rxvt_term::x_cb),
168#endif
169#ifdef CURSOR_BLINK 166#ifdef CURSOR_BLINK
170 cursor_blink_ev (this, &rxvt_term::cursor_blink_cb), 167 cursor_blink_ev (this, &rxvt_term::cursor_blink_cb),
171#endif 168#endif
172#ifdef TEXT_BLINK 169#ifdef TEXT_BLINK
173 text_blink_ev (this, &rxvt_term::text_blink_cb), 170 text_blink_ev (this, &rxvt_term::text_blink_cb),
242 239
243 selection_clear (); 240 selection_clear ();
244 241
245#ifdef USE_XIM 242#ifdef USE_XIM
246 im_destroy (); 243 im_destroy ();
247#endif
248#ifdef MENUBAR
249 if (menubarGC) XFreeGC (disp, menubarGC);
250#endif 244#endif
251#ifdef XTERM_SCROLLBAR 245#ifdef XTERM_SCROLLBAR
252 if (xscrollbarGC) XFreeGC (disp, xscrollbarGC); 246 if (xscrollbarGC) XFreeGC (disp, xscrollbarGC);
253 if (ShadowGC) XFreeGC (disp, ShadowGC); 247 if (ShadowGC) XFreeGC (disp, ShadowGC);
254#endif 248#endif
265 if (upArrow) XFreePixmap (disp, upArrow); 259 if (upArrow) XFreePixmap (disp, upArrow);
266 if (downArrow) XFreePixmap (disp, downArrow); 260 if (downArrow) XFreePixmap (disp, downArrow);
267 if (upArrowHi) XFreePixmap (disp, upArrowHi); 261 if (upArrowHi) XFreePixmap (disp, upArrowHi);
268 if (downArrowHi) XFreePixmap (disp, downArrowHi); 262 if (downArrowHi) XFreePixmap (disp, downArrowHi);
269#endif 263#endif
270#if defined(MENUBAR) || defined(RXVT_SCROLLBAR) 264#ifdef RXVT_SCROLLBAR
271 if (topShadowGC) XFreeGC (disp, topShadowGC); 265 if (topShadowGC) XFreeGC (disp, topShadowGC);
272 if (botShadowGC) XFreeGC (disp, botShadowGC); 266 if (botShadowGC) XFreeGC (disp, botShadowGC);
273 if (scrollbarGC) XFreeGC (disp, scrollbarGC); 267 if (scrollbarGC) XFreeGC (disp, scrollbarGC);
274#endif 268#endif
275 if (gc) XFreeGC (disp, gc); 269 if (gc) XFreeGC (disp, gc);
276 270
277#if defined(MENUBAR) && (MENUBAR_MAX > 1)
278 delete menuBar.drawable;
279 //if (menuBar.win)
280 // XDestroyWindow (disp, menuBar.win);
281#endif
282 delete drawable; 271 delete drawable;
283 // destroy all windows 272 // destroy all windows
284 if (parent[0]) 273 if (parent[0])
285 XDestroyWindow (disp, parent[0]); 274 XDestroyWindow (disp, parent[0]);
286 } 275 }
287 276
288 // TODO: free pixcolours, colours should become part of rxvt_display 277 // TODO: free pixcolours, colours should become part of rxvt_display
289
290 delete pix_colors_focused; 278 delete pix_colors_focused;
291#if OFF_FOCUS_FADING 279#if OFF_FOCUS_FADING
292 delete pix_colors_unfocused; 280 delete pix_colors_unfocused;
293#endif 281#endif
294 282
343 im_ev.stop (display); 331 im_ev.stop (display);
344#endif 332#endif
345#if HAVE_SCROLLBARS 333#if HAVE_SCROLLBARS
346 scrollbar_ev.stop (display); 334 scrollbar_ev.stop (display);
347#endif 335#endif
348#if MENUBAR
349 menubar_ev.stop (display);
350#endif
351#if TRANSPARENT 336#if TRANSPARENT
352 rootwin_ev.stop (display); 337 rootwin_ev.stop (display);
353#endif 338#endif
354 incr_ev.stop (); 339 incr_ev.stop ();
355 termwin_ev.stop (display); 340 termwin_ev.stop (display);
378} 363}
379 364
380void 365void
381rxvt_term::destroy_cb (time_watcher &w) 366rxvt_term::destroy_cb (time_watcher &w)
382{ 367{
383 SET_R (this); 368 make_current ();
384 369
385 delete this; 370 delete this;
386} 371}
387 372
388/*----------------------------------------------------------------------*/ 373/*----------------------------------------------------------------------*/
479/*----------------------------------------------------------------------*/ 464/*----------------------------------------------------------------------*/
480bool 465bool
481rxvt_term::init (int argc, const char *const *argv) 466rxvt_term::init (int argc, const char *const *argv)
482{ 467{
483 SET_R (this); 468 SET_R (this);
484 TEMP_ENV; // few things in X do not call setlocale :(
485
486 set_locale (""); 469 set_locale ("");
470 set_environ (envv); // few things in X do not call setlocale :(
487 471
488 if (!init_vars ()) 472 if (!init_vars ())
489 return false; 473 return false;
490 474
491 init_secondary (); 475 init_secondary ();
494 478
495#ifdef KEYSYM_RESOURCE 479#ifdef KEYSYM_RESOURCE
496 keyboard->register_done (); 480 keyboard->register_done ();
497#endif 481#endif
498 482
499#if MENUBAR_MAX
500 menubar_read (rs[Rs_menu]);
501#endif
502#ifdef HAVE_SCROLLBARS 483#ifdef HAVE_SCROLLBARS
503 if (OPTION (Opt_scrollBar)) 484 if (OPTION (Opt_scrollBar))
504 scrollBar.setIdle (); /* set existence for size calculations */ 485 scrollBar.setIdle (); /* set existence for size calculations */
505#endif 486#endif
506 487
523 rs[Rs_perl_lib] = 0; 504 rs[Rs_perl_lib] = 0;
524 rs[Rs_perl_eval] = 0; 505 rs[Rs_perl_eval] = 0;
525 } 506 }
526 } 507 }
527#endif 508#endif
528 rxvt_perl.init (); 509 rxvt_perl.init (this);
529 HOOK_INVOKE ((this, HOOK_INIT, DT_END)); 510 HOOK_INVOKE ((this, HOOK_INIT, DT_END));
530 } 511 }
531#endif 512#endif
532 513
533 create_windows (argc, argv); 514 create_windows (argc, argv);
543#endif 524#endif
544 525
545#ifdef HAVE_SCROLLBARS 526#ifdef HAVE_SCROLLBARS
546 if (OPTION (Opt_scrollBar)) 527 if (OPTION (Opt_scrollBar))
547 resize_scrollbar (); /* create and map scrollbar */ 528 resize_scrollbar (); /* create and map scrollbar */
548#endif
549#if (MENUBAR_MAX)
550 if (menubar_visible ())
551 XMapWindow (disp, menuBar.win);
552#endif 529#endif
553#ifdef TRANSPARENT 530#ifdef TRANSPARENT
554 if (OPTION (Opt_transparent)) 531 if (OPTION (Opt_transparent))
555 { 532 {
556 XSelectInput (disp, display->root, PropertyChangeMask); 533 XSelectInput (disp, display->root, PropertyChangeMask);
616 sw_int (this, &sig_handlers::sig_term) 593 sw_int (this, &sig_handlers::sig_term)
617 { 594 {
618 } 595 }
619} sig_handlers; 596} sig_handlers;
620 597
598char **rxvt_environ; // startup environment
599
621void 600void
622rxvt_init () 601rxvt_init ()
623{ 602{
603 rxvt_environ = environ;
604
624 /* 605 /*
625 * Save and then give up any super-user privileges 606 * Save and then give up any super-user privileges
626 * If we need privileges in any area then we must specifically request it. 607 * If we need privileges in any area then we must specifically request it.
627 * We should only need to be root in these cases: 608 * We should only need to be root in these cases:
628 * 1. write utmp entries on some systems 609 * 1. write utmp entries on some systems
704 case IGNORE: 685 case IGNORE:
705 /* 686 /*
706 * change effective uid/gid - not real uid/gid - so we can switch 687 * change effective uid/gid - not real uid/gid - so we can switch
707 * back to root later, as required 688 * back to root later, as required
708 */ 689 */
690 setegid (getgid ());
709 seteuid (getuid ()); 691 seteuid (getuid ());
710 setegid (getgid ());
711 break; 692 break;
712 case SAVE: 693 case SAVE:
694 saved_egid = getegid ();
713 saved_euid = geteuid (); 695 saved_euid = geteuid ();
714 saved_egid = getegid ();
715 break; 696 break;
716 case RESTORE: 697 case RESTORE:
698 setegid (saved_egid);
717 seteuid (saved_euid); 699 seteuid (saved_euid);
718 setegid (saved_egid);
719 break; 700 break;
720 } 701 }
721# else 702# else
722 switch (action) 703 switch (action)
723 { 704 {
724 case IGNORE: 705 case IGNORE:
706 setgid (getgid ());
725 setuid (getuid ()); 707 setuid (getuid ());
726 setgid (getgid ());
727 /* FALLTHROUGH */ 708 /* FALLTHROUGH */
728 case SAVE: 709 case SAVE:
729 /* FALLTHROUGH */ 710 /* FALLTHROUGH */
730 case RESTORE: 711 case RESTORE:
731 break; 712 break;
736 717
737#ifdef UTMP_SUPPORT 718#ifdef UTMP_SUPPORT
738void 719void
739rxvt_term::privileged_utmp (rxvt_privaction action) 720rxvt_term::privileged_utmp (rxvt_privaction action)
740{ 721{
741 if (OPTION (Opt_utmpInhibit) 722 if (OPTION (Opt_utmpInhibit))
742 || !pty.name || !*pty.name)
743 return; 723 return;
744 724
745 rxvt_privileges (RESTORE); 725 rxvt_privileges (RESTORE);
746 726
747 if (action == SAVE) 727 if (action == SAVE)
748 makeutent (pty.name, rs[Rs_display_name]); 728 pty.login (cmd_pid, OPTION (Opt_loginShell), rs[Rs_display_name]);
749 else 729 else
750 cleanutent (); 730 pty.logout ();
751 731
752 rxvt_privileges (IGNORE); 732 rxvt_privileges (IGNORE);
753} 733}
754#endif 734#endif
755 735
760 */ 740 */
761void 741void
762rxvt_term::window_calc (unsigned int newwidth, unsigned int newheight) 742rxvt_term::window_calc (unsigned int newwidth, unsigned int newheight)
763{ 743{
764 short recalc_x, recalc_y; 744 short recalc_x, recalc_y;
765 int x, y, sb_w, mb_h, flags; 745 int x, y, sb_w, flags;
766 unsigned int w, h; 746 unsigned int w, h;
767 unsigned int max_width, max_height; 747 unsigned int max_width, max_height;
768 dDisp; 748 dDisp;
769 749
770 D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", 750 D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d",
831 max_width = MAX_COLS * fwidth; 811 max_width = MAX_COLS * fwidth;
832 max_height = MAX_ROWS * fheight; 812 max_height = MAX_ROWS * fheight;
833 813
834 szHint.base_width = szHint.base_height = 2 * int_bwidth; 814 szHint.base_width = szHint.base_height = 2 * int_bwidth;
835 815
836 sb_w = mb_h = 0; 816 sb_w = 0;
837 window_vt_x = window_vt_y = int_bwidth; 817 window_vt_x = window_vt_y = int_bwidth;
838 818
839 if (scrollbar_visible ()) 819 if (scrollBar.state)
840 { 820 {
841 sb_w = scrollbar_TotalWidth (); 821 sb_w = scrollbar_TotalWidth ();
842 szHint.base_width += sb_w; 822 szHint.base_width += sb_w;
843 if (!OPTION (Opt_scrollBar_right)) 823 if (!OPTION (Opt_scrollBar_right))
844 window_vt_x += sb_w; 824 window_vt_x += sb_w;
845 } 825 }
846 826
847 if (menubar_visible ())
848 {
849 mb_h = menuBar_TotalHeight ();
850 szHint.base_height += mb_h;
851 window_vt_y += mb_h;
852 }
853
854 szHint.width_inc = fwidth; 827 szHint.width_inc = fwidth;
855 szHint.height_inc = fheight; 828 szHint.height_inc = fheight;
856 szHint.min_width = szHint.base_width + szHint.width_inc; 829 szHint.min_width = szHint.base_width + szHint.width_inc;
857 szHint.min_height = szHint.base_height + szHint.height_inc; 830 szHint.min_height = szHint.base_height + szHint.height_inc;
858 831
876 { 849 {
877 min_it (height, max_height); 850 min_it (height, max_height);
878 szHint.height = szHint.base_height + height; 851 szHint.height = szHint.base_height + height;
879 } 852 }
880 853
881 if (scrollbar_visible () && OPTION (Opt_scrollBar_right)) 854 if (scrollBar.state && OPTION (Opt_scrollBar_right))
882 window_sb_x = szHint.width - sb_w; 855 window_sb_x = szHint.width - sb_w;
883 856
884 if (recalc_x) 857 if (recalc_x)
885 szHint.x += DisplayWidth (disp, display->screen) - szHint.width - 2 * ext_bwidth; 858 szHint.x += DisplayWidth (disp, display->screen) - szHint.width - 2 * ext_bwidth;
886 if (recalc_y) 859 if (recalc_y)
1241 1214
1242 fix_screen = ncol != prev_ncol || nrow != prev_nrow; 1215 fix_screen = ncol != prev_ncol || nrow != prev_nrow;
1243 1216
1244 if (fix_screen || newwidth != old_width || newheight != old_height) 1217 if (fix_screen || newwidth != old_width || newheight != old_height)
1245 { 1218 {
1246 if (scrollbar_visible ()) 1219 if (scrollBar.state)
1247 { 1220 {
1248 XMoveResizeWindow (disp, scrollBar.win, 1221 XMoveResizeWindow (disp, scrollBar.win,
1249 window_sb_x, 0, 1222 window_sb_x, 0,
1250 scrollbar_TotalWidth (), szHint.height); 1223 scrollbar_TotalWidth (), szHint.height);
1251 resize_scrollbar (); 1224 resize_scrollbar ();
1252 } 1225 }
1253
1254 if (menubar_visible ())
1255 XMoveResizeWindow (disp, menuBar.win,
1256 window_vt_x, 0,
1257 width, menuBar_TotalHeight ());
1258 1226
1259 XMoveResizeWindow (disp, vt, 1227 XMoveResizeWindow (disp, vt,
1260 window_vt_x, window_vt_y, 1228 window_vt_x, window_vt_y,
1261 width, height); 1229 width, height);
1262 1230
1447 unsigned long fg, bg; 1415 unsigned long fg, bg;
1448 const char *p; 1416 const char *p;
1449 char **s; 1417 char **s;
1450 XIMStyles *xim_styles; 1418 XIMStyles *xim_styles;
1451 1419
1452 TEMP_ENV; 1420 set_environ (envv);
1453 1421
1454 if (! ((p = XSetLocaleModifiers (modifiers)) && *p)) 1422 if (! ((p = XSetLocaleModifiers (modifiers)) && *p))
1455 return false; 1423 return false;
1456 1424
1457 D_MAIN ((stderr, "rxvt_IM_get_IC ()")); 1425 D_MAIN ((stderr, "rxvt_IM_get_IC ()"));
1623 int i; 1591 int i;
1624 const char *p; 1592 const char *p;
1625 char **s; 1593 char **s;
1626 char buf[IMBUFSIZ]; 1594 char buf[IMBUFSIZ];
1627 1595
1628 SET_R (this); 1596 make_current ();
1629 1597
1630 im_destroy (); 1598 im_destroy ();
1631 1599
1632 D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()")); 1600 D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()"));
1633 if (Input_Context) 1601 if (Input_Context)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines