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.45 by pcg, Tue Feb 24 21:46:15 2004 UTC vs.
Revision 1.70 by root, Mon Jul 26 18:01:19 2004 UTC

1/*--------------------------------*-C-*---------------------------------*; 1/*--------------------------------*-C-*---------------------------------*
2 * File: main.c 2 * File: main.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * 4 *
5 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> 6 * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk>
7 * - original version 7 * - original version
44# include <termios.h> 44# include <termios.h>
45#endif 45#endif
46 46
47#include <cstring> 47#include <cstring>
48 48
49vector<rxvt_term *> rxvt_term::termlist;
50
49static char curlocale[128]; 51static char curlocale[128];
50 52
51void 53bool
52rxvt_set_locale (const char *locale) 54rxvt_set_locale (const char *locale)
53{ 55{
54 if (locale && STRNCMP (locale, curlocale, 128)) 56 if (!locale || !STRNCMP (locale, curlocale, 128))
55 { 57 return false;
58
56 STRNCPY (curlocale, locale, 128); 59 STRNCPY (curlocale, locale, 128);
57 setlocale (LC_CTYPE, curlocale); 60 setlocale (LC_CTYPE, curlocale);
61 return true;
62}
63
64#if ENABLE_COMBINING
65class rxvt_composite_vec rxvt_composite;
66
67text_t rxvt_composite_vec::compose (unicode_t c1, unicode_t c2)
68{
69 compose_char *cc;
70
71 // break compose chains, as stupid readline really likes to duplicate
72 // composing characters for some reason near the end of a line.
73 cc = (*this)[c1];
74 while (cc)
58 } 75 {
76 if (cc->c2 == c2) return c1;
77 cc = (*this)[cc->c1];
78 }
79
80 // check to see wether this combination already exists otherwise
81 for (cc = v.end (); cc-- > v.begin (); )
82 {
83 if (cc->c1 == c1 && cc->c2 == c2)
84 return COMPOSE_LO + (cc - v.begin ());
85 }
86
87 // allocate a new combination
88 if (v.size () == COMPOSE_HI - COMPOSE_LO + 1)
89 {
90 static int seen;
91
92 if (!seen++)
93 fprintf (stderr, "too many unrepresentable composite characters, try --enable-unicode3\n");
94
95 return REPLACEMENT_CHAR;
96 }
97
98 v.push_back (compose_char (c1, c2));
99
100 return v.size () - 1 + COMPOSE_LO;
59} 101}
102
103int rxvt_composite_vec::expand (unicode_t c, wchar_t *r)
104{
105 compose_char *cc = (*this)[c];
106
107 if (!cc)
108 {
109 if (r) *r = c;
110 return 1;
111 }
112
113 int len = expand (cc->c1, r);
114
115 if (r) r += len;
116
117 if (cc->c2 != NOCHAR)
118 {
119 len++;
120 if (r) *r++ = cc->c2;
121 }
122
123 return len;
124
125}
126#endif
60 127
61void * 128void *
62rxvt_term::operator new (size_t s) 129rxvt_term::operator new (size_t s)
63{ 130{
64 void *p = malloc (s); 131 void *p = malloc (s);
88 cursor_blink_ev (this, &rxvt_term::cursor_blink_cb), 155 cursor_blink_ev (this, &rxvt_term::cursor_blink_cb),
89#endif 156#endif
90#ifdef TEXT_BLINK 157#ifdef TEXT_BLINK
91 text_blink_ev (this, &rxvt_term::text_blink_cb), 158 text_blink_ev (this, &rxvt_term::text_blink_cb),
92#endif 159#endif
160#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
161 cont_scroll_ev (this, &rxvt_term::cont_scroll_cb),
162#endif
163#ifdef SELECTION_SCROLLING
164 sel_scroll_ev (this, &rxvt_term::sel_scroll_cb),
165#endif
166#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
167 slip_wheel_ev (this, &rxvt_term::slip_wheel_cb),
168#endif
93#ifdef POINTER_BLANK 169#ifdef POINTER_BLANK
94 pointer_ev (this, &rxvt_term::pointer_cb), 170 pointer_ev (this, &rxvt_term::pointer_cb),
95#endif 171#endif
96#ifdef USE_XIM 172#ifdef USE_XIM
97 im_ev (this, &rxvt_term::im_cb), 173 im_ev (this, &rxvt_term::im_cb),
100 destroy_ev (this, &rxvt_term::destroy_cb), 176 destroy_ev (this, &rxvt_term::destroy_cb),
101 pty_ev (this, &rxvt_term::pty_cb), 177 pty_ev (this, &rxvt_term::pty_cb),
102 incr_ev (this, &rxvt_term::incr_cb) 178 incr_ev (this, &rxvt_term::incr_cb)
103{ 179{
104 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; 180 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base;
181
182 termlist.push_back (this);
105} 183}
106 184
107rxvt_term::~rxvt_term () 185rxvt_term::~rxvt_term ()
108{ 186{
187 termlist.erase (find (termlist.begin (), termlist.end(), this));
188
109 if (cmd_fd >= 0) 189 if (cmd_fd >= 0)
110 close (cmd_fd); 190 close (cmd_fd);
111 191
112#ifndef NO_SETOWNER_TTYDEV 192#ifndef NO_SETOWNER_TTYDEV
113 privileged_ttydev (RESTORE); 193 privileged_ttydev (RESTORE);
118 198
119 delete TermWin.fontset; 199 delete TermWin.fontset;
120 200
121 if (display) 201 if (display)
122 { 202 {
203 selection_clear ();
204
205#ifdef MENUBAR
206 if (menubarGC) XFreeGC (display->display, menubarGC);
207#endif
208#ifdef XTERM_SCROLLBAR
209 if (xscrollbarGC) XFreeGC (display->display, xscrollbarGC);
210 if (ShadowGC) XFreeGC (display->display, ShadowGC);
211#endif
212#ifdef PLAIN_SCROLLBAR
213 if (pscrollbarGC) XFreeGC (display->display, pscrollbarGC);
214#endif
215#ifdef NEXT_SCROLLBAR
216 if (blackGC) XFreeGC (display->display, blackGC);
217 if (whiteGC) XFreeGC (display->display, whiteGC);
218 if (grayGC) XFreeGC (display->display, grayGC);
219 if (darkGC) XFreeGC (display->display, darkGC);
220 if (stippleGC) XFreeGC (display->display, stippleGC);
221 if (dimple) XFreePixmap (display->display, dimple);
222 if (upArrow) XFreePixmap (display->display, upArrow);
223 if (downArrow) XFreePixmap (display->display, downArrow);
224 if (upArrowHi) XFreePixmap (display->display, upArrowHi);
225 if (downArrowHi) XFreePixmap (display->display, downArrowHi);
226#endif
227#if defined(MENUBAR) || defined(RXVT_SCROLLBAR)
228 if (topShadowGC) XFreeGC (display->display, topShadowGC);
229 if (botShadowGC) XFreeGC (display->display, botShadowGC);
230 if (scrollbarGC) XFreeGC (display->display, scrollbarGC);
231#endif
232 if (TermWin.gc) XFreeGC (display->display, TermWin.gc);
233
123#if defined(MENUBAR) && (MENUBAR_MAX > 1) 234#if defined(MENUBAR) && (MENUBAR_MAX > 1)
124 delete menuBar.drawable; 235 delete menuBar.drawable;
125 //if (menuBar.win) 236 //if (menuBar.win)
126 // XDestroyWindow (display->display, menuBar.win); 237 // XDestroyWindow (display->display, menuBar.win);
127#endif 238#endif
137 248
138 displays.put (display); 249 displays.put (display);
139 250
140 scr_release (); 251 scr_release ();
141 252
253 /* clear all resources */
254 for (int i = 0; i < allocated.size (); i++)
255 free (allocated[i]);
256
257 free (selection.text);
258 // TODO: manage env vars in child only(!)
142 free (env_windowid); 259 free (env_windowid);
143 free (env_display); 260 free (env_display);
144 free (env_term); 261 free (env_term);
145 free (env_colorfgbg); 262 free (env_colorfgbg);
146 free (locale); 263 free (locale);
264#if 0
147 free (codeset); 265 free (codeset);
266#endif
148 267
149 delete envv; 268 delete envv;
150 delete argv; 269 delete argv;
151} 270}
152 271
176 cursor_blink_ev.stop (); 295 cursor_blink_ev.stop ();
177#endif 296#endif
178#ifdef TEXT_BLINK 297#ifdef TEXT_BLINK
179 text_blink_ev.stop (); 298 text_blink_ev.stop ();
180#endif 299#endif
300#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
301 cont_scroll_ev.stop ();
302#endif
303#ifdef SELECTION_SCROLLING
304 sel_scroll_ev.stop ();
305#endif
181#ifdef POINTER_BLANK 306#ifdef POINTER_BLANK
182 pointer_ev.stop (); 307 pointer_ev.stop ();
183#endif 308#endif
184 309
185 destroy_ev.start (0); 310 destroy_ev.start (0);
193 delete this; 318 delete this;
194} 319}
195 320
196/*----------------------------------------------------------------------*/ 321/*----------------------------------------------------------------------*/
197/* rxvt_init () */ 322/* rxvt_init () */
198/* LIBPROTO */
199rxvt_t
200rxvt_init (int argc, const char *const *argv)
201{
202 SET_R (new rxvt_term);
203
204 if (!GET_R->init_vars () || !GET_R->init (argc, argv))
205 {
206 delete GET_R;
207 SET_R (0);
208 }
209
210 return GET_R;
211}
212
213static int (*old_xerror_handler) (Display *dpy, XErrorEvent *event);
214
215void
216rxvt_init_signals ()
217{
218 /* install exit handler for cleanup */
219#if 0
220#ifdef HAVE_ATEXIT
221 atexit (rxvt_clean_exit);
222#else
223#endif
224#endif
225
226 struct sigaction sa;
227
228 sigfillset (&sa.sa_mask);
229 sa.sa_flags = SA_NOCLDSTOP | SA_RESTART;
230 sa.sa_handler = SIG_IGN; sigaction (SIGHUP , &sa, 0);
231 sa.sa_handler = SIG_IGN; sigaction (SIGPIPE, &sa, 0);
232 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGINT , &sa, 0);
233 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGQUIT, &sa, 0);
234 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGTERM, &sa, 0);
235 sa.sa_handler = rxvt_Child_signal; sigaction (SIGCHLD, &sa, 0);
236
237 /* need to trap SIGURG for SVR4 (Unixware) rlogin */
238 /* signal (SIGURG, SIG_DFL); */
239
240 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
241 //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler);
242}
243
244bool 323bool
245rxvt_term::init (int argc, const char *const *argv) 324rxvt_term::init (int argc, const char *const *argv)
246{ 325{
326 SET_R (this);
327
328 if (!init_vars ())
329 return false;
330
247 /* 331 /*
248 * Save and then give up any super-user privileges 332 * Save and then give up any super-user privileges
249 * If we need privileges in any area then we must specifically request it. 333 * If we need privileges in any area then we must specifically request it.
250 * We should only need to be root in these cases: 334 * We should only need to be root in these cases:
251 * 1. write utmp entries on some systems 335 * 1. write utmp entries on some systems
306 check_ev.start (); 390 check_ev.start ();
307 391
308 return true; 392 return true;
309} 393}
310 394
395static int (*old_xerror_handler) (Display *dpy, XErrorEvent *event);
396
397void
398rxvt_init_signals ()
399{
400 /* install exit handler for cleanup */
401#if 0
402#ifdef HAVE_ATEXIT
403 atexit (rxvt_clean_exit);
404#else
405#endif
406#endif
407
408 struct sigaction sa;
409
410 sigfillset (&sa.sa_mask);
411 sa.sa_flags = SA_NOCLDSTOP | SA_RESTART;
412 sa.sa_handler = SIG_IGN; sigaction (SIGHUP , &sa, 0);
413 sa.sa_handler = SIG_IGN; sigaction (SIGPIPE, &sa, 0);
414 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGINT , &sa, 0);
415 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGQUIT, &sa, 0);
416 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGTERM, &sa, 0);
417 sa.sa_handler = rxvt_Child_signal; sigaction (SIGCHLD, &sa, 0);
418
419 /* need to trap SIGURG for SVR4 (Unixware) rlogin */
420 /* signal (SIGURG, SIG_DFL); */
421
422 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
423 //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler);
424}
425
311/* ------------------------------------------------------------------------- * 426/* ------------------------------------------------------------------------- *
312 * SIGNAL HANDLING & EXIT HANDLER * 427 * SIGNAL HANDLING & EXIT HANDLER *
313 * ------------------------------------------------------------------------- */ 428 * ------------------------------------------------------------------------- */
314/* 429/*
315 * Catch a SIGCHLD signal and exit if the direct child has died 430 * Catch a SIGCHLD signal and exit if the direct child has died
316 */ 431 */
432
433void rxvt_term::child_exited (int pid)
434{
435 for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++)
436 if (pid == (*t)->cmd_pid)
437 {
438 (*t)->destroy ();
439 break;
440 }
441}
442
317/* ARGSUSED */ 443/* ARGSUSED */
318/* EXTPROTO */ 444/* EXTPROTO */
319RETSIGTYPE 445RETSIGTYPE
320rxvt_Child_signal (int sig __attribute__ ((unused))) 446rxvt_Child_signal (int sig __attribute__ ((unused)))
321{ 447{
322 int pid, save_errno = errno; 448 int pid, save_errno = errno;
449
323 while ((pid = waitpid (-1, NULL, WNOHANG)) == -1 && errno == EINTR) 450 while ((pid = waitpid (-1, NULL, WNOHANG)) > 0)
324 ; 451 rxvt_term::child_exited (pid);
452
325 errno = save_errno; 453 errno = save_errno;
326
327#if 0
328 if (pid == cmd_pid)
329 exit (EXIT_SUCCESS);
330#endif
331} 454}
332 455
333/* 456/*
334 * Catch a fatal signal and tidy up before quitting 457 * Catch a fatal signal and tidy up before quitting
335 */ 458 */
337RETSIGTYPE 460RETSIGTYPE
338rxvt_Exit_signal (int sig) 461rxvt_Exit_signal (int sig)
339{ 462{
340 signal (sig, SIG_DFL); 463 signal (sig, SIG_DFL);
341#ifdef DEBUG_CMD 464#ifdef DEBUG_CMD
342 rxvt_print_error ("signal %d", sig); 465 rxvt_warn ("caught signal %d, exiting.\n", sig);
343#endif 466#endif
344 rxvt_clean_exit (); 467 rxvt_clean_exit ();
345 kill (getpid (), sig); 468 kill (getpid (), sig);
346} 469}
347 470
385 508
386 p = malloc (size); 509 p = malloc (size);
387 if (p) 510 if (p)
388 return p; 511 return p;
389 512
390 fprintf (stderr, APL_NAME ": memory allocation failure. Aborting"); 513 fprintf (stderr, RESNAME ": memory allocation failure. Aborting");
391 rxvt_clean_exit (); 514 rxvt_clean_exit ();
392 exit (EXIT_FAILURE); 515 exit (EXIT_FAILURE);
393 /* NOTREACHED */ 516 /* NOTREACHED */
394} 517}
395 518
401 524
402 p = calloc (number, size); 525 p = calloc (number, size);
403 if (p) 526 if (p)
404 return p; 527 return p;
405 528
406 fprintf (stderr, APL_NAME ": memory allocation failure. Aborting"); 529 fprintf (stderr, RESNAME ": memory allocation failure. Aborting");
407 rxvt_clean_exit (); 530 rxvt_clean_exit ();
408 exit (EXIT_FAILURE); 531 exit (EXIT_FAILURE);
409 /* NOTREACHED */ 532 /* NOTREACHED */
410} 533}
411 534
420 else 543 else
421 p = malloc (size); 544 p = malloc (size);
422 if (p) 545 if (p)
423 return p; 546 return p;
424 547
425 fprintf (stderr, APL_NAME ": memory allocation failure. Aborting"); 548 fprintf (stderr, RESNAME ": memory allocation failure. Aborting");
426 rxvt_clean_exit (); 549 rxvt_clean_exit ();
427 exit (EXIT_FAILURE); 550 exit (EXIT_FAILURE);
428 /* NOTREACHED */ 551 /* NOTREACHED */
429} 552}
430 553
622 else 745 else
623 szHint.win_gravity = SouthWestGravity; 746 szHint.win_gravity = SouthWestGravity;
624 } 747 }
625 } 748 }
626 } 749 }
750
627 /* TODO: BOUNDS */ 751 /* TODO: BOUNDS */
628 TermWin.width = TermWin.ncol * TermWin.fwidth; 752 TermWin.width = TermWin.ncol * TermWin.fwidth;
629 TermWin.height = TermWin.nrow * TermWin.fheight; 753 TermWin.height = TermWin.nrow * TermWin.fheight;
630 max_width = MAX_COLS * TermWin.fwidth; 754 max_width = MAX_COLS * TermWin.fwidth;
631 max_height = MAX_ROWS * TermWin.fheight; 755 max_height = MAX_ROWS * TermWin.fheight;
632 756
633 szHint.base_width = szHint.base_height = 2 * TermWin.int_bwidth; 757 szHint.base_width = szHint.base_height = 2 * TermWin.int_bwidth;
634 758
635 sb_w = mb_h = 0; 759 sb_w = mb_h = 0;
636 window_vt_x = window_vt_y = 0; 760 window_vt_x = window_vt_y = TermWin.int_bwidth;
761
637 if (scrollbar_visible ()) 762 if (scrollbar_visible ())
638 { 763 {
639 sb_w = scrollbar_TotalWidth (); 764 sb_w = scrollbar_TotalWidth ();
640 szHint.base_width += sb_w; 765 szHint.base_width += sb_w;
641 if (! (Options & Opt_scrollBar_right)) 766 if (!(Options & Opt_scrollBar_right))
642 window_vt_x = sb_w; 767 window_vt_x += sb_w;
643 } 768 }
769
644 if (menubar_visible ()) 770 if (menubar_visible ())
645 { 771 {
646 mb_h = menuBar_TotalHeight (); 772 mb_h = menuBar_TotalHeight ();
647 szHint.base_height += mb_h; 773 szHint.base_height += mb_h;
648 window_vt_y = mb_h; 774 window_vt_y += mb_h;
649 } 775 }
776
650 szHint.width_inc = TermWin.fwidth; 777 szHint.width_inc = TermWin.fwidth;
651 szHint.height_inc = TermWin.fheight; 778 szHint.height_inc = TermWin.fheight;
652 szHint.min_width = szHint.base_width + szHint.width_inc; 779 szHint.min_width = szHint.base_width + szHint.width_inc;
653 szHint.min_height = szHint.base_height + szHint.height_inc; 780 szHint.min_height = szHint.base_height + szHint.height_inc;
654 781
660 else 787 else
661 { 788 {
662 MIN_IT (TermWin.width, max_width); 789 MIN_IT (TermWin.width, max_width);
663 szHint.width = szHint.base_width + TermWin.width; 790 szHint.width = szHint.base_width + TermWin.width;
664 } 791 }
792
665 if (height && height - szHint.base_height < max_height) 793 if (height && height - szHint.base_height < max_height)
666 { 794 {
667 szHint.height = height; 795 szHint.height = height;
668 TermWin.height = height - szHint.base_height; 796 TermWin.height = height - szHint.base_height;
669 } 797 }
670 else 798 else
671 { 799 {
672 MIN_IT (TermWin.height, max_height); 800 MIN_IT (TermWin.height, max_height);
673 szHint.height = szHint.base_height + TermWin.height; 801 szHint.height = szHint.base_height + TermWin.height;
674 } 802 }
803
675 if (scrollbar_visible () && (Options & Opt_scrollBar_right)) 804 if (scrollbar_visible () && (Options & Opt_scrollBar_right))
676 window_sb_x = szHint.width - sb_w; 805 window_sb_x = szHint.width - sb_w;
677 806
678 if (recalc_x) 807 if (recalc_x)
679 szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display)) 808 szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display))
739 } 868 }
740 else 869 else
741 { 870 {
742 rxvt_fontset *fs = new rxvt_fontset (this); 871 rxvt_fontset *fs = new rxvt_fontset (this);
743 872
744 if (fs && fs->populate (fontname)) 873 if (fs && fs->populate (fontname ? fontname : "fixed"))
745 { 874 {
746 delete TermWin.fontset; 875 delete TermWin.fontset;
747 TermWin.fontset = fs; 876 TermWin.fontset = fs;
748 TermWin.fwidth = fs->base_font ()->width; 877 TermWin.fwidth = fs->base_font ()->width;
749 TermWin.fheight = fs->base_font ()->height; 878 TermWin.fheight = fs->base_font ()->height;
750 TermWin.fbase = fs->base_font ()->ascent; 879 TermWin.fbase = fs->base_font ()->ascent;
751 880
752 // TODO: screen needs to be told about new fonts
753
754 if (TermWin.parent[0]) 881 if (TermWin.parent[0])
755 { 882 {
756 resize_all_windows (0, 0, 0); 883 resize_all_windows (0, 0, 0);
757 scr_remap_chars (); 884 scr_remap_chars ();
758 scr_touch (true); 885 scr_touch (true);
775/*----------------------------------------------------------------------*/ 902/*----------------------------------------------------------------------*/
776/* xterm sequences - title, iconName, color (exptl) */ 903/* xterm sequences - title, iconName, color (exptl) */
777void 904void
778rxvt_term::set_title (const char *str) 905rxvt_term::set_title (const char *str)
779{ 906{
780#ifndef SMART_WINDOW_TITLE 907#ifdef SMART_WINDOW_TITLE
781 XStoreName (display->display, TermWin.parent[0], str); 908 char *name;
782#else
783 char *name;
784 909
785 if (XFetchName (display->display, TermWin.parent[0], &name) == 0) 910 if (!XFetchName (display->display, TermWin.parent[0], &name))
786 name = NULL; 911 name = NULL;
912
787 if (name == NULL || STRCMP (name, str)) 913 if (name == NULL || STRCMP (name, str))
914#endif
788 XStoreName (display->display, TermWin.parent[0], str); 915 XStoreName (display->display, TermWin.parent[0], str);
916
917#ifdef SMART_WINDOW_TITLE
789 if (name) 918 if (name)
790 XFree (name); 919 XFree (name);
791#endif 920#endif
792} 921}
793 922
794void 923void
795rxvt_term::set_iconName (const char *str) 924rxvt_term::set_icon_name (const char *str)
796{ 925{
797#ifndef SMART_WINDOW_TITLE 926#ifdef SMART_WINDOW_TITLE
798 XSetIconName (display->display, TermWin.parent[0], str); 927 char *name;
799#else
800 char *name;
801 928
802 if (XGetIconName (display->display, TermWin.parent[0], &name)) 929 if (!XGetIconName (display->display, TermWin.parent[0], &name))
803 name = NULL; 930 name = NULL;
931
804 if (name == NULL || STRCMP (name, str)) 932 if (name == NULL || STRCMP (name, str))
933#endif
805 XSetIconName (display->display, TermWin.parent[0], str); 934 XSetIconName (display->display, TermWin.parent[0], str);
935
936#ifdef SMART_WINDOW_TITLE
806 if (name) 937 if (name)
807 XFree (name); 938 XFree (name);
808#endif 939#endif
809} 940}
810 941
811#ifdef XTERM_COLOR_CHANGE 942#ifdef XTERM_COLOR_CHANGE
812void 943void
813rxvt_term::set_window_color (int idx, const char *color) 944rxvt_term::set_window_color (int idx, const char *color)
814{ 945{
815 rxvt_color xcol; 946 rxvt_color xcol;
816 int i; 947 int i;
817 948
818 if (color == NULL || *color == '\0') 949 if (color == NULL || *color == '\0')
819 return; 950 return;
820 951
821 /* handle color aliases */ 952 /* handle color aliases */
837 PixColors[idx] = PixColors[minCOLOR + i]; 968 PixColors[idx] = PixColors[minCOLOR + i];
838 SET_PIXCOLOR (idx); 969 SET_PIXCOLOR (idx);
839 goto Done; 970 goto Done;
840 } 971 }
841 } 972 }
973
842 if (!rXParseAllocColor (& xcol, color)) 974 if (!rXParseAllocColor (& xcol, color))
843 return; 975 return;
976
844 /* XStoreColor (display->display, XCMAP, XColor*); */ 977 /* XStoreColor (display->display, XCMAP, XColor*); */
845 978
846 /* 979 /*
847 * FIXME: should free colors here, but no idea how to do it so instead, 980 * FIXME: should free colors here, but no idea how to do it so instead,
848 * so just keep gobbling up the colormap 981 * so just keep gobbling up the colormap
871 1004
872 /* handle Color_BD, scrollbar background, etc. */ 1005 /* handle Color_BD, scrollbar background, etc. */
873 1006
874 set_colorfgbg (); 1007 set_colorfgbg ();
875 recolour_cursor (); 1008 recolour_cursor ();
876 /* the only reasonable way to enforce a clean update */ 1009 scr_touch (true);
877 scr_poweron ();
878} 1010}
879 1011
880#else 1012#else
881# define set_window_color (idx,color) ((void)0) 1013# define set_window_color (idx,color) ((void)0)
882#endif /* XTERM_COLOR_CHANGE */ 1014#endif /* XTERM_COLOR_CHANGE */
883 1015
884void 1016void
885rxvt_term::recolour_cursor () 1017rxvt_term::recolour_cursor ()
886{ 1018{
887#if TODO
888 rxvt_color xcol[2]; 1019 XColor xcol[2];
889 1020
890 xcol[0] = PixColors[Color_pointer]; 1021 xcol[0].pixel = ISSET_PIXCOLOR (Color_pointer_fg) ? PixColors[Color_pointer_fg] : PixColors[Color_fg];
891 xcol[1] = PixColors[Color_bg]; 1022 xcol[1].pixel = ISSET_PIXCOLOR (Color_pointer_bg) ? PixColors[Color_pointer_bg] : PixColors[Color_bg];
892 XQueryColors (display->display, XCMAP, xcol, 2); 1023 XQueryColors (display->display, XCMAP, xcol, 2);
893 XRecolorCursor (display->display, TermWin_cursor, & (xcol[0]), & (xcol[1])); 1024 XRecolorCursor (display->display, TermWin_cursor, xcol + 0, xcol + 1);
894#endif
895} 1025}
896 1026
897/*----------------------------------------------------------------------*/ 1027/*----------------------------------------------------------------------*/
898/* 1028/*
899 * find if fg/bg matches any of the normal (low-intensity) colors 1029 * find if fg/bg matches any of the normal (low-intensity) colors
948int 1078int
949rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour) 1079rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour)
950{ 1080{
951 if (!screen_in_out->set (display, colour)) 1081 if (!screen_in_out->set (display, colour))
952 { 1082 {
953 rxvt_print_error ("can't allocate colour: %s", colour); 1083 rxvt_warn ("can't get colour '%s', continuing without.\n", colour);
954 return false; 1084 return false;
955 } 1085 }
956 1086
957 return true; 1087 return true;
958} 1088}
969 int old_width = szHint.width, old_height = szHint.height; 1099 int old_width = szHint.width, old_height = szHint.height;
970#endif 1100#endif
971 1101
972 window_calc (width, height); 1102 window_calc (width, height);
973 XSetWMNormalHints (display->display, TermWin.parent[0], &szHint); 1103 XSetWMNormalHints (display->display, TermWin.parent[0], &szHint);
1104
974 if (!ignoreparent) 1105 if (!ignoreparent)
975 { 1106 {
976#ifdef SMART_RESIZE 1107#ifdef SMART_RESIZE
977 /* 1108 /*
978 * resize by Marius Gedminas <marius.gedminas@uosis.mif.vu.lt> 1109 * resize by Marius Gedminas <marius.gedminas@uosis.mif.vu.lt>
1013 dy /= 2; 1144 dy /= 2;
1014 1145
1015 XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy, 1146 XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy,
1016 szHint.width, szHint.height); 1147 szHint.width, szHint.height);
1017#else 1148#else
1018 XResizeWindow (display->display, TermWin.parent[0], szHint.width, 1149 XResizeWindow (display->display, TermWin.parent[0], szHint.width, szHint.height);
1019 szHint.height);
1020#endif 1150#endif
1021
1022 } 1151 }
1023 1152
1024 fix_screen = (TermWin.ncol != prev_ncol 1153 fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow;
1025 || TermWin.nrow != prev_nrow);
1026 1154
1027 if (fix_screen || width != old_width || height != old_height) 1155 if (fix_screen || width != old_width || height != old_height)
1028 { 1156 {
1029 if (scrollbar_visible ()) 1157 if (scrollbar_visible ())
1030 { 1158 {
1031 XMoveResizeWindow (display->display, scrollBar.win, window_sb_x, 1159 XMoveResizeWindow (display->display, scrollBar.win,
1160 window_sb_x, 0,
1032 0, scrollbar_TotalWidth (), szHint.height); 1161 scrollbar_TotalWidth (), szHint.height);
1033 resize_scrollbar (); 1162 resize_scrollbar ();
1034 } 1163 }
1035 1164
1036 if (menubar_visible ()) 1165 if (menubar_visible ())
1037 XMoveResizeWindow (display->display, menuBar.win, window_vt_x, 1166 XMoveResizeWindow (display->display, menuBar.win,
1167 window_vt_x, 0,
1038 0, TermWin_TotalWidth (), menuBar_TotalHeight ()); 1168 TermWin_TotalWidth (), menuBar_TotalHeight ());
1039 1169
1040 XMoveResizeWindow (display->display, TermWin.vt, window_vt_x, 1170 XMoveResizeWindow (display->display, TermWin.vt,
1041 window_vt_y, TermWin_TotalWidth (), 1171 window_vt_x, window_vt_y,
1042 TermWin_TotalHeight ()); 1172 TermWin_TotalWidth (), TermWin_TotalHeight ());
1043 scr_clear (); 1173 scr_clear ();
1044#ifdef XPM_BACKGROUND 1174#ifdef XPM_BACKGROUND
1045 resize_pixmap (); 1175 resize_pixmap ();
1046#endif 1176#endif
1047
1048 } 1177 }
1049 1178
1050 if (fix_screen || old_height == 0) 1179 if (fix_screen || old_height == 0)
1051 { 1180 {
1052 int curr_screen = -1; 1181 int curr_screen = -1;
1325 if (preedit_attr) XFree (preedit_attr); 1454 if (preedit_attr) XFree (preedit_attr);
1326 if (status_attr) XFree (status_attr); 1455 if (status_attr) XFree (status_attr);
1327 1456
1328 if (Input_Context == NULL) 1457 if (Input_Context == NULL)
1329 { 1458 {
1330 rxvt_print_error ("failed to create input context"); 1459 rxvt_warn ("failed to create input context, continuing without XIM.\n");
1331 display->put_xim (input_method); 1460 display->put_xim (input_method);
1332 return false; 1461 return false;
1333 } 1462 }
1334 1463
1335 if (input_style & XIMPreeditArea) 1464 if (input_style & XIMPreeditArea)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines