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.48 by pcg, Wed Mar 3 04:07:52 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
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))
773/*----------------------------------------------------------------------*/ 902/*----------------------------------------------------------------------*/
774/* xterm sequences - title, iconName, color (exptl) */ 903/* xterm sequences - title, iconName, color (exptl) */
775void 904void
776rxvt_term::set_title (const char *str) 905rxvt_term::set_title (const char *str)
777{ 906{
778#ifndef SMART_WINDOW_TITLE 907#ifdef SMART_WINDOW_TITLE
779 XStoreName (display->display, TermWin.parent[0], str);
780#else
781 char *name; 908 char *name;
782 909
783 if (XFetchName (display->display, TermWin.parent[0], &name) == 0) 910 if (!XFetchName (display->display, TermWin.parent[0], &name))
784 name = NULL; 911 name = NULL;
912
785 if (name == NULL || STRCMP (name, str)) 913 if (name == NULL || STRCMP (name, str))
914#endif
786 XStoreName (display->display, TermWin.parent[0], str); 915 XStoreName (display->display, TermWin.parent[0], str);
916
917#ifdef SMART_WINDOW_TITLE
787 if (name) 918 if (name)
788 XFree (name); 919 XFree (name);
789#endif 920#endif
790} 921}
791 922
792void 923void
793rxvt_term::set_iconName (const char *str) 924rxvt_term::set_icon_name (const char *str)
794{ 925{
795#ifndef SMART_WINDOW_TITLE 926#ifdef SMART_WINDOW_TITLE
796 XSetIconName (display->display, TermWin.parent[0], str);
797#else
798 char *name; 927 char *name;
799 928
800 if (XGetIconName (display->display, TermWin.parent[0], &name)) 929 if (!XGetIconName (display->display, TermWin.parent[0], &name))
801 name = NULL; 930 name = NULL;
931
802 if (name == NULL || STRCMP (name, str)) 932 if (name == NULL || STRCMP (name, str))
933#endif
803 XSetIconName (display->display, TermWin.parent[0], str); 934 XSetIconName (display->display, TermWin.parent[0], str);
935
936#ifdef SMART_WINDOW_TITLE
804 if (name) 937 if (name)
805 XFree (name); 938 XFree (name);
806#endif 939#endif
807} 940}
808 941
835 PixColors[idx] = PixColors[minCOLOR + i]; 968 PixColors[idx] = PixColors[minCOLOR + i];
836 SET_PIXCOLOR (idx); 969 SET_PIXCOLOR (idx);
837 goto Done; 970 goto Done;
838 } 971 }
839 } 972 }
973
840 if (!rXParseAllocColor (& xcol, color)) 974 if (!rXParseAllocColor (& xcol, color))
841 return; 975 return;
976
842 /* XStoreColor (display->display, XCMAP, XColor*); */ 977 /* XStoreColor (display->display, XCMAP, XColor*); */
843 978
844 /* 979 /*
845 * 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,
846 * so just keep gobbling up the colormap 981 * so just keep gobbling up the colormap
869 1004
870 /* handle Color_BD, scrollbar background, etc. */ 1005 /* handle Color_BD, scrollbar background, etc. */
871 1006
872 set_colorfgbg (); 1007 set_colorfgbg ();
873 recolour_cursor (); 1008 recolour_cursor ();
874 /* the only reasonable way to enforce a clean update */ 1009 scr_touch (true);
875 scr_poweron ();
876} 1010}
877 1011
878#else 1012#else
879# define set_window_color (idx,color) ((void)0) 1013# define set_window_color (idx,color) ((void)0)
880#endif /* XTERM_COLOR_CHANGE */ 1014#endif /* XTERM_COLOR_CHANGE */
881 1015
882void 1016void
883rxvt_term::recolour_cursor () 1017rxvt_term::recolour_cursor ()
884{ 1018{
885#if TODO
886 rxvt_color xcol[2]; 1019 XColor xcol[2];
887 1020
888 xcol[0] = PixColors[Color_pointer]; 1021 xcol[0].pixel = ISSET_PIXCOLOR (Color_pointer_fg) ? PixColors[Color_pointer_fg] : PixColors[Color_fg];
889 xcol[1] = PixColors[Color_bg]; 1022 xcol[1].pixel = ISSET_PIXCOLOR (Color_pointer_bg) ? PixColors[Color_pointer_bg] : PixColors[Color_bg];
890 XQueryColors (display->display, XCMAP, xcol, 2); 1023 XQueryColors (display->display, XCMAP, xcol, 2);
891 XRecolorCursor (display->display, TermWin_cursor, & (xcol[0]), & (xcol[1])); 1024 XRecolorCursor (display->display, TermWin_cursor, xcol + 0, xcol + 1);
892#endif
893} 1025}
894 1026
895/*----------------------------------------------------------------------*/ 1027/*----------------------------------------------------------------------*/
896/* 1028/*
897 * 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
946int 1078int
947rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour) 1079rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour)
948{ 1080{
949 if (!screen_in_out->set (display, colour)) 1081 if (!screen_in_out->set (display, colour))
950 { 1082 {
951 rxvt_print_error ("can't allocate colour: %s", colour); 1083 rxvt_warn ("can't get colour '%s', continuing without.\n", colour);
952 return false; 1084 return false;
953 } 1085 }
954 1086
955 return true; 1087 return true;
956} 1088}
967 int old_width = szHint.width, old_height = szHint.height; 1099 int old_width = szHint.width, old_height = szHint.height;
968#endif 1100#endif
969 1101
970 window_calc (width, height); 1102 window_calc (width, height);
971 XSetWMNormalHints (display->display, TermWin.parent[0], &szHint); 1103 XSetWMNormalHints (display->display, TermWin.parent[0], &szHint);
1104
972 if (!ignoreparent) 1105 if (!ignoreparent)
973 { 1106 {
974#ifdef SMART_RESIZE 1107#ifdef SMART_RESIZE
975 /* 1108 /*
976 * resize by Marius Gedminas <marius.gedminas@uosis.mif.vu.lt> 1109 * resize by Marius Gedminas <marius.gedminas@uosis.mif.vu.lt>
1011 dy /= 2; 1144 dy /= 2;
1012 1145
1013 XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy, 1146 XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy,
1014 szHint.width, szHint.height); 1147 szHint.width, szHint.height);
1015#else 1148#else
1016 XResizeWindow (display->display, TermWin.parent[0], szHint.width, 1149 XResizeWindow (display->display, TermWin.parent[0], szHint.width, szHint.height);
1017 szHint.height);
1018#endif 1150#endif
1019
1020 } 1151 }
1021 1152
1022 fix_screen = (TermWin.ncol != prev_ncol 1153 fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow;
1023 || TermWin.nrow != prev_nrow);
1024 1154
1025 if (fix_screen || width != old_width || height != old_height) 1155 if (fix_screen || width != old_width || height != old_height)
1026 { 1156 {
1027 if (scrollbar_visible ()) 1157 if (scrollbar_visible ())
1028 { 1158 {
1029 XMoveResizeWindow (display->display, scrollBar.win, window_sb_x, 1159 XMoveResizeWindow (display->display, scrollBar.win,
1160 window_sb_x, 0,
1030 0, scrollbar_TotalWidth (), szHint.height); 1161 scrollbar_TotalWidth (), szHint.height);
1031 resize_scrollbar (); 1162 resize_scrollbar ();
1032 } 1163 }
1033 1164
1034 if (menubar_visible ()) 1165 if (menubar_visible ())
1035 XMoveResizeWindow (display->display, menuBar.win, window_vt_x, 1166 XMoveResizeWindow (display->display, menuBar.win,
1167 window_vt_x, 0,
1036 0, TermWin_TotalWidth (), menuBar_TotalHeight ()); 1168 TermWin_TotalWidth (), menuBar_TotalHeight ());
1037 1169
1038 XMoveResizeWindow (display->display, TermWin.vt, window_vt_x, 1170 XMoveResizeWindow (display->display, TermWin.vt,
1039 window_vt_y, TermWin_TotalWidth (), 1171 window_vt_x, window_vt_y,
1040 TermWin_TotalHeight ()); 1172 TermWin_TotalWidth (), TermWin_TotalHeight ());
1041 scr_clear (height != old_height); 1173 scr_clear ();
1042#ifdef XPM_BACKGROUND 1174#ifdef XPM_BACKGROUND
1043 resize_pixmap (); 1175 resize_pixmap ();
1044#endif 1176#endif
1045
1046 } 1177 }
1047 1178
1048 if (fix_screen || old_height == 0) 1179 if (fix_screen || old_height == 0)
1049 { 1180 {
1050 int curr_screen = -1; 1181 int curr_screen = -1;
1323 if (preedit_attr) XFree (preedit_attr); 1454 if (preedit_attr) XFree (preedit_attr);
1324 if (status_attr) XFree (status_attr); 1455 if (status_attr) XFree (status_attr);
1325 1456
1326 if (Input_Context == NULL) 1457 if (Input_Context == NULL)
1327 { 1458 {
1328 rxvt_print_error ("failed to create input context"); 1459 rxvt_warn ("failed to create input context, continuing without XIM.\n");
1329 display->put_xim (input_method); 1460 display->put_xim (input_method);
1330 return false; 1461 return false;
1331 } 1462 }
1332 1463
1333 if (input_style & XIMPreeditArea) 1464 if (input_style & XIMPreeditArea)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines