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.193 by root, Sat Jan 21 14:25:05 2006 UTC vs.
Revision 1.198 by root, Tue Jan 24 16:57:42 2006 UTC

450 _exit (EXIT_FAILURE); 450 _exit (EXIT_FAILURE);
451} 451}
452 452
453/*----------------------------------------------------------------------*/ 453/*----------------------------------------------------------------------*/
454bool 454bool
455rxvt_term::init (int argc, const char *const *argv) 455rxvt_term::init (int argc, const char *const *argv, stringvec *envv)
456{ 456{
457 this->envv = envv;
458
457 SET_R (this); 459 SET_R (this);
458 set_locale (""); 460 set_locale ("");
459 set_environ (envv); // few things in X do not call setlocale :( 461 set_environ (envv); // few things in X do not call setlocale :(
460 462
461 if (!init_vars ()) 463 if (!init_vars ())
472#ifdef HAVE_SCROLLBARS 474#ifdef HAVE_SCROLLBARS
473 if (OPTION (Opt_scrollBar)) 475 if (OPTION (Opt_scrollBar))
474 scrollBar.setIdle (); /* set existence for size calculations */ 476 scrollBar.setIdle (); /* set existence for size calculations */
475#endif 477#endif
476 478
477 pty = rxvt_new_ptytty (); 479 pty = ptytty::create ();
478 480
479 create_windows (argc, argv); 481 create_windows (argc, argv);
480 482
481 dDisp; 483 dDisp;
482 484
548char **rxvt_environ; // startup environment 550char **rxvt_environ; // startup environment
549 551
550void 552void
551rxvt_init () 553rxvt_init ()
552{ 554{
553 uid_t uid = getuid (); 555 ptytty::init ();
554 gid_t gid = getgid ();
555
556 // before doing anything else, check for setuid/setgid operation,
557 // start the helper process and drop privileges
558 if (uid != geteuid ()
559 || gid != getegid ())
560 {
561#if PTYTTY_HELPER
562 rxvt_ptytty_server ();
563#else
564 rxvt_warn ("running setuid/setgid without pty helper compiled in, continuing unprivileged.\n");
565#endif
566
567 // drop privileges
568#if HAVE_SETRESUID
569 setresgid (gid, gid, gid);
570 setresuid (uid, uid, uid);
571#elif HAVE_SETREUID
572 setregid (gid, gid);
573 setreuid (uid, uid);
574#elif HAVE_SETUID
575 setgid (gid);
576 setuid (uid);
577#endif
578
579 if (uid != geteuid ()
580 || gid != getegid ())
581 rxvt_fatal ("unable to drop privileges, aborting.\n");
582 }
583 556
584 rxvt_environ = environ; 557 rxvt_environ = environ;
585 558
586 signal (SIGHUP, SIG_IGN); 559 signal (SIGHUP, SIG_IGN);
587 signal (SIGPIPE, SIG_IGN); 560 signal (SIGPIPE, SIG_IGN);
1058 * -------------------------------------------------------------------- */ 1031 * -------------------------------------------------------------------- */
1059void 1032void
1060rxvt_term::resize_all_windows (unsigned int newwidth, unsigned int newheight, int ignoreparent) 1033rxvt_term::resize_all_windows (unsigned int newwidth, unsigned int newheight, int ignoreparent)
1061{ 1034{
1062 int fix_screen; 1035 int fix_screen;
1063 int old_width = szHint.width, old_height = szHint.height; 1036 int old_width = szHint.width;
1037 int old_height = szHint.height;
1064 dDisp; 1038 dDisp;
1065 1039
1066 window_calc (newwidth, newheight); 1040 window_calc (newwidth, newheight);
1067 XSetWMNormalHints (disp, parent[0], &szHint); 1041 XSetWMNormalHints (disp, parent[0], &szHint);
1068 1042
1090 { 1064 {
1091 x -= x1; 1065 x -= x1;
1092 y -= y1; 1066 y -= y1;
1093 } 1067 }
1094 1068
1095 x1 = (DisplayWidth (disp, display->screen) - old_width) / 2; 1069 x1 = (DisplayWidth (disp, display->screen) - old_width ) / 2;
1096 y1 = (DisplayHeight (disp, display->screen) - old_height) / 2; 1070 y1 = (DisplayHeight (disp, display->screen) - old_height) / 2;
1097 dx = old_width - szHint.width; 1071 dx = old_width - szHint.width;
1098 dy = old_height - szHint.height; 1072 dy = old_height - szHint.height;
1099 1073
1100 /* Check position of the center of the window */ 1074 /* Check position of the center of the window */
1101 if (x < x1) /* left half */ 1075 if (x < x1) /* left half */
1102 dx = 0; 1076 dx = 0;
1135 resize_pixmap (); 1109 resize_pixmap ();
1136#endif 1110#endif
1137 } 1111 }
1138 1112
1139 if (fix_screen || old_height == 0) 1113 if (fix_screen || old_height == 0)
1140 {
1141 int curr_screen = -1;
1142 int old_ncol = prev_ncol;
1143
1144 /* scr_reset only works on the primary screen */
1145 if (old_height) /* this is not the first time through */
1146 {
1147 unsigned int ocol = ncol;
1148 ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this
1149 curr_screen = scr_change_screen (PRIMARY);
1150 ncol = ocol;
1151 }
1152
1153 scr_reset (); 1114 scr_reset ();
1154
1155 if (curr_screen >= 0) /* this is not the first time through */
1156 {
1157 scr_change_screen (curr_screen);
1158 selection_check (old_ncol != ncol ? 4 : 0);
1159 }
1160 }
1161
1162 old_width = szHint.width;
1163 old_height = szHint.height;
1164 1115
1165#ifdef XPM_BACKGROUND 1116#ifdef XPM_BACKGROUND
1166 if (pixmap) 1117 if (pixmap)
1167 scr_touch (false); 1118 scr_touch (false);
1168#endif 1119#endif
1477 { 1428 {
1478 rxvt_warn ("failed to create input context, continuing without XIM.\n"); 1429 rxvt_warn ("failed to create input context, continuing without XIM.\n");
1479 im_destroy (); 1430 im_destroy ();
1480 return false; 1431 return false;
1481 } 1432 }
1433
1434 if (!XGetICValues (Input_Context, XNFilterEvents, &vt_emask_xim, NULL))
1435 vt_select_input ();
1482 1436
1483 if (input_style & XIMPreeditArea) 1437 if (input_style & XIMPreeditArea)
1484 IMSetStatusPosition (); 1438 IMSetStatusPosition ();
1485 1439
1486 D_MAIN ((stderr, "rxvt_IM_get_IC () - successful connection")); 1440 D_MAIN ((stderr, "rxvt_IM_get_IC () - successful connection"));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines