… | |
… | |
11 | * Copyright (c) 1997 mj olesen <olesen@me.QueensU.CA> |
11 | * Copyright (c) 1997 mj olesen <olesen@me.QueensU.CA> |
12 | * - extensive modifications |
12 | * - extensive modifications |
13 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
13 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
14 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
14 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
15 | * - extensive modifications |
15 | * - extensive modifications |
16 | * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com> |
16 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
17 | * |
17 | * |
18 | * This program is free software; you can redistribute it and/or modify |
18 | * This program is free software; you can redistribute it and/or modify |
19 | * it under the terms of the GNU General Public License as published by |
19 | * it under the terms of the GNU General Public License as published by |
20 | * the Free Software Foundation; either version 2 of the License, or |
20 | * the Free Software Foundation; either version 2 of the License, or |
21 | * (at your option) any later version. |
21 | * (at your option) any later version. |
… | |
… | |
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 |
51 | #if (defined(HAVE_SETEUID) || defined(HAVE_SETREUID)) && !defined(__CYGWIN32__) |
48 | # include "keyboard.h" |
52 | static uid_t saved_euid; |
|
|
53 | static gid_t saved_egid; |
49 | #endif |
54 | #endif |
|
|
55 | |
|
|
56 | bool |
|
|
57 | rxvt_tainted () |
|
|
58 | { |
|
|
59 | #if (defined(HAVE_SETEUID) || defined(HAVE_SETREUID)) && !defined(__CYGWIN32__) |
|
|
60 | return getuid () != saved_euid || getgid () != saved_egid; |
|
|
61 | #else |
|
|
62 | return false; |
|
|
63 | #endif |
|
|
64 | } |
50 | |
65 | |
51 | vector<rxvt_term *> rxvt_term::termlist; |
66 | vector<rxvt_term *> rxvt_term::termlist; |
52 | |
67 | |
53 | static char curlocale[128]; |
68 | static char curlocale[128], savelocale[128]; |
54 | |
69 | |
55 | bool |
70 | bool |
56 | rxvt_set_locale (const char *locale) |
71 | rxvt_set_locale (const char *locale) |
57 | { |
72 | { |
58 | if (!locale || !strncmp (locale, curlocale, 128)) |
73 | if (!locale || !strncmp (locale, curlocale, 128)) |
59 | return false; |
74 | return false; |
60 | |
75 | |
61 | strncpy (curlocale, locale, 128); |
76 | strncpy (curlocale, locale, 128); |
62 | setlocale (LC_CTYPE, curlocale); |
77 | setlocale (LC_CTYPE, curlocale); |
63 | return true; |
78 | return true; |
|
|
79 | } |
|
|
80 | |
|
|
81 | void |
|
|
82 | rxvt_push_locale (const char *locale) |
|
|
83 | { |
|
|
84 | strcpy (savelocale, curlocale); |
|
|
85 | rxvt_set_locale (locale); |
|
|
86 | } |
|
|
87 | |
|
|
88 | void |
|
|
89 | rxvt_pop_locale () |
|
|
90 | { |
|
|
91 | rxvt_set_locale (savelocale); |
|
|
92 | } |
|
|
93 | |
|
|
94 | void |
|
|
95 | rxvt_term::make_current () const |
|
|
96 | { |
|
|
97 | SET_R (this); |
|
|
98 | rxvt_set_locale (locale); |
|
|
99 | set_environ (envv); |
64 | } |
100 | } |
65 | |
101 | |
66 | #if ENABLE_COMBINING |
102 | #if ENABLE_COMBINING |
67 | class rxvt_composite_vec rxvt_composite; |
103 | class rxvt_composite_vec rxvt_composite; |
68 | |
104 | |
… | |
… | |
193 | pty.put (); |
229 | pty.put (); |
194 | } |
230 | } |
195 | |
231 | |
196 | rxvt_term::~rxvt_term () |
232 | rxvt_term::~rxvt_term () |
197 | { |
233 | { |
|
|
234 | HOOK_INVOKE ((this, HOOK_DESTROY, DT_END)); |
|
|
235 | |
198 | termlist.erase (find (termlist.begin (), termlist.end(), this)); |
236 | termlist.erase (find (termlist.begin (), termlist.end(), this)); |
199 | |
237 | |
200 | emergency_cleanup (); |
238 | emergency_cleanup (); |
201 | |
239 | |
202 | #if ENABLE_STYLES |
240 | #if ENABLE_STYLES |
… | |
… | |
254 | if (parent[0]) |
292 | if (parent[0]) |
255 | XDestroyWindow (disp, parent[0]); |
293 | XDestroyWindow (disp, parent[0]); |
256 | } |
294 | } |
257 | |
295 | |
258 | // TODO: free pixcolours, colours should become part of rxvt_display |
296 | // TODO: free pixcolours, colours should become part of rxvt_display |
259 | |
|
|
260 | delete pix_colors_focused; |
297 | delete pix_colors_focused; |
261 | #if OFF_FOCUS_FADING |
298 | #if OFF_FOCUS_FADING |
262 | delete pix_colors_unfocused; |
299 | delete pix_colors_unfocused; |
263 | #endif |
300 | #endif |
264 | |
301 | |
… | |
… | |
287 | delete keyboard; |
324 | delete keyboard; |
288 | #endif |
325 | #endif |
289 | } |
326 | } |
290 | |
327 | |
291 | void |
328 | void |
|
|
329 | rxvt_term::child_exit () |
|
|
330 | { |
|
|
331 | cmd_pid = 0; |
|
|
332 | |
|
|
333 | if (!OPTION (Opt_hold)) |
|
|
334 | destroy (); |
|
|
335 | } |
|
|
336 | |
|
|
337 | void |
292 | rxvt_term::destroy () |
338 | rxvt_term::destroy () |
293 | { |
339 | { |
294 | if (destroy_ev.active) |
340 | if (destroy_ev.active) |
295 | return; |
341 | return; |
296 | |
342 | |
… | |
… | |
339 | } |
385 | } |
340 | |
386 | |
341 | void |
387 | void |
342 | rxvt_term::destroy_cb (time_watcher &w) |
388 | rxvt_term::destroy_cb (time_watcher &w) |
343 | { |
389 | { |
344 | SET_R (this); |
390 | make_current (); |
345 | |
391 | |
346 | delete this; |
392 | delete this; |
347 | } |
393 | } |
348 | |
394 | |
349 | /*----------------------------------------------------------------------*/ |
395 | /*----------------------------------------------------------------------*/ |
… | |
… | |
440 | /*----------------------------------------------------------------------*/ |
486 | /*----------------------------------------------------------------------*/ |
441 | bool |
487 | bool |
442 | rxvt_term::init (int argc, const char *const *argv) |
488 | rxvt_term::init (int argc, const char *const *argv) |
443 | { |
489 | { |
444 | SET_R (this); |
490 | SET_R (this); |
445 | |
|
|
446 | set_locale (""); |
491 | set_locale (""); |
|
|
492 | set_environ (envv); // few things in X do not call setlocale :( |
447 | |
493 | |
448 | if (!init_vars ()) |
494 | if (!init_vars ()) |
449 | return false; |
495 | return false; |
450 | |
496 | |
451 | init_secondary (); |
497 | init_secondary (); |
… | |
… | |
458 | |
504 | |
459 | #if MENUBAR_MAX |
505 | #if MENUBAR_MAX |
460 | menubar_read (rs[Rs_menu]); |
506 | menubar_read (rs[Rs_menu]); |
461 | #endif |
507 | #endif |
462 | #ifdef HAVE_SCROLLBARS |
508 | #ifdef HAVE_SCROLLBARS |
463 | if (options & Opt_scrollBar) |
509 | if (OPTION (Opt_scrollBar)) |
464 | scrollBar.setIdle (); /* set existence for size calculations */ |
510 | scrollBar.setIdle (); /* set existence for size calculations */ |
465 | #endif |
511 | #endif |
466 | |
512 | |
|
|
513 | #if ENABLE_PERL |
|
|
514 | if (!rs[Rs_perl_ext_1]) |
|
|
515 | rs[Rs_perl_ext_1] = "default"; |
|
|
516 | |
|
|
517 | if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) |
|
|
518 | || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2]) |
|
|
519 | || (rs[Rs_perl_eval] && *rs[Rs_perl_eval])) |
|
|
520 | { |
|
|
521 | #if (defined(HAVE_SETEUID) || defined(HAVE_SETREUID)) && !defined(__CYGWIN32__) |
|
|
522 | // ignore some perl-related arguments if some bozo installed us set[ug]id |
|
|
523 | if (rxvt_tainted ()) |
|
|
524 | { |
|
|
525 | if ((rs[Rs_perl_lib] && *rs[Rs_perl_lib]) |
|
|
526 | || (rs[Rs_perl_eval] && *rs[Rs_perl_eval])) |
|
|
527 | { |
|
|
528 | rxvt_warn ("running with elevated privileges: ignoring perl-lib and perl-eval.\n"); |
|
|
529 | rs[Rs_perl_lib] = 0; |
|
|
530 | rs[Rs_perl_eval] = 0; |
|
|
531 | } |
|
|
532 | } |
|
|
533 | #endif |
|
|
534 | rxvt_perl.init (); |
|
|
535 | setlocale (LC_CTYPE, curlocale); // perl init destroys current locale |
|
|
536 | HOOK_INVOKE ((this, HOOK_INIT, DT_END)); |
|
|
537 | } |
|
|
538 | #endif |
|
|
539 | |
467 | create_windows (argc, argv); |
540 | create_windows (argc, argv); |
468 | |
541 | |
469 | dDisp; |
542 | dDisp; |
470 | |
543 | |
471 | init_xlocale (); |
544 | init_xlocale (); |
472 | |
545 | |
473 | scr_reset (); /* initialize screen */ |
546 | scr_reset (); // initialize screen |
474 | |
547 | |
475 | #if 0 |
548 | #if 0 |
476 | XSynchronize (disp, True); |
549 | XSynchronize (disp, True); |
477 | #endif |
550 | #endif |
478 | |
551 | |
479 | #ifdef HAVE_SCROLLBARS |
552 | #ifdef HAVE_SCROLLBARS |
480 | if (options & Opt_scrollBar) |
553 | if (OPTION (Opt_scrollBar)) |
481 | resize_scrollbar (); /* create and map scrollbar */ |
554 | resize_scrollbar (); /* create and map scrollbar */ |
482 | #endif |
555 | #endif |
483 | #if (MENUBAR_MAX) |
556 | #if (MENUBAR_MAX) |
484 | if (menubar_visible ()) |
557 | if (menubar_visible ()) |
485 | XMapWindow (disp, menuBar.win); |
558 | XMapWindow (disp, menuBar.win); |
486 | #endif |
559 | #endif |
487 | #ifdef TRANSPARENT |
560 | #ifdef TRANSPARENT |
488 | if (options & Opt_transparent) |
561 | if (OPTION (Opt_transparent)) |
489 | { |
562 | { |
490 | XSelectInput (disp, display->root, PropertyChangeMask); |
563 | XSelectInput (disp, display->root, PropertyChangeMask); |
491 | check_our_parents (); |
564 | check_our_parents (); |
492 | rootwin_ev.start (display, display->root); |
565 | rootwin_ev.start (display, display->root); |
493 | } |
566 | } |
… | |
… | |
500 | |
573 | |
501 | init_command (cmd_argv); |
574 | init_command (cmd_argv); |
502 | |
575 | |
503 | free (cmd_argv); |
576 | free (cmd_argv); |
504 | |
577 | |
|
|
578 | if (pty.pty >= 0) |
505 | pty_ev.start (pty.pty, EVENT_READ); |
579 | pty_ev.start (pty.pty, EVENT_READ); |
506 | |
580 | |
507 | check_ev.start (); |
581 | check_ev.start (); |
|
|
582 | |
|
|
583 | HOOK_INVOKE ((this, HOOK_START, DT_END)); |
508 | |
584 | |
509 | return true; |
585 | return true; |
510 | } |
586 | } |
511 | |
587 | |
512 | static struct sig_handlers |
588 | static struct sig_handlers |
… | |
… | |
520 | |
596 | |
521 | while ((pid = waitpid (-1, NULL, WNOHANG)) > 0) |
597 | while ((pid = waitpid (-1, NULL, WNOHANG)) > 0) |
522 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
598 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
523 | if (pid == (*t)->cmd_pid) |
599 | if (pid == (*t)->cmd_pid) |
524 | { |
600 | { |
525 | (*t)->destroy (); |
601 | (*t)->child_exit (); |
526 | break; |
602 | break; |
527 | } |
603 | } |
528 | } |
604 | } |
529 | |
605 | |
530 | /* |
606 | /* |
… | |
… | |
547 | sw_int (this, &sig_handlers::sig_term) |
623 | sw_int (this, &sig_handlers::sig_term) |
548 | { |
624 | { |
549 | } |
625 | } |
550 | } sig_handlers; |
626 | } sig_handlers; |
551 | |
627 | |
|
|
628 | char **rxvt_environ; // startup environment |
|
|
629 | |
552 | void |
630 | void |
553 | rxvt_init () |
631 | rxvt_init () |
554 | { |
632 | { |
|
|
633 | rxvt_environ = environ; |
|
|
634 | |
555 | /* |
635 | /* |
556 | * Save and then give up any super-user privileges |
636 | * Save and then give up any super-user privileges |
557 | * 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. |
558 | * We should only need to be root in these cases: |
638 | * We should only need to be root in these cases: |
559 | * 1. write utmp entries on some systems |
639 | * 1. write utmp entries on some systems |
… | |
… | |
573 | /* signal (SIGURG, SIG_DFL); */ |
653 | /* signal (SIGURG, SIG_DFL); */ |
574 | |
654 | |
575 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
655 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
576 | // TODO: handle this with exceptions and tolerate the memory loss |
656 | // TODO: handle this with exceptions and tolerate the memory loss |
577 | XSetIOErrorHandler (rxvt_xioerror_handler); |
657 | XSetIOErrorHandler (rxvt_xioerror_handler); |
|
|
658 | |
|
|
659 | XrmInitialize (); |
578 | } |
660 | } |
579 | |
661 | |
580 | /* ------------------------------------------------------------------------- * |
662 | /* ------------------------------------------------------------------------- * |
581 | * MEMORY ALLOCATION WRAPPERS * |
663 | * MEMORY ALLOCATION WRAPPERS * |
582 | * ------------------------------------------------------------------------- */ |
664 | * ------------------------------------------------------------------------- */ |
… | |
… | |
618 | * ------------------------------------------------------------------------- */ |
700 | * ------------------------------------------------------------------------- */ |
619 | /* take care of suid/sgid super-user (root) privileges */ |
701 | /* take care of suid/sgid super-user (root) privileges */ |
620 | void |
702 | void |
621 | rxvt_privileges (rxvt_privaction action) |
703 | rxvt_privileges (rxvt_privaction action) |
622 | { |
704 | { |
623 | #if (defined(HAVE_SETEUID) || defined(HAVE_SETREUID)) && !defined(__CYGWIN32__) |
|
|
624 | static uid_t euid; |
|
|
625 | static gid_t egid; |
|
|
626 | #endif |
|
|
627 | |
|
|
628 | #if ! defined(__CYGWIN32__) |
705 | #if ! defined(__CYGWIN32__) |
629 | # if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) |
706 | # if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) |
630 | /* setreuid () is the poor man's setuid (), seteuid () */ |
707 | /* setreuid () is the poor man's setuid (), seteuid () */ |
631 | # define seteuid(a) setreuid(-1, (a)) |
708 | # define seteuid(a) setreuid(-1, (a)) |
632 | # define setegid(a) setregid(-1, (a)) |
709 | # define setegid(a) setregid(-1, (a)) |
… | |
… | |
638 | case IGNORE: |
715 | case IGNORE: |
639 | /* |
716 | /* |
640 | * 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 |
641 | * back to root later, as required |
718 | * back to root later, as required |
642 | */ |
719 | */ |
|
|
720 | setegid (getgid ()); |
643 | seteuid (getuid ()); |
721 | seteuid (getuid ()); |
644 | setegid (getgid ()); |
|
|
645 | break; |
722 | break; |
646 | case SAVE: |
723 | case SAVE: |
647 | euid = geteuid (); |
|
|
648 | egid = getegid (); |
724 | saved_egid = getegid (); |
|
|
725 | saved_euid = geteuid (); |
649 | break; |
726 | break; |
650 | case RESTORE: |
727 | case RESTORE: |
651 | seteuid (euid); |
|
|
652 | setegid (egid); |
728 | setegid (saved_egid); |
|
|
729 | seteuid (saved_euid); |
653 | break; |
730 | break; |
654 | } |
731 | } |
655 | # else |
732 | # else |
656 | switch (action) |
733 | switch (action) |
657 | { |
734 | { |
658 | case IGNORE: |
735 | case IGNORE: |
|
|
736 | setgid (getgid ()); |
659 | setuid (getuid ()); |
737 | setuid (getuid ()); |
660 | setgid (getgid ()); |
|
|
661 | /* FALLTHROUGH */ |
738 | /* FALLTHROUGH */ |
662 | case SAVE: |
739 | case SAVE: |
663 | /* FALLTHROUGH */ |
740 | /* FALLTHROUGH */ |
664 | case RESTORE: |
741 | case RESTORE: |
665 | break; |
742 | break; |
… | |
… | |
670 | |
747 | |
671 | #ifdef UTMP_SUPPORT |
748 | #ifdef UTMP_SUPPORT |
672 | void |
749 | void |
673 | rxvt_term::privileged_utmp (rxvt_privaction action) |
750 | rxvt_term::privileged_utmp (rxvt_privaction action) |
674 | { |
751 | { |
675 | if ((options & Opt_utmpInhibit) |
752 | if (OPTION (Opt_utmpInhibit) |
676 | || !pty.name || !*pty.name) |
753 | || !pty.name || !*pty.name) |
677 | return; |
754 | return; |
678 | |
755 | |
679 | rxvt_privileges (RESTORE); |
756 | rxvt_privileges (RESTORE); |
680 | |
757 | |
… | |
… | |
718 | if (rs[Rs_geometry]) |
795 | if (rs[Rs_geometry]) |
719 | flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); |
796 | flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); |
720 | |
797 | |
721 | if (flags & WidthValue) |
798 | if (flags & WidthValue) |
722 | { |
799 | { |
723 | ncol = BOUND_POSITIVE_INT16 (w); |
800 | ncol = clamp (w, 0, std::numeric_limits<int16_t>::max ()); |
724 | szHint.flags |= USSize; |
801 | szHint.flags |= USSize; |
725 | } |
802 | } |
726 | |
803 | |
727 | if (flags & HeightValue) |
804 | if (flags & HeightValue) |
728 | { |
805 | { |
729 | nrow = BOUND_POSITIVE_INT16 (h); |
806 | nrow = clamp (h, 0, std::numeric_limits<int16_t>::max ()); |
730 | szHint.flags |= USSize; |
807 | szHint.flags |= USSize; |
731 | } |
808 | } |
732 | |
809 | |
733 | if (flags & XValue) |
810 | if (flags & XValue) |
734 | { |
811 | { |
… | |
… | |
772 | |
849 | |
773 | if (scrollbar_visible ()) |
850 | if (scrollbar_visible ()) |
774 | { |
851 | { |
775 | sb_w = scrollbar_TotalWidth (); |
852 | sb_w = scrollbar_TotalWidth (); |
776 | szHint.base_width += sb_w; |
853 | szHint.base_width += sb_w; |
777 | if (!(options & Opt_scrollBar_right)) |
854 | if (!OPTION (Opt_scrollBar_right)) |
778 | window_vt_x += sb_w; |
855 | window_vt_x += sb_w; |
779 | } |
856 | } |
780 | |
857 | |
781 | if (menubar_visible ()) |
858 | if (menubar_visible ()) |
782 | { |
859 | { |
… | |
… | |
795 | szHint.width = newwidth; |
872 | szHint.width = newwidth; |
796 | width = newwidth - szHint.base_width; |
873 | width = newwidth - szHint.base_width; |
797 | } |
874 | } |
798 | else |
875 | else |
799 | { |
876 | { |
800 | MIN_IT (width, max_width); |
877 | min_it (width, max_width); |
801 | szHint.width = szHint.base_width + width; |
878 | szHint.width = szHint.base_width + width; |
802 | } |
879 | } |
803 | |
880 | |
804 | if (newheight && newheight - szHint.base_height < max_height) |
881 | if (newheight && newheight - szHint.base_height < max_height) |
805 | { |
882 | { |
806 | szHint.height = newheight; |
883 | szHint.height = newheight; |
807 | height = newheight - szHint.base_height; |
884 | height = newheight - szHint.base_height; |
808 | } |
885 | } |
809 | else |
886 | else |
810 | { |
887 | { |
811 | MIN_IT (height, max_height); |
888 | min_it (height, max_height); |
812 | szHint.height = szHint.base_height + height; |
889 | szHint.height = szHint.base_height + height; |
813 | } |
890 | } |
814 | |
891 | |
815 | if (scrollbar_visible () && (options & Opt_scrollBar_right)) |
892 | if (scrollbar_visible () && OPTION (Opt_scrollBar_right)) |
816 | window_sb_x = szHint.width - sb_w; |
893 | window_sb_x = szHint.width - sb_w; |
817 | |
894 | |
818 | if (recalc_x) |
895 | if (recalc_x) |
819 | szHint.x += DisplayWidth (disp, display->screen) - szHint.width - 2 * ext_bwidth; |
896 | szHint.x += DisplayWidth (disp, display->screen) - szHint.width - 2 * ext_bwidth; |
820 | if (recalc_y) |
897 | if (recalc_y) |
… | |
… | |
889 | prop.height += lineSpace; |
966 | prop.height += lineSpace; |
890 | fs->set_prop (prop); |
967 | fs->set_prop (prop); |
891 | |
968 | |
892 | fwidth = prop.width; |
969 | fwidth = prop.width; |
893 | fheight = prop.height; |
970 | fheight = prop.height; |
894 | fweight = prop.weight; |
971 | fbase = prop.ascent; |
895 | fslant = prop.slant; |
|
|
896 | fbase = (*fs)[1]->ascent; |
|
|
897 | |
972 | |
898 | for (int style = 1; style < 4; style++) |
973 | for (int style = 1; style < 4; style++) |
899 | { |
974 | { |
900 | #if ENABLE_STYLES |
975 | #if ENABLE_STYLES |
901 | const char *res = rs[Rs_font + style]; |
976 | const char *res = rs[Rs_font + style]; |
… | |
… | |
935 | return true; |
1010 | return true; |
936 | } |
1011 | } |
937 | |
1012 | |
938 | void rxvt_term::set_string_property (Atom prop, const char *str, int len) |
1013 | void rxvt_term::set_string_property (Atom prop, const char *str, int len) |
939 | { |
1014 | { |
940 | // TODO: SMART_WINDOW_TITLE |
|
|
941 | XChangeProperty (display->display, parent[0], |
1015 | XChangeProperty (display->display, parent[0], |
942 | prop, XA_STRING, 8, PropModeReplace, |
1016 | prop, XA_STRING, 8, PropModeReplace, |
943 | (const unsigned char *)str, len >= 0 ? len : strlen (str)); |
1017 | (const unsigned char *)str, len >= 0 ? len : strlen (str)); |
944 | } |
1018 | } |
945 | |
1019 | |
946 | void rxvt_term::set_utf8_property (Atom prop, const char *str, int len) |
1020 | void rxvt_term::set_utf8_property (Atom prop, const char *str, int len) |
947 | { |
1021 | { |
948 | // TODO: SMART_WINDOW_TITLE |
|
|
949 | wchar_t *ws = rxvt_mbstowcs (str, len); |
1022 | wchar_t *ws = rxvt_mbstowcs (str, len); |
950 | char *s = rxvt_wcstoutf8 (ws); |
1023 | char *s = rxvt_wcstoutf8 (ws); |
951 | |
1024 | |
952 | XChangeProperty (display->display, parent[0], |
1025 | XChangeProperty (display->display, parent[0], |
953 | prop, xa[XA_UTF8_STRING], 8, PropModeReplace, |
1026 | prop, xa[XA_UTF8_STRING], 8, PropModeReplace, |
… | |
… | |
994 | i = atoi (color); |
1067 | i = atoi (color); |
995 | |
1068 | |
996 | if (i >= 8 && i <= 15) |
1069 | if (i >= 8 && i <= 15) |
997 | { /* bright colors */ |
1070 | { /* bright colors */ |
998 | i -= 8; |
1071 | i -= 8; |
999 | # ifndef NO_BRIGHTCOLOR |
|
|
1000 | pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; |
1072 | pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; |
1001 | SET_PIXCOLOR (idx); |
1073 | SET_PIXCOLOR (idx); |
1002 | goto done; |
1074 | goto done; |
1003 | # endif |
|
|
1004 | } |
1075 | } |
1005 | |
1076 | |
1006 | if (i >= 0 && i <= 7) |
1077 | if (i >= 0 && i <= 7) |
1007 | { /* normal colors */ |
1078 | { /* normal colors */ |
1008 | pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; |
1079 | pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; |
… | |
… | |
1192 | } |
1263 | } |
1193 | |
1264 | |
1194 | if (menubar_visible ()) |
1265 | if (menubar_visible ()) |
1195 | XMoveResizeWindow (disp, menuBar.win, |
1266 | XMoveResizeWindow (disp, menuBar.win, |
1196 | window_vt_x, 0, |
1267 | window_vt_x, 0, |
1197 | TermWin_TotalWidth (), menuBar_TotalHeight ()); |
1268 | width, menuBar_TotalHeight ()); |
1198 | |
1269 | |
1199 | XMoveResizeWindow (disp, vt, |
1270 | XMoveResizeWindow (disp, vt, |
1200 | window_vt_x, window_vt_y, |
1271 | window_vt_x, window_vt_y, |
1201 | TermWin_TotalWidth (), TermWin_TotalHeight ()); |
1272 | width, height); |
1202 | |
1273 | |
1203 | scr_clear (); |
1274 | scr_clear (); |
1204 | #ifdef XPM_BACKGROUND |
1275 | #ifdef XPM_BACKGROUND |
1205 | resize_pixmap (); |
1276 | resize_pixmap (); |
1206 | #endif |
1277 | #endif |
… | |
… | |
1386 | XRectangle rect, status_rect, needed_rect; |
1457 | XRectangle rect, status_rect, needed_rect; |
1387 | unsigned long fg, bg; |
1458 | unsigned long fg, bg; |
1388 | const char *p; |
1459 | const char *p; |
1389 | char **s; |
1460 | char **s; |
1390 | XIMStyles *xim_styles; |
1461 | XIMStyles *xim_styles; |
|
|
1462 | |
|
|
1463 | set_environ (envv); |
1391 | |
1464 | |
1392 | if (! ((p = XSetLocaleModifiers (modifiers)) && *p)) |
1465 | if (! ((p = XSetLocaleModifiers (modifiers)) && *p)) |
1393 | return false; |
1466 | return false; |
1394 | |
1467 | |
1395 | D_MAIN ((stderr, "rxvt_IM_get_IC ()")); |
1468 | D_MAIN ((stderr, "rxvt_IM_get_IC ()")); |
… | |
… | |
1561 | int i; |
1634 | int i; |
1562 | const char *p; |
1635 | const char *p; |
1563 | char **s; |
1636 | char **s; |
1564 | char buf[IMBUFSIZ]; |
1637 | char buf[IMBUFSIZ]; |
1565 | |
1638 | |
1566 | SET_R (this); |
1639 | make_current (); |
1567 | |
1640 | |
1568 | im_destroy (); |
1641 | im_destroy (); |
1569 | |
1642 | |
1570 | D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()")); |
1643 | D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()")); |
1571 | if (Input_Context) |
1644 | if (Input_Context) |