… | |
… | |
76 | strncpy (curlocale, locale, 128); |
76 | strncpy (curlocale, locale, 128); |
77 | setlocale (LC_CTYPE, curlocale); |
77 | setlocale (LC_CTYPE, curlocale); |
78 | return true; |
78 | return true; |
79 | } |
79 | } |
80 | |
80 | |
81 | bool |
81 | void |
82 | rxvt_push_locale (const char *locale) |
82 | rxvt_push_locale (const char *locale) |
83 | { |
83 | { |
84 | strcpy (savelocale, curlocale); |
84 | strcpy (savelocale, curlocale); |
85 | rxvt_set_locale (locale); |
85 | rxvt_set_locale (locale); |
86 | } |
86 | } |
… | |
… | |
284 | if (parent[0]) |
284 | if (parent[0]) |
285 | XDestroyWindow (disp, parent[0]); |
285 | XDestroyWindow (disp, parent[0]); |
286 | } |
286 | } |
287 | |
287 | |
288 | // TODO: free pixcolours, colours should become part of rxvt_display |
288 | // TODO: free pixcolours, colours should become part of rxvt_display |
289 | |
|
|
290 | delete pix_colors_focused; |
289 | delete pix_colors_focused; |
291 | #if OFF_FOCUS_FADING |
290 | #if OFF_FOCUS_FADING |
292 | delete pix_colors_unfocused; |
291 | delete pix_colors_unfocused; |
293 | #endif |
|
|
294 | #if USE_XGETDEFAULT |
|
|
295 | XrmDestroyDatabase (xrmdatabase); |
|
|
296 | #endif |
292 | #endif |
297 | |
293 | |
298 | displays.put (display); |
294 | displays.put (display); |
299 | |
295 | |
300 | scr_release (); |
296 | scr_release (); |
… | |
… | |
381 | } |
377 | } |
382 | |
378 | |
383 | void |
379 | void |
384 | rxvt_term::destroy_cb (time_watcher &w) |
380 | rxvt_term::destroy_cb (time_watcher &w) |
385 | { |
381 | { |
386 | SET_R (this); |
382 | make_current (); |
387 | |
383 | |
388 | delete this; |
384 | delete this; |
389 | } |
385 | } |
390 | |
386 | |
391 | /*----------------------------------------------------------------------*/ |
387 | /*----------------------------------------------------------------------*/ |
… | |
… | |
482 | /*----------------------------------------------------------------------*/ |
478 | /*----------------------------------------------------------------------*/ |
483 | bool |
479 | bool |
484 | rxvt_term::init (int argc, const char *const *argv) |
480 | rxvt_term::init (int argc, const char *const *argv) |
485 | { |
481 | { |
486 | SET_R (this); |
482 | SET_R (this); |
487 | |
|
|
488 | set_locale (""); |
483 | set_locale (""); |
|
|
484 | set_environ (envv); // few things in X do not call setlocale :( |
489 | |
485 | |
490 | if (!init_vars ()) |
486 | if (!init_vars ()) |
491 | return false; |
487 | return false; |
492 | |
488 | |
493 | init_secondary (); |
489 | init_secondary (); |
… | |
… | |
525 | rs[Rs_perl_lib] = 0; |
521 | rs[Rs_perl_lib] = 0; |
526 | rs[Rs_perl_eval] = 0; |
522 | rs[Rs_perl_eval] = 0; |
527 | } |
523 | } |
528 | } |
524 | } |
529 | #endif |
525 | #endif |
530 | rxvt_perl.init (); |
526 | rxvt_perl.init (this); |
531 | HOOK_INVOKE ((this, HOOK_INIT, DT_END)); |
527 | HOOK_INVOKE ((this, HOOK_INIT, DT_END)); |
532 | } |
528 | } |
533 | #endif |
529 | #endif |
534 | |
530 | |
535 | create_windows (argc, argv); |
531 | create_windows (argc, argv); |
536 | |
532 | |
537 | dDisp; |
533 | dDisp; |
538 | |
534 | |
539 | init_xlocale (); |
535 | init_xlocale (); |
540 | |
536 | |
541 | scr_reset (); /* initialize screen */ |
537 | scr_reset (); // initialize screen |
542 | |
538 | |
543 | #if 0 |
539 | #if 0 |
544 | XSynchronize (disp, True); |
540 | XSynchronize (disp, True); |
545 | #endif |
541 | #endif |
546 | |
542 | |
… | |
… | |
618 | sw_int (this, &sig_handlers::sig_term) |
614 | sw_int (this, &sig_handlers::sig_term) |
619 | { |
615 | { |
620 | } |
616 | } |
621 | } sig_handlers; |
617 | } sig_handlers; |
622 | |
618 | |
|
|
619 | char **rxvt_environ; // startup environment |
|
|
620 | |
623 | void |
621 | void |
624 | rxvt_init () |
622 | rxvt_init () |
625 | { |
623 | { |
|
|
624 | rxvt_environ = environ; |
|
|
625 | |
626 | /* |
626 | /* |
627 | * Save and then give up any super-user privileges |
627 | * Save and then give up any super-user privileges |
628 | * If we need privileges in any area then we must specifically request it. |
628 | * If we need privileges in any area then we must specifically request it. |
629 | * We should only need to be root in these cases: |
629 | * We should only need to be root in these cases: |
630 | * 1. write utmp entries on some systems |
630 | * 1. write utmp entries on some systems |
… | |
… | |
645 | |
645 | |
646 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
646 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
647 | // TODO: handle this with exceptions and tolerate the memory loss |
647 | // TODO: handle this with exceptions and tolerate the memory loss |
648 | XSetIOErrorHandler (rxvt_xioerror_handler); |
648 | XSetIOErrorHandler (rxvt_xioerror_handler); |
649 | |
649 | |
650 | #ifdef USE_XGETDEFAULT |
|
|
651 | XrmInitialize (); |
650 | XrmInitialize (); |
652 | #endif |
|
|
653 | } |
651 | } |
654 | |
652 | |
655 | /* ------------------------------------------------------------------------- * |
653 | /* ------------------------------------------------------------------------- * |
656 | * MEMORY ALLOCATION WRAPPERS * |
654 | * MEMORY ALLOCATION WRAPPERS * |
657 | * ------------------------------------------------------------------------- */ |
655 | * ------------------------------------------------------------------------- */ |
… | |
… | |
708 | case IGNORE: |
706 | case IGNORE: |
709 | /* |
707 | /* |
710 | * change effective uid/gid - not real uid/gid - so we can switch |
708 | * change effective uid/gid - not real uid/gid - so we can switch |
711 | * back to root later, as required |
709 | * back to root later, as required |
712 | */ |
710 | */ |
|
|
711 | setegid (getgid ()); |
713 | seteuid (getuid ()); |
712 | seteuid (getuid ()); |
714 | setegid (getgid ()); |
|
|
715 | break; |
713 | break; |
716 | case SAVE: |
714 | case SAVE: |
|
|
715 | saved_egid = getegid (); |
717 | saved_euid = geteuid (); |
716 | saved_euid = geteuid (); |
718 | saved_egid = getegid (); |
|
|
719 | break; |
717 | break; |
720 | case RESTORE: |
718 | case RESTORE: |
|
|
719 | setegid (saved_egid); |
721 | seteuid (saved_euid); |
720 | seteuid (saved_euid); |
722 | setegid (saved_egid); |
|
|
723 | break; |
721 | break; |
724 | } |
722 | } |
725 | # else |
723 | # else |
726 | switch (action) |
724 | switch (action) |
727 | { |
725 | { |
728 | case IGNORE: |
726 | case IGNORE: |
|
|
727 | setgid (getgid ()); |
729 | setuid (getuid ()); |
728 | setuid (getuid ()); |
730 | setgid (getgid ()); |
|
|
731 | /* FALLTHROUGH */ |
729 | /* FALLTHROUGH */ |
732 | case SAVE: |
730 | case SAVE: |
733 | /* FALLTHROUGH */ |
731 | /* FALLTHROUGH */ |
734 | case RESTORE: |
732 | case RESTORE: |
735 | break; |
733 | break; |
… | |
… | |
1451 | unsigned long fg, bg; |
1449 | unsigned long fg, bg; |
1452 | const char *p; |
1450 | const char *p; |
1453 | char **s; |
1451 | char **s; |
1454 | XIMStyles *xim_styles; |
1452 | XIMStyles *xim_styles; |
1455 | |
1453 | |
|
|
1454 | set_environ (envv); |
|
|
1455 | |
1456 | if (! ((p = XSetLocaleModifiers (modifiers)) && *p)) |
1456 | if (! ((p = XSetLocaleModifiers (modifiers)) && *p)) |
1457 | return false; |
1457 | return false; |
1458 | |
1458 | |
1459 | D_MAIN ((stderr, "rxvt_IM_get_IC ()")); |
1459 | D_MAIN ((stderr, "rxvt_IM_get_IC ()")); |
1460 | input_method = display->get_xim (locale, modifiers); |
1460 | input_method = display->get_xim (locale, modifiers); |
… | |
… | |
1625 | int i; |
1625 | int i; |
1626 | const char *p; |
1626 | const char *p; |
1627 | char **s; |
1627 | char **s; |
1628 | char buf[IMBUFSIZ]; |
1628 | char buf[IMBUFSIZ]; |
1629 | |
1629 | |
1630 | SET_R (this); |
1630 | make_current (); |
1631 | |
1631 | |
1632 | im_destroy (); |
1632 | im_destroy (); |
1633 | |
1633 | |
1634 | D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()")); |
1634 | D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()")); |
1635 | if (Input_Context) |
1635 | if (Input_Context) |