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.151 by root, Wed Dec 21 19:50:16 2005 UTC vs.
Revision 1.190 by root, Thu Jan 19 20:30:36 2006 UTC

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"
35 37
36#include <limits> 38#include <limits>
37 39
38#include <csignal> 40#include <csignal>
39#include <cstring> 41#include <cstring>
44 46
45#ifdef HAVE_TERMIOS_H 47#ifdef HAVE_TERMIOS_H
46# include <termios.h> 48# include <termios.h>
47#endif 49#endif
48 50
49#ifdef KEYSYM_RESOURCE
50# include "keyboard.h"
51#endif
52
53vector<rxvt_term *> rxvt_term::termlist; 51vector<rxvt_term *> rxvt_term::termlist;
54 52
55static char curlocale[128]; 53static char curlocale[128], savelocale[128];
56 54
57bool 55bool
58rxvt_set_locale (const char *locale) 56rxvt_set_locale (const char *locale)
59{ 57{
60 if (!locale || !strncmp (locale, curlocale, 128)) 58 if (!locale || !strncmp (locale, curlocale, 128))
61 return false; 59 return false;
62 60
63 strncpy (curlocale, locale, 128); 61 strncpy (curlocale, locale, 128);
64 setlocale (LC_CTYPE, curlocale); 62 setlocale (LC_CTYPE, curlocale);
65 return true; 63 return true;
64}
65
66void
67rxvt_push_locale (const char *locale)
68{
69 strcpy (savelocale, curlocale);
70 rxvt_set_locale (locale);
71}
72
73void
74rxvt_pop_locale ()
75{
76 rxvt_set_locale (savelocale);
66} 77}
67 78
68#if ENABLE_COMBINING 79#if ENABLE_COMBINING
69class rxvt_composite_vec rxvt_composite; 80class rxvt_composite_vec rxvt_composite;
70 81
135 rootwin_ev (this, &rxvt_term::rootwin_cb), 146 rootwin_ev (this, &rxvt_term::rootwin_cb),
136#endif 147#endif
137#ifdef HAVE_SCROLLBARS 148#ifdef HAVE_SCROLLBARS
138 scrollbar_ev (this, &rxvt_term::x_cb), 149 scrollbar_ev (this, &rxvt_term::x_cb),
139#endif 150#endif
140#ifdef MENUBAR
141 menubar_ev (this, &rxvt_term::x_cb),
142#endif
143#ifdef CURSOR_BLINK 151#ifdef CURSOR_BLINK
144 cursor_blink_ev (this, &rxvt_term::cursor_blink_cb), 152 cursor_blink_ev (this, &rxvt_term::cursor_blink_cb),
145#endif 153#endif
146#ifdef TEXT_BLINK 154#ifdef TEXT_BLINK
147 text_blink_ev (this, &rxvt_term::text_blink_cb), 155 text_blink_ev (this, &rxvt_term::text_blink_cb),
161#ifdef USE_XIM 169#ifdef USE_XIM
162 im_ev (this, &rxvt_term::im_cb), 170 im_ev (this, &rxvt_term::im_cb),
163#endif 171#endif
164 termwin_ev (this, &rxvt_term::x_cb), 172 termwin_ev (this, &rxvt_term::x_cb),
165 vt_ev (this, &rxvt_term::x_cb), 173 vt_ev (this, &rxvt_term::x_cb),
174 child_ev (this, &rxvt_term::child_cb),
166 check_ev (this, &rxvt_term::check_cb), 175 check_ev (this, &rxvt_term::check_cb),
167 flush_ev (this, &rxvt_term::flush_cb), 176 flush_ev (this, &rxvt_term::flush_cb),
168 destroy_ev (this, &rxvt_term::destroy_cb), 177 destroy_ev (this, &rxvt_term::destroy_cb),
169 pty_ev (this, &rxvt_term::pty_cb), 178 pty_ev (this, &rxvt_term::pty_cb),
170 incr_ev (this, &rxvt_term::incr_cb) 179 incr_ev (this, &rxvt_term::incr_cb)
186void rxvt_term::emergency_cleanup () 195void rxvt_term::emergency_cleanup ()
187{ 196{
188 if (cmd_pid) 197 if (cmd_pid)
189 kill (-cmd_pid, SIGHUP); 198 kill (-cmd_pid, SIGHUP);
190 199
191#ifdef UTMP_SUPPORT 200 delete pty; pty = 0;
192 privileged_utmp (RESTORE);
193#endif
194
195 pty.put ();
196} 201}
197 202
198rxvt_term::~rxvt_term () 203rxvt_term::~rxvt_term ()
199{ 204{
205 HOOK_INVOKE ((this, HOOK_DESTROY, DT_END));
206
200 termlist.erase (find (termlist.begin (), termlist.end(), this)); 207 termlist.erase (find (termlist.begin (), termlist.end(), this));
201 208
202 emergency_cleanup (); 209 emergency_cleanup ();
203 210
204#if ENABLE_STYLES 211#if ENABLE_STYLES
214 221
215 selection_clear (); 222 selection_clear ();
216 223
217#ifdef USE_XIM 224#ifdef USE_XIM
218 im_destroy (); 225 im_destroy ();
219#endif
220#ifdef MENUBAR
221 if (menubarGC) XFreeGC (disp, menubarGC);
222#endif 226#endif
223#ifdef XTERM_SCROLLBAR 227#ifdef XTERM_SCROLLBAR
224 if (xscrollbarGC) XFreeGC (disp, xscrollbarGC); 228 if (xscrollbarGC) XFreeGC (disp, xscrollbarGC);
225 if (ShadowGC) XFreeGC (disp, ShadowGC); 229 if (ShadowGC) XFreeGC (disp, ShadowGC);
226#endif 230#endif
237 if (upArrow) XFreePixmap (disp, upArrow); 241 if (upArrow) XFreePixmap (disp, upArrow);
238 if (downArrow) XFreePixmap (disp, downArrow); 242 if (downArrow) XFreePixmap (disp, downArrow);
239 if (upArrowHi) XFreePixmap (disp, upArrowHi); 243 if (upArrowHi) XFreePixmap (disp, upArrowHi);
240 if (downArrowHi) XFreePixmap (disp, downArrowHi); 244 if (downArrowHi) XFreePixmap (disp, downArrowHi);
241#endif 245#endif
242#if defined(MENUBAR) || defined(RXVT_SCROLLBAR) 246#ifdef RXVT_SCROLLBAR
243 if (topShadowGC) XFreeGC (disp, topShadowGC); 247 if (topShadowGC) XFreeGC (disp, topShadowGC);
244 if (botShadowGC) XFreeGC (disp, botShadowGC); 248 if (botShadowGC) XFreeGC (disp, botShadowGC);
245 if (scrollbarGC) XFreeGC (disp, scrollbarGC); 249 if (scrollbarGC) XFreeGC (disp, scrollbarGC);
246#endif 250#endif
247 if (gc) XFreeGC (disp, gc); 251 if (gc) XFreeGC (disp, gc);
248 252
249#if defined(MENUBAR) && (MENUBAR_MAX > 1)
250 delete menuBar.drawable;
251 //if (menuBar.win)
252 // XDestroyWindow (disp, menuBar.win);
253#endif
254 delete drawable; 253 delete drawable;
255 // destroy all windows 254 // destroy all windows
256 if (parent[0]) 255 if (parent[0])
257 XDestroyWindow (disp, parent[0]); 256 XDestroyWindow (disp, parent[0]);
258 } 257 }
259 258
260 // TODO: free pixcolours, colours should become part of rxvt_display 259 // TODO: free pixcolours, colours should become part of rxvt_display
261
262 delete pix_colors_focused; 260 delete pix_colors_focused;
263#if OFF_FOCUS_FADING 261#if OFF_FOCUS_FADING
264 delete pix_colors_unfocused; 262 delete pix_colors_unfocused;
265#endif 263#endif
266 264
288#ifdef KEYSYM_RESOURCE 286#ifdef KEYSYM_RESOURCE
289 delete keyboard; 287 delete keyboard;
290#endif 288#endif
291} 289}
292 290
291// child has exited, usually destroys
292void
293rxvt_term::child_cb (child_watcher &w, int status)
294{
295 HOOK_INVOKE ((this, HOOK_CHILD_EXIT, DT_INT, status, DT_END));
296
297 cmd_pid = 0;
298
299 if (!OPTION (Opt_hold))
300 destroy ();
301}
302
293void 303void
294rxvt_term::destroy () 304rxvt_term::destroy ()
295{ 305{
296 if (destroy_ev.active) 306 if (destroy_ev.active)
297 return; 307 return;
305#if USE_XIM 315#if USE_XIM
306 im_ev.stop (display); 316 im_ev.stop (display);
307#endif 317#endif
308#if HAVE_SCROLLBARS 318#if HAVE_SCROLLBARS
309 scrollbar_ev.stop (display); 319 scrollbar_ev.stop (display);
310#endif
311#if MENUBAR
312 menubar_ev.stop (display);
313#endif 320#endif
314#if TRANSPARENT 321#if TRANSPARENT
315 rootwin_ev.stop (display); 322 rootwin_ev.stop (display);
316#endif 323#endif
317 incr_ev.stop (); 324 incr_ev.stop ();
341} 348}
342 349
343void 350void
344rxvt_term::destroy_cb (time_watcher &w) 351rxvt_term::destroy_cb (time_watcher &w)
345{ 352{
346 SET_R (this); 353 make_current ();
347 354
348 delete this; 355 delete this;
349} 356}
350 357
351/*----------------------------------------------------------------------*/ 358/*----------------------------------------------------------------------*/
442/*----------------------------------------------------------------------*/ 449/*----------------------------------------------------------------------*/
443bool 450bool
444rxvt_term::init (int argc, const char *const *argv) 451rxvt_term::init (int argc, const char *const *argv)
445{ 452{
446 SET_R (this); 453 SET_R (this);
447
448 set_locale (""); 454 set_locale ("");
455 set_environ (envv); // few things in X do not call setlocale :(
449 456
450 if (!init_vars ()) 457 if (!init_vars ())
451 return false; 458 return false;
452 459
453 init_secondary (); 460 init_secondary ();
456 463
457#ifdef KEYSYM_RESOURCE 464#ifdef KEYSYM_RESOURCE
458 keyboard->register_done (); 465 keyboard->register_done ();
459#endif 466#endif
460 467
461#if MENUBAR_MAX 468#if ENABLE_PERL
462 menubar_read (rs[Rs_menu]); 469 if (!rs[Rs_perl_ext_1])
470 rs[Rs_perl_ext_1] = "default";
471
472 if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1])
473 || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2])
474 || (rs[Rs_perl_eval] && *rs[Rs_perl_eval]))
475 {
476 rxvt_perl.init (this);
477 HOOK_INVOKE ((this, HOOK_INIT, DT_END));
478 }
463#endif 479#endif
480
464#ifdef HAVE_SCROLLBARS 481#ifdef HAVE_SCROLLBARS
465 if (options & Opt_scrollBar) 482 if (OPTION (Opt_scrollBar))
466 scrollBar.setIdle (); /* set existence for size calculations */ 483 scrollBar.setIdle (); /* set existence for size calculations */
467#endif 484#endif
468 485
486 pty = rxvt_new_ptytty ();
487
469 create_windows (argc, argv); 488 create_windows (argc, argv);
470 489
471 dDisp; 490 dDisp;
472 491
473 init_xlocale (); 492 init_xlocale ();
474 493
475 scr_reset (); /* initialize screen */ 494 scr_reset (); // initialize screen
476 495
477#if 0 496#if 0
478 XSynchronize (disp, True); 497 XSynchronize (disp, True);
479#endif 498#endif
480 499
481#ifdef HAVE_SCROLLBARS 500#ifdef HAVE_SCROLLBARS
482 if (options & Opt_scrollBar) 501 if (OPTION (Opt_scrollBar))
483 resize_scrollbar (); /* create and map scrollbar */ 502 resize_scrollbar (); /* create and map scrollbar */
484#endif 503#endif
485#if (MENUBAR_MAX)
486 if (menubar_visible ())
487 XMapWindow (disp, menuBar.win);
488#endif
489#ifdef TRANSPARENT 504#ifdef TRANSPARENT
490 if (options & Opt_transparent) 505 if (OPTION (Opt_transparent))
491 { 506 {
492 XSelectInput (disp, display->root, PropertyChangeMask); 507 XSelectInput (disp, display->root, PropertyChangeMask);
493 check_our_parents (); 508 check_our_parents ();
494 rootwin_ev.start (display, display->root); 509 rootwin_ev.start (display, display->root);
495 } 510 }
502 517
503 init_command (cmd_argv); 518 init_command (cmd_argv);
504 519
505 free (cmd_argv); 520 free (cmd_argv);
506 521
522 if (pty->pty >= 0)
507 pty_ev.start (pty.pty, EVENT_READ); 523 pty_ev.start (pty->pty, EVENT_READ);
508 524
509 check_ev.start (); 525 check_ev.start ();
510 526
527 HOOK_INVOKE ((this, HOOK_START, DT_END));
528
511 return true; 529 return true;
512} 530}
513 531
514static struct sig_handlers 532static struct sig_handlers
515{ 533{
516 sig_watcher sw_chld, sw_term, sw_int; 534 sig_watcher sw_term, sw_int;
517 535
518 void sig_chld (sig_watcher &w)
519 {
520 // we are being called for every SIGCHLD, find the corresponding term
521 int pid;
522
523 while ((pid = waitpid (-1, NULL, WNOHANG)) > 0)
524 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
525 if (pid == (*t)->cmd_pid)
526 {
527 (*t)->destroy ();
528 break;
529 }
530 }
531
532 /* 536 /*
533 * Catch a fatal signal and tidy up before quitting 537 * Catch a fatal signal and tidy up before quitting
534 */ 538 */
535 void 539 void
536 sig_term (sig_watcher &w) 540 sig_term (sig_watcher &w)
542 signal (w.signum, SIG_DFL); 546 signal (w.signum, SIG_DFL);
543 kill (getpid (), w.signum); 547 kill (getpid (), w.signum);
544 } 548 }
545 549
546 sig_handlers () 550 sig_handlers ()
547 : sw_chld (this, &sig_handlers::sig_chld),
548 sw_term (this, &sig_handlers::sig_term), 551 : sw_term (this, &sig_handlers::sig_term),
549 sw_int (this, &sig_handlers::sig_term) 552 sw_int (this, &sig_handlers::sig_term)
550 { 553 {
551 } 554 }
552} sig_handlers; 555} sig_handlers;
553 556
557char **rxvt_environ; // startup environment
558
554void 559void
555rxvt_init () 560rxvt_init ()
556{ 561{
557 /* 562 uid_t uid = getuid ();
558 * Save and then give up any super-user privileges 563 gid_t gid = getgid ();
559 * If we need privileges in any area then we must specifically request it. 564
560 * We should only need to be root in these cases: 565 // before doing anything else, check for setuid/setgid operation,
561 * 1. write utmp entries on some systems 566 // start the helper process and drop privileges
562 * 2. chown tty on some systems 567 if (uid != geteuid ()
563 */ 568 || gid != getegid ())
564 rxvt_privileges (SAVE); 569 {
565 rxvt_privileges (IGNORE); 570#if PTYTTY_HELPER
571 rxvt_ptytty_server ();
572#else
573 rxvt_warn ("running setuid/setgid without pty helper compiled in, continuing unprivileged.\n");
574#endif
575
576 // drop privileges
577#if HAVE_SETRESUID
578 setresgid (gid, gid, gid);
579 setresuid (uid, uid, uid);
580#elif HAVE_SETREUID
581 setregid (gid, gid);
582 setreuid (uid, uid);
583#elif HAVE_SETUID
584 setgid (gid);
585 setuid (uid);
586#endif
587
588 if (uid != geteuid ()
589 || gid != getegid ())
590 rxvt_fatal ("unable to drop privileges, aborting.\n");
591 }
592
593 rxvt_environ = environ;
566 594
567 signal (SIGHUP, SIG_IGN); 595 signal (SIGHUP, SIG_IGN);
568 signal (SIGPIPE, SIG_IGN); 596 signal (SIGPIPE, SIG_IGN);
569 597
570 sig_handlers.sw_chld.start (SIGCHLD);
571 sig_handlers.sw_term.start (SIGTERM); 598 sig_handlers.sw_term.start (SIGTERM);
572 sig_handlers.sw_int.start (SIGINT); 599 sig_handlers.sw_int.start (SIGINT);
573 600
574 /* need to trap SIGURG for SVR4 (Unixware) rlogin */ 601 /* need to trap SIGURG for SVR4 (Unixware) rlogin */
575 /* signal (SIGURG, SIG_DFL); */ 602 /* signal (SIGURG, SIG_DFL); */
576 603
577 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); 604 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
578 // TODO: handle this with exceptions and tolerate the memory loss 605 // TODO: handle this with exceptions and tolerate the memory loss
579 XSetIOErrorHandler (rxvt_xioerror_handler); 606 XSetIOErrorHandler (rxvt_xioerror_handler);
607
608 XrmInitialize ();
580} 609}
581 610
582/* ------------------------------------------------------------------------- * 611/* ------------------------------------------------------------------------- *
583 * MEMORY ALLOCATION WRAPPERS * 612 * MEMORY ALLOCATION WRAPPERS *
584 * ------------------------------------------------------------------------- */ 613 * ------------------------------------------------------------------------- */
613 rxvt_fatal ("memory allocation failure. aborting.\n"); 642 rxvt_fatal ("memory allocation failure. aborting.\n");
614 643
615 return p; 644 return p;
616} 645}
617 646
618/* ------------------------------------------------------------------------- *
619 * PRIVILEGED OPERATIONS *
620 * ------------------------------------------------------------------------- */
621/* take care of suid/sgid super-user (root) privileges */
622void
623rxvt_privileges (rxvt_privaction action)
624{
625#if (defined(HAVE_SETEUID) || defined(HAVE_SETREUID)) && !defined(__CYGWIN32__)
626 static uid_t euid;
627 static gid_t egid;
628#endif
629
630#if ! defined(__CYGWIN32__)
631# if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID)
632 /* setreuid () is the poor man's setuid (), seteuid () */
633# define seteuid(a) setreuid(-1, (a))
634# define setegid(a) setregid(-1, (a))
635# define HAVE_SETEUID
636# endif
637# ifdef HAVE_SETEUID
638 switch (action)
639 {
640 case IGNORE:
641 /*
642 * change effective uid/gid - not real uid/gid - so we can switch
643 * back to root later, as required
644 */
645 seteuid (getuid ());
646 setegid (getgid ());
647 break;
648 case SAVE:
649 euid = geteuid ();
650 egid = getegid ();
651 break;
652 case RESTORE:
653 seteuid (euid);
654 setegid (egid);
655 break;
656 }
657# else
658 switch (action)
659 {
660 case IGNORE:
661 setuid (getuid ());
662 setgid (getgid ());
663 /* FALLTHROUGH */
664 case SAVE:
665 /* FALLTHROUGH */
666 case RESTORE:
667 break;
668 }
669# endif
670#endif
671}
672
673#ifdef UTMP_SUPPORT
674void
675rxvt_term::privileged_utmp (rxvt_privaction action)
676{
677 if ((options & Opt_utmpInhibit)
678 || !pty.name || !*pty.name)
679 return;
680
681 rxvt_privileges (RESTORE);
682
683 if (action == SAVE)
684 makeutent (pty.name, rs[Rs_display_name]);
685 else
686 cleanutent ();
687
688 rxvt_privileges (IGNORE);
689}
690#endif
691
692/*----------------------------------------------------------------------*/ 647/*----------------------------------------------------------------------*/
693/* 648/*
694 * window size/position calculcations for XSizeHint and other storage. 649 * window size/position calculcations for XSizeHint and other storage.
695 * if width/height are non-zero then override calculated width/height 650 * if width/height are non-zero then override calculated width/height
696 */ 651 */
697void 652void
698rxvt_term::window_calc (unsigned int newwidth, unsigned int newheight) 653rxvt_term::window_calc (unsigned int newwidth, unsigned int newheight)
699{ 654{
700 short recalc_x, recalc_y; 655 short recalc_x, recalc_y;
701 int x, y, sb_w, mb_h, flags; 656 int x, y, sb_w, flags;
702 unsigned int w, h; 657 unsigned int w, h;
703 unsigned int max_width, max_height; 658 unsigned int max_width, max_height;
704 dDisp; 659 dDisp;
705 660
706 D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", 661 D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d",
767 max_width = MAX_COLS * fwidth; 722 max_width = MAX_COLS * fwidth;
768 max_height = MAX_ROWS * fheight; 723 max_height = MAX_ROWS * fheight;
769 724
770 szHint.base_width = szHint.base_height = 2 * int_bwidth; 725 szHint.base_width = szHint.base_height = 2 * int_bwidth;
771 726
772 sb_w = mb_h = 0; 727 sb_w = 0;
773 window_vt_x = window_vt_y = int_bwidth; 728 window_vt_x = window_vt_y = int_bwidth;
774 729
775 if (scrollbar_visible ()) 730 if (scrollBar.state)
776 { 731 {
777 sb_w = scrollbar_TotalWidth (); 732 sb_w = scrollbar_TotalWidth ();
778 szHint.base_width += sb_w; 733 szHint.base_width += sb_w;
779 if (!(options & Opt_scrollBar_right)) 734 if (!OPTION (Opt_scrollBar_right))
780 window_vt_x += sb_w; 735 window_vt_x += sb_w;
781 }
782
783 if (menubar_visible ())
784 {
785 mb_h = menuBar_TotalHeight ();
786 szHint.base_height += mb_h;
787 window_vt_y += mb_h;
788 } 736 }
789 737
790 szHint.width_inc = fwidth; 738 szHint.width_inc = fwidth;
791 szHint.height_inc = fheight; 739 szHint.height_inc = fheight;
792 szHint.min_width = szHint.base_width + szHint.width_inc; 740 szHint.min_width = szHint.base_width + szHint.width_inc;
812 { 760 {
813 min_it (height, max_height); 761 min_it (height, max_height);
814 szHint.height = szHint.base_height + height; 762 szHint.height = szHint.base_height + height;
815 } 763 }
816 764
817 if (scrollbar_visible () && (options & Opt_scrollBar_right)) 765 if (scrollBar.state && OPTION (Opt_scrollBar_right))
818 window_sb_x = szHint.width - sb_w; 766 window_sb_x = szHint.width - sb_w;
819 767
820 if (recalc_x) 768 if (recalc_x)
821 szHint.x += DisplayWidth (disp, display->screen) - szHint.width - 2 * ext_bwidth; 769 szHint.x += DisplayWidth (disp, display->screen) - szHint.width - 2 * ext_bwidth;
822 if (recalc_y) 770 if (recalc_y)
836 * Called after a window size change. 784 * Called after a window size change.
837 */ 785 */
838void 786void
839rxvt_term::tt_winch () 787rxvt_term::tt_winch ()
840{ 788{
841 if (pty.pty < 0) 789 if (pty->pty < 0)
842 return; 790 return;
843 791
844 struct winsize ws; 792 struct winsize ws;
845 793
846 ws.ws_col = ncol; 794 ws.ws_col = ncol;
847 ws.ws_row = nrow; 795 ws.ws_row = nrow;
848 ws.ws_xpixel = width; 796 ws.ws_xpixel = width;
849 ws.ws_ypixel = height; 797 ws.ws_ypixel = height;
850 (void)ioctl (pty.pty, TIOCSWINSZ, &ws); 798 (void)ioctl (pty->pty, TIOCSWINSZ, &ws);
851 799
852#if 0 800#if 0
853 // TIOCSWINSZ⎈ is supposed to do this automatically and correctly 801 // TIOCSWINSZ⎈ is supposed to do this automatically and correctly
854 if (cmd_pid) /* force through to the command */ 802 if (cmd_pid) /* force through to the command */
855 kill (-cmd_pid, SIGWINCH); 803 kill (-cmd_pid, SIGWINCH);
891 prop.height += lineSpace; 839 prop.height += lineSpace;
892 fs->set_prop (prop); 840 fs->set_prop (prop);
893 841
894 fwidth = prop.width; 842 fwidth = prop.width;
895 fheight = prop.height; 843 fheight = prop.height;
896 fbase = (*fs)[1]->ascent; 844 fbase = prop.ascent;
897 845
898 for (int style = 1; style < 4; style++) 846 for (int style = 1; style < 4; style++)
899 { 847 {
900#if ENABLE_STYLES 848#if ENABLE_STYLES
901 const char *res = rs[Rs_font + style]; 849 const char *res = rs[Rs_font + style];
935 return true; 883 return true;
936} 884}
937 885
938void rxvt_term::set_string_property (Atom prop, const char *str, int len) 886void rxvt_term::set_string_property (Atom prop, const char *str, int len)
939{ 887{
940 // TODO: SMART_WINDOW_TITLE
941 XChangeProperty (display->display, parent[0], 888 XChangeProperty (display->display, parent[0],
942 prop, XA_STRING, 8, PropModeReplace, 889 prop, XA_STRING, 8, PropModeReplace,
943 (const unsigned char *)str, len >= 0 ? len : strlen (str)); 890 (const unsigned char *)str, len >= 0 ? len : strlen (str));
944} 891}
945 892
946void rxvt_term::set_utf8_property (Atom prop, const char *str, int len) 893void rxvt_term::set_utf8_property (Atom prop, const char *str, int len)
947{ 894{
948 // TODO: SMART_WINDOW_TITLE
949 wchar_t *ws = rxvt_mbstowcs (str, len); 895 wchar_t *ws = rxvt_mbstowcs (str, len);
950 char *s = rxvt_wcstoutf8 (ws); 896 char *s = rxvt_wcstoutf8 (ws);
951 897
952 XChangeProperty (display->display, parent[0], 898 XChangeProperty (display->display, parent[0],
953 prop, xa[XA_UTF8_STRING], 8, PropModeReplace, 899 prop, xa[XA_UTF8_STRING], 8, PropModeReplace,
994 i = atoi (color); 940 i = atoi (color);
995 941
996 if (i >= 8 && i <= 15) 942 if (i >= 8 && i <= 15)
997 { /* bright colors */ 943 { /* bright colors */
998 i -= 8; 944 i -= 8;
999# ifndef NO_BRIGHTCOLOR
1000 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; 945 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i];
1001 SET_PIXCOLOR (idx); 946 SET_PIXCOLOR (idx);
1002 goto done; 947 goto done;
1003# endif
1004 } 948 }
1005 949
1006 if (i >= 0 && i <= 7) 950 if (i >= 0 && i <= 7)
1007 { /* normal colors */ 951 { /* normal colors */
1008 pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; 952 pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i];
1181 1125
1182 fix_screen = ncol != prev_ncol || nrow != prev_nrow; 1126 fix_screen = ncol != prev_ncol || nrow != prev_nrow;
1183 1127
1184 if (fix_screen || newwidth != old_width || newheight != old_height) 1128 if (fix_screen || newwidth != old_width || newheight != old_height)
1185 { 1129 {
1186 if (scrollbar_visible ()) 1130 if (scrollBar.state)
1187 { 1131 {
1188 XMoveResizeWindow (disp, scrollBar.win, 1132 XMoveResizeWindow (disp, scrollBar.win,
1189 window_sb_x, 0, 1133 window_sb_x, 0,
1190 scrollbar_TotalWidth (), szHint.height); 1134 scrollbar_TotalWidth (), szHint.height);
1191 resize_scrollbar (); 1135 resize_scrollbar ();
1192 } 1136 }
1193 1137
1194 if (menubar_visible ())
1195 XMoveResizeWindow (disp, menuBar.win,
1196 window_vt_x, 0,
1197 TermWin_TotalWidth (), menuBar_TotalHeight ());
1198
1199 XMoveResizeWindow (disp, vt, 1138 XMoveResizeWindow (disp, vt,
1200 window_vt_x, window_vt_y, 1139 window_vt_x, window_vt_y,
1201 TermWin_TotalWidth (), TermWin_TotalHeight ()); 1140 width, height);
1202 1141
1203 scr_clear (); 1142 scr_clear ();
1204#ifdef XPM_BACKGROUND 1143#ifdef XPM_BACKGROUND
1205 resize_pixmap (); 1144 resize_pixmap ();
1206#endif 1145#endif
1386 XRectangle rect, status_rect, needed_rect; 1325 XRectangle rect, status_rect, needed_rect;
1387 unsigned long fg, bg; 1326 unsigned long fg, bg;
1388 const char *p; 1327 const char *p;
1389 char **s; 1328 char **s;
1390 XIMStyles *xim_styles; 1329 XIMStyles *xim_styles;
1330
1331 set_environ (envv);
1391 1332
1392 if (! ((p = XSetLocaleModifiers (modifiers)) && *p)) 1333 if (! ((p = XSetLocaleModifiers (modifiers)) && *p))
1393 return false; 1334 return false;
1394 1335
1395 D_MAIN ((stderr, "rxvt_IM_get_IC ()")); 1336 D_MAIN ((stderr, "rxvt_IM_get_IC ()"));
1561 int i; 1502 int i;
1562 const char *p; 1503 const char *p;
1563 char **s; 1504 char **s;
1564 char buf[IMBUFSIZ]; 1505 char buf[IMBUFSIZ];
1565 1506
1566 SET_R (this); 1507 make_current ();
1567 1508
1568 im_destroy (); 1509 im_destroy ();
1569 1510
1570 D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()")); 1511 D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()"));
1571 if (Input_Context) 1512 if (Input_Context)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines