… | |
… | |
89 | rxvt_pop_locale () |
89 | rxvt_pop_locale () |
90 | { |
90 | { |
91 | rxvt_set_locale (savelocale); |
91 | rxvt_set_locale (savelocale); |
92 | } |
92 | } |
93 | |
93 | |
|
|
94 | void |
|
|
95 | rxvt_term::make_current () const |
|
|
96 | { |
|
|
97 | SET_R (this); |
|
|
98 | rxvt_set_locale (locale); |
|
|
99 | set_environ (envv); |
|
|
100 | } |
|
|
101 | |
94 | #if ENABLE_COMBINING |
102 | #if ENABLE_COMBINING |
95 | class rxvt_composite_vec rxvt_composite; |
103 | class rxvt_composite_vec rxvt_composite; |
96 | |
104 | |
97 | text_t rxvt_composite_vec::compose (unicode_t c1, unicode_t c2) |
105 | text_t rxvt_composite_vec::compose (unicode_t c1, unicode_t c2) |
98 | { |
106 | { |
… | |
… | |
284 | if (parent[0]) |
292 | if (parent[0]) |
285 | XDestroyWindow (disp, parent[0]); |
293 | XDestroyWindow (disp, parent[0]); |
286 | } |
294 | } |
287 | |
295 | |
288 | // TODO: free pixcolours, colours should become part of rxvt_display |
296 | // TODO: free pixcolours, colours should become part of rxvt_display |
289 | |
|
|
290 | delete pix_colors_focused; |
297 | delete pix_colors_focused; |
291 | #if OFF_FOCUS_FADING |
298 | #if OFF_FOCUS_FADING |
292 | delete pix_colors_unfocused; |
299 | delete pix_colors_unfocused; |
293 | #endif |
|
|
294 | #if USE_XGETDEFAULT |
|
|
295 | XrmDestroyDatabase (xrmdatabase); |
|
|
296 | #endif |
300 | #endif |
297 | |
301 | |
298 | displays.put (display); |
302 | displays.put (display); |
299 | |
303 | |
300 | scr_release (); |
304 | scr_release (); |
… | |
… | |
381 | } |
385 | } |
382 | |
386 | |
383 | void |
387 | void |
384 | rxvt_term::destroy_cb (time_watcher &w) |
388 | rxvt_term::destroy_cb (time_watcher &w) |
385 | { |
389 | { |
386 | SET_R (this); |
390 | make_current (); |
387 | |
391 | |
388 | delete this; |
392 | delete this; |
389 | } |
393 | } |
390 | |
394 | |
391 | /*----------------------------------------------------------------------*/ |
395 | /*----------------------------------------------------------------------*/ |
… | |
… | |
482 | /*----------------------------------------------------------------------*/ |
486 | /*----------------------------------------------------------------------*/ |
483 | bool |
487 | bool |
484 | rxvt_term::init (int argc, const char *const *argv) |
488 | rxvt_term::init (int argc, const char *const *argv) |
485 | { |
489 | { |
486 | SET_R (this); |
490 | SET_R (this); |
487 | |
|
|
488 | set_locale (""); |
491 | set_locale (""); |
|
|
492 | set_environ (envv); // few things in X do not call setlocale :( |
489 | |
493 | |
490 | if (!init_vars ()) |
494 | if (!init_vars ()) |
491 | return false; |
495 | return false; |
492 | |
496 | |
493 | init_secondary (); |
497 | init_secondary (); |
… | |
… | |
526 | rs[Rs_perl_eval] = 0; |
530 | rs[Rs_perl_eval] = 0; |
527 | } |
531 | } |
528 | } |
532 | } |
529 | #endif |
533 | #endif |
530 | rxvt_perl.init (); |
534 | rxvt_perl.init (); |
|
|
535 | setlocale (LC_CTYPE, curlocale); // perl init destroys current locale |
531 | HOOK_INVOKE ((this, HOOK_INIT, DT_END)); |
536 | HOOK_INVOKE ((this, HOOK_INIT, DT_END)); |
532 | } |
537 | } |
533 | #endif |
538 | #endif |
534 | |
539 | |
535 | create_windows (argc, argv); |
540 | create_windows (argc, argv); |
536 | |
541 | |
537 | dDisp; |
542 | dDisp; |
538 | |
543 | |
539 | init_xlocale (); |
544 | init_xlocale (); |
540 | |
545 | |
541 | scr_reset (); /* initialize screen */ |
546 | scr_reset (); // initialize screen |
542 | |
547 | |
543 | #if 0 |
548 | #if 0 |
544 | XSynchronize (disp, True); |
549 | XSynchronize (disp, True); |
545 | #endif |
550 | #endif |
546 | |
551 | |
… | |
… | |
618 | sw_int (this, &sig_handlers::sig_term) |
623 | sw_int (this, &sig_handlers::sig_term) |
619 | { |
624 | { |
620 | } |
625 | } |
621 | } sig_handlers; |
626 | } sig_handlers; |
622 | |
627 | |
|
|
628 | char **rxvt_environ; // startup environment |
|
|
629 | |
623 | void |
630 | void |
624 | rxvt_init () |
631 | rxvt_init () |
625 | { |
632 | { |
|
|
633 | rxvt_environ = environ; |
|
|
634 | |
626 | /* |
635 | /* |
627 | * Save and then give up any super-user privileges |
636 | * Save and then give up any super-user privileges |
628 | * If we need privileges in any area then we must specifically request it. |
637 | * If we need privileges in any area then we must specifically request it. |
629 | * We should only need to be root in these cases: |
638 | * We should only need to be root in these cases: |
630 | * 1. write utmp entries on some systems |
639 | * 1. write utmp entries on some systems |
… | |
… | |
645 | |
654 | |
646 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
655 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
647 | // TODO: handle this with exceptions and tolerate the memory loss |
656 | // TODO: handle this with exceptions and tolerate the memory loss |
648 | XSetIOErrorHandler (rxvt_xioerror_handler); |
657 | XSetIOErrorHandler (rxvt_xioerror_handler); |
649 | |
658 | |
650 | #ifdef USE_XGETDEFAULT |
|
|
651 | XrmInitialize (); |
659 | XrmInitialize (); |
652 | #endif |
|
|
653 | } |
660 | } |
654 | |
661 | |
655 | /* ------------------------------------------------------------------------- * |
662 | /* ------------------------------------------------------------------------- * |
656 | * MEMORY ALLOCATION WRAPPERS * |
663 | * MEMORY ALLOCATION WRAPPERS * |
657 | * ------------------------------------------------------------------------- */ |
664 | * ------------------------------------------------------------------------- */ |
… | |
… | |
708 | case IGNORE: |
715 | case IGNORE: |
709 | /* |
716 | /* |
710 | * change effective uid/gid - not real uid/gid - so we can switch |
717 | * change effective uid/gid - not real uid/gid - so we can switch |
711 | * back to root later, as required |
718 | * back to root later, as required |
712 | */ |
719 | */ |
|
|
720 | setegid (getgid ()); |
713 | seteuid (getuid ()); |
721 | seteuid (getuid ()); |
714 | setegid (getgid ()); |
|
|
715 | break; |
722 | break; |
716 | case SAVE: |
723 | case SAVE: |
|
|
724 | saved_egid = getegid (); |
717 | saved_euid = geteuid (); |
725 | saved_euid = geteuid (); |
718 | saved_egid = getegid (); |
|
|
719 | break; |
726 | break; |
720 | case RESTORE: |
727 | case RESTORE: |
|
|
728 | setegid (saved_egid); |
721 | seteuid (saved_euid); |
729 | seteuid (saved_euid); |
722 | setegid (saved_egid); |
|
|
723 | break; |
730 | break; |
724 | } |
731 | } |
725 | # else |
732 | # else |
726 | switch (action) |
733 | switch (action) |
727 | { |
734 | { |
728 | case IGNORE: |
735 | case IGNORE: |
|
|
736 | setgid (getgid ()); |
729 | setuid (getuid ()); |
737 | setuid (getuid ()); |
730 | setgid (getgid ()); |
|
|
731 | /* FALLTHROUGH */ |
738 | /* FALLTHROUGH */ |
732 | case SAVE: |
739 | case SAVE: |
733 | /* FALLTHROUGH */ |
740 | /* FALLTHROUGH */ |
734 | case RESTORE: |
741 | case RESTORE: |
735 | break; |
742 | break; |
… | |
… | |
1451 | unsigned long fg, bg; |
1458 | unsigned long fg, bg; |
1452 | const char *p; |
1459 | const char *p; |
1453 | char **s; |
1460 | char **s; |
1454 | XIMStyles *xim_styles; |
1461 | XIMStyles *xim_styles; |
1455 | |
1462 | |
|
|
1463 | set_environ (envv); |
|
|
1464 | |
1456 | if (! ((p = XSetLocaleModifiers (modifiers)) && *p)) |
1465 | if (! ((p = XSetLocaleModifiers (modifiers)) && *p)) |
1457 | return false; |
1466 | return false; |
1458 | |
1467 | |
1459 | D_MAIN ((stderr, "rxvt_IM_get_IC ()")); |
1468 | D_MAIN ((stderr, "rxvt_IM_get_IC ()")); |
1460 | input_method = display->get_xim (locale, modifiers); |
1469 | input_method = display->get_xim (locale, modifiers); |
… | |
… | |
1625 | int i; |
1634 | int i; |
1626 | const char *p; |
1635 | const char *p; |
1627 | char **s; |
1636 | char **s; |
1628 | char buf[IMBUFSIZ]; |
1637 | char buf[IMBUFSIZ]; |
1629 | |
1638 | |
1630 | SET_R (this); |
1639 | make_current (); |
1631 | |
1640 | |
1632 | im_destroy (); |
1641 | im_destroy (); |
1633 | |
1642 | |
1634 | D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()")); |
1643 | D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()")); |
1635 | if (Input_Context) |
1644 | if (Input_Context) |