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.51 by pcg, Sat Mar 6 00:05:01 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);
58 } 61 return true;
59} 62}
60 63
64#if ENABLE_COMBINING
61class rxvt_composite_vec rxvt_composite; 65class rxvt_composite_vec rxvt_composite;
62 66
63text_t rxvt_composite_vec::compose (uint32_t c1, uint32_t c2) 67text_t rxvt_composite_vec::compose (unicode_t c1, unicode_t c2)
64{ 68{
65 compose_char *cc; 69 compose_char *cc;
66 70
67 // break compose chains, as stupid readline really likes to duplicate 71 // break compose chains, as stupid readline really likes to duplicate
68 // composing characters for some reason near the end of a line. 72 // composing characters for some reason near the end of a line.
94 v.push_back (compose_char (c1, c2)); 98 v.push_back (compose_char (c1, c2));
95 99
96 return v.size () - 1 + COMPOSE_LO; 100 return v.size () - 1 + COMPOSE_LO;
97} 101}
98 102
99int rxvt_composite_vec::expand (uint32_t c, wchar_t *r) 103int rxvt_composite_vec::expand (unicode_t c, wchar_t *r)
100{ 104{
101 compose_char *cc = (*this)[c]; 105 compose_char *cc = (*this)[c];
102 106
103 if (!cc) 107 if (!cc)
104 { 108 {
117 } 121 }
118 122
119 return len; 123 return len;
120 124
121} 125}
126#endif
122 127
123extern struct rxvt_composite_vec rxvt_composite;
124void * 128void *
125rxvt_term::operator new (size_t s) 129rxvt_term::operator new (size_t s)
126{ 130{
127 void *p = malloc (s); 131 void *p = malloc (s);
128 132
151 cursor_blink_ev (this, &rxvt_term::cursor_blink_cb), 155 cursor_blink_ev (this, &rxvt_term::cursor_blink_cb),
152#endif 156#endif
153#ifdef TEXT_BLINK 157#ifdef TEXT_BLINK
154 text_blink_ev (this, &rxvt_term::text_blink_cb), 158 text_blink_ev (this, &rxvt_term::text_blink_cb),
155#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
156#ifdef POINTER_BLANK 169#ifdef POINTER_BLANK
157 pointer_ev (this, &rxvt_term::pointer_cb), 170 pointer_ev (this, &rxvt_term::pointer_cb),
158#endif 171#endif
159#ifdef USE_XIM 172#ifdef USE_XIM
160 im_ev (this, &rxvt_term::im_cb), 173 im_ev (this, &rxvt_term::im_cb),
163 destroy_ev (this, &rxvt_term::destroy_cb), 176 destroy_ev (this, &rxvt_term::destroy_cb),
164 pty_ev (this, &rxvt_term::pty_cb), 177 pty_ev (this, &rxvt_term::pty_cb),
165 incr_ev (this, &rxvt_term::incr_cb) 178 incr_ev (this, &rxvt_term::incr_cb)
166{ 179{
167 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; 180 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base;
181
182 termlist.push_back (this);
168} 183}
169 184
170rxvt_term::~rxvt_term () 185rxvt_term::~rxvt_term ()
171{ 186{
187 termlist.erase (find (termlist.begin (), termlist.end(), this));
188
172 if (cmd_fd >= 0) 189 if (cmd_fd >= 0)
173 close (cmd_fd); 190 close (cmd_fd);
174 191
175#ifndef NO_SETOWNER_TTYDEV 192#ifndef NO_SETOWNER_TTYDEV
176 privileged_ttydev (RESTORE); 193 privileged_ttydev (RESTORE);
181 198
182 delete TermWin.fontset; 199 delete TermWin.fontset;
183 200
184 if (display) 201 if (display)
185 { 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
186#if defined(MENUBAR) && (MENUBAR_MAX > 1) 234#if defined(MENUBAR) && (MENUBAR_MAX > 1)
187 delete menuBar.drawable; 235 delete menuBar.drawable;
188 //if (menuBar.win) 236 //if (menuBar.win)
189 // XDestroyWindow (display->display, menuBar.win); 237 // XDestroyWindow (display->display, menuBar.win);
190#endif 238#endif
200 248
201 displays.put (display); 249 displays.put (display);
202 250
203 scr_release (); 251 scr_release ();
204 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(!)
205 free (env_windowid); 259 free (env_windowid);
206 free (env_display); 260 free (env_display);
207 free (env_term); 261 free (env_term);
208 free (env_colorfgbg); 262 free (env_colorfgbg);
209 free (locale); 263 free (locale);
264#if 0
210 free (codeset); 265 free (codeset);
266#endif
211 267
212 delete envv; 268 delete envv;
213 delete argv; 269 delete argv;
214} 270}
215 271
239 cursor_blink_ev.stop (); 295 cursor_blink_ev.stop ();
240#endif 296#endif
241#ifdef TEXT_BLINK 297#ifdef TEXT_BLINK
242 text_blink_ev.stop (); 298 text_blink_ev.stop ();
243#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
244#ifdef POINTER_BLANK 306#ifdef POINTER_BLANK
245 pointer_ev.stop (); 307 pointer_ev.stop ();
246#endif 308#endif
247 309
248 destroy_ev.start (0); 310 destroy_ev.start (0);
256 delete this; 318 delete this;
257} 319}
258 320
259/*----------------------------------------------------------------------*/ 321/*----------------------------------------------------------------------*/
260/* rxvt_init () */ 322/* rxvt_init () */
261/* LIBPROTO */
262rxvt_t
263rxvt_init (int argc, const char *const *argv)
264{
265 SET_R (new rxvt_term);
266
267 if (!GET_R->init_vars () || !GET_R->init (argc, argv))
268 {
269 delete GET_R;
270 SET_R (0);
271 }
272
273 return GET_R;
274}
275
276static int (*old_xerror_handler) (Display *dpy, XErrorEvent *event);
277
278void
279rxvt_init_signals ()
280{
281 /* install exit handler for cleanup */
282#if 0
283#ifdef HAVE_ATEXIT
284 atexit (rxvt_clean_exit);
285#else
286#endif
287#endif
288
289 struct sigaction sa;
290
291 sigfillset (&sa.sa_mask);
292 sa.sa_flags = SA_NOCLDSTOP | SA_RESTART;
293 sa.sa_handler = SIG_IGN; sigaction (SIGHUP , &sa, 0);
294 sa.sa_handler = SIG_IGN; sigaction (SIGPIPE, &sa, 0);
295 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGINT , &sa, 0);
296 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGQUIT, &sa, 0);
297 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGTERM, &sa, 0);
298 sa.sa_handler = rxvt_Child_signal; sigaction (SIGCHLD, &sa, 0);
299
300 /* need to trap SIGURG for SVR4 (Unixware) rlogin */
301 /* signal (SIGURG, SIG_DFL); */
302
303 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
304 //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler);
305}
306
307bool 323bool
308rxvt_term::init (int argc, const char *const *argv) 324rxvt_term::init (int argc, const char *const *argv)
309{ 325{
326 SET_R (this);
327
328 if (!init_vars ())
329 return false;
330
310 /* 331 /*
311 * Save and then give up any super-user privileges 332 * Save and then give up any super-user privileges
312 * 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.
313 * We should only need to be root in these cases: 334 * We should only need to be root in these cases:
314 * 1. write utmp entries on some systems 335 * 1. write utmp entries on some systems
369 check_ev.start (); 390 check_ev.start ();
370 391
371 return true; 392 return true;
372} 393}
373 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
374/* ------------------------------------------------------------------------- * 426/* ------------------------------------------------------------------------- *
375 * SIGNAL HANDLING & EXIT HANDLER * 427 * SIGNAL HANDLING & EXIT HANDLER *
376 * ------------------------------------------------------------------------- */ 428 * ------------------------------------------------------------------------- */
377/* 429/*
378 * 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
379 */ 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
380/* ARGSUSED */ 443/* ARGSUSED */
381/* EXTPROTO */ 444/* EXTPROTO */
382RETSIGTYPE 445RETSIGTYPE
383rxvt_Child_signal (int sig __attribute__ ((unused))) 446rxvt_Child_signal (int sig __attribute__ ((unused)))
384{ 447{
385 int pid, save_errno = errno; 448 int pid, save_errno = errno;
449
386 while ((pid = waitpid (-1, NULL, WNOHANG)) == -1 && errno == EINTR) 450 while ((pid = waitpid (-1, NULL, WNOHANG)) > 0)
387 ; 451 rxvt_term::child_exited (pid);
452
388 errno = save_errno; 453 errno = save_errno;
389
390#if 0
391 if (pid == cmd_pid)
392 exit (EXIT_SUCCESS);
393#endif
394} 454}
395 455
396/* 456/*
397 * Catch a fatal signal and tidy up before quitting 457 * Catch a fatal signal and tidy up before quitting
398 */ 458 */
400RETSIGTYPE 460RETSIGTYPE
401rxvt_Exit_signal (int sig) 461rxvt_Exit_signal (int sig)
402{ 462{
403 signal (sig, SIG_DFL); 463 signal (sig, SIG_DFL);
404#ifdef DEBUG_CMD 464#ifdef DEBUG_CMD
405 rxvt_print_error ("signal %d", sig); 465 rxvt_warn ("caught signal %d, exiting.\n", sig);
406#endif 466#endif
407 rxvt_clean_exit (); 467 rxvt_clean_exit ();
408 kill (getpid (), sig); 468 kill (getpid (), sig);
409} 469}
410 470
685 else 745 else
686 szHint.win_gravity = SouthWestGravity; 746 szHint.win_gravity = SouthWestGravity;
687 } 747 }
688 } 748 }
689 } 749 }
750
690 /* TODO: BOUNDS */ 751 /* TODO: BOUNDS */
691 TermWin.width = TermWin.ncol * TermWin.fwidth; 752 TermWin.width = TermWin.ncol * TermWin.fwidth;
692 TermWin.height = TermWin.nrow * TermWin.fheight; 753 TermWin.height = TermWin.nrow * TermWin.fheight;
693 max_width = MAX_COLS * TermWin.fwidth; 754 max_width = MAX_COLS * TermWin.fwidth;
694 max_height = MAX_ROWS * TermWin.fheight; 755 max_height = MAX_ROWS * TermWin.fheight;
695 756
696 szHint.base_width = szHint.base_height = 2 * TermWin.int_bwidth; 757 szHint.base_width = szHint.base_height = 2 * TermWin.int_bwidth;
697 758
698 sb_w = mb_h = 0; 759 sb_w = mb_h = 0;
699 window_vt_x = window_vt_y = 0; 760 window_vt_x = window_vt_y = TermWin.int_bwidth;
761
700 if (scrollbar_visible ()) 762 if (scrollbar_visible ())
701 { 763 {
702 sb_w = scrollbar_TotalWidth (); 764 sb_w = scrollbar_TotalWidth ();
703 szHint.base_width += sb_w; 765 szHint.base_width += sb_w;
704 if (! (Options & Opt_scrollBar_right)) 766 if (!(Options & Opt_scrollBar_right))
705 window_vt_x = sb_w; 767 window_vt_x += sb_w;
706 } 768 }
769
707 if (menubar_visible ()) 770 if (menubar_visible ())
708 { 771 {
709 mb_h = menuBar_TotalHeight (); 772 mb_h = menuBar_TotalHeight ();
710 szHint.base_height += mb_h; 773 szHint.base_height += mb_h;
711 window_vt_y = mb_h; 774 window_vt_y += mb_h;
712 } 775 }
776
713 szHint.width_inc = TermWin.fwidth; 777 szHint.width_inc = TermWin.fwidth;
714 szHint.height_inc = TermWin.fheight; 778 szHint.height_inc = TermWin.fheight;
715 szHint.min_width = szHint.base_width + szHint.width_inc; 779 szHint.min_width = szHint.base_width + szHint.width_inc;
716 szHint.min_height = szHint.base_height + szHint.height_inc; 780 szHint.min_height = szHint.base_height + szHint.height_inc;
717 781
723 else 787 else
724 { 788 {
725 MIN_IT (TermWin.width, max_width); 789 MIN_IT (TermWin.width, max_width);
726 szHint.width = szHint.base_width + TermWin.width; 790 szHint.width = szHint.base_width + TermWin.width;
727 } 791 }
792
728 if (height && height - szHint.base_height < max_height) 793 if (height && height - szHint.base_height < max_height)
729 { 794 {
730 szHint.height = height; 795 szHint.height = height;
731 TermWin.height = height - szHint.base_height; 796 TermWin.height = height - szHint.base_height;
732 } 797 }
733 else 798 else
734 { 799 {
735 MIN_IT (TermWin.height, max_height); 800 MIN_IT (TermWin.height, max_height);
736 szHint.height = szHint.base_height + TermWin.height; 801 szHint.height = szHint.base_height + TermWin.height;
737 } 802 }
803
738 if (scrollbar_visible () && (Options & Opt_scrollBar_right)) 804 if (scrollbar_visible () && (Options & Opt_scrollBar_right))
739 window_sb_x = szHint.width - sb_w; 805 window_sb_x = szHint.width - sb_w;
740 806
741 if (recalc_x) 807 if (recalc_x)
742 szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display)) 808 szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display))
836/*----------------------------------------------------------------------*/ 902/*----------------------------------------------------------------------*/
837/* xterm sequences - title, iconName, color (exptl) */ 903/* xterm sequences - title, iconName, color (exptl) */
838void 904void
839rxvt_term::set_title (const char *str) 905rxvt_term::set_title (const char *str)
840{ 906{
841#ifndef SMART_WINDOW_TITLE 907#ifdef SMART_WINDOW_TITLE
842 XStoreName (display->display, TermWin.parent[0], str);
843#else
844 char *name; 908 char *name;
845 909
846 if (XFetchName (display->display, TermWin.parent[0], &name) == 0) 910 if (!XFetchName (display->display, TermWin.parent[0], &name))
847 name = NULL; 911 name = NULL;
912
848 if (name == NULL || STRCMP (name, str)) 913 if (name == NULL || STRCMP (name, str))
914#endif
849 XStoreName (display->display, TermWin.parent[0], str); 915 XStoreName (display->display, TermWin.parent[0], str);
916
917#ifdef SMART_WINDOW_TITLE
850 if (name) 918 if (name)
851 XFree (name); 919 XFree (name);
852#endif 920#endif
853} 921}
854 922
855void 923void
856rxvt_term::set_iconName (const char *str) 924rxvt_term::set_icon_name (const char *str)
857{ 925{
858#ifndef SMART_WINDOW_TITLE 926#ifdef SMART_WINDOW_TITLE
859 XSetIconName (display->display, TermWin.parent[0], str);
860#else
861 char *name; 927 char *name;
862 928
863 if (XGetIconName (display->display, TermWin.parent[0], &name)) 929 if (!XGetIconName (display->display, TermWin.parent[0], &name))
864 name = NULL; 930 name = NULL;
931
865 if (name == NULL || STRCMP (name, str)) 932 if (name == NULL || STRCMP (name, str))
933#endif
866 XSetIconName (display->display, TermWin.parent[0], str); 934 XSetIconName (display->display, TermWin.parent[0], str);
935
936#ifdef SMART_WINDOW_TITLE
867 if (name) 937 if (name)
868 XFree (name); 938 XFree (name);
869#endif 939#endif
870} 940}
871 941
898 PixColors[idx] = PixColors[minCOLOR + i]; 968 PixColors[idx] = PixColors[minCOLOR + i];
899 SET_PIXCOLOR (idx); 969 SET_PIXCOLOR (idx);
900 goto Done; 970 goto Done;
901 } 971 }
902 } 972 }
973
903 if (!rXParseAllocColor (& xcol, color)) 974 if (!rXParseAllocColor (& xcol, color))
904 return; 975 return;
976
905 /* XStoreColor (display->display, XCMAP, XColor*); */ 977 /* XStoreColor (display->display, XCMAP, XColor*); */
906 978
907 /* 979 /*
908 * 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,
909 * so just keep gobbling up the colormap 981 * so just keep gobbling up the colormap
932 1004
933 /* handle Color_BD, scrollbar background, etc. */ 1005 /* handle Color_BD, scrollbar background, etc. */
934 1006
935 set_colorfgbg (); 1007 set_colorfgbg ();
936 recolour_cursor (); 1008 recolour_cursor ();
937 /* the only reasonable way to enforce a clean update */ 1009 scr_touch (true);
938 scr_poweron ();
939} 1010}
940 1011
941#else 1012#else
942# define set_window_color (idx,color) ((void)0) 1013# define set_window_color (idx,color) ((void)0)
943#endif /* XTERM_COLOR_CHANGE */ 1014#endif /* XTERM_COLOR_CHANGE */
944 1015
945void 1016void
946rxvt_term::recolour_cursor () 1017rxvt_term::recolour_cursor ()
947{ 1018{
948#if TODO
949 rxvt_color xcol[2]; 1019 XColor xcol[2];
950 1020
951 xcol[0] = PixColors[Color_pointer]; 1021 xcol[0].pixel = ISSET_PIXCOLOR (Color_pointer_fg) ? PixColors[Color_pointer_fg] : PixColors[Color_fg];
952 xcol[1] = PixColors[Color_bg]; 1022 xcol[1].pixel = ISSET_PIXCOLOR (Color_pointer_bg) ? PixColors[Color_pointer_bg] : PixColors[Color_bg];
953 XQueryColors (display->display, XCMAP, xcol, 2); 1023 XQueryColors (display->display, XCMAP, xcol, 2);
954 XRecolorCursor (display->display, TermWin_cursor, & (xcol[0]), & (xcol[1])); 1024 XRecolorCursor (display->display, TermWin_cursor, xcol + 0, xcol + 1);
955#endif
956} 1025}
957 1026
958/*----------------------------------------------------------------------*/ 1027/*----------------------------------------------------------------------*/
959/* 1028/*
960 * 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
1009int 1078int
1010rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour) 1079rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour)
1011{ 1080{
1012 if (!screen_in_out->set (display, colour)) 1081 if (!screen_in_out->set (display, colour))
1013 { 1082 {
1014 rxvt_print_error ("can't allocate colour: %s", colour); 1083 rxvt_warn ("can't get colour '%s', continuing without.\n", colour);
1015 return false; 1084 return false;
1016 } 1085 }
1017 1086
1018 return true; 1087 return true;
1019} 1088}
1030 int old_width = szHint.width, old_height = szHint.height; 1099 int old_width = szHint.width, old_height = szHint.height;
1031#endif 1100#endif
1032 1101
1033 window_calc (width, height); 1102 window_calc (width, height);
1034 XSetWMNormalHints (display->display, TermWin.parent[0], &szHint); 1103 XSetWMNormalHints (display->display, TermWin.parent[0], &szHint);
1104
1035 if (!ignoreparent) 1105 if (!ignoreparent)
1036 { 1106 {
1037#ifdef SMART_RESIZE 1107#ifdef SMART_RESIZE
1038 /* 1108 /*
1039 * resize by Marius Gedminas <marius.gedminas@uosis.mif.vu.lt> 1109 * resize by Marius Gedminas <marius.gedminas@uosis.mif.vu.lt>
1074 dy /= 2; 1144 dy /= 2;
1075 1145
1076 XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy, 1146 XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy,
1077 szHint.width, szHint.height); 1147 szHint.width, szHint.height);
1078#else 1148#else
1079 XResizeWindow (display->display, TermWin.parent[0], szHint.width, 1149 XResizeWindow (display->display, TermWin.parent[0], szHint.width, szHint.height);
1080 szHint.height);
1081#endif 1150#endif
1082
1083 } 1151 }
1084 1152
1085 fix_screen = (TermWin.ncol != prev_ncol 1153 fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow;
1086 || TermWin.nrow != prev_nrow);
1087 1154
1088 if (fix_screen || width != old_width || height != old_height) 1155 if (fix_screen || width != old_width || height != old_height)
1089 { 1156 {
1090 if (scrollbar_visible ()) 1157 if (scrollbar_visible ())
1091 { 1158 {
1092 XMoveResizeWindow (display->display, scrollBar.win, window_sb_x, 1159 XMoveResizeWindow (display->display, scrollBar.win,
1160 window_sb_x, 0,
1093 0, scrollbar_TotalWidth (), szHint.height); 1161 scrollbar_TotalWidth (), szHint.height);
1094 resize_scrollbar (); 1162 resize_scrollbar ();
1095 } 1163 }
1096 1164
1097 if (menubar_visible ()) 1165 if (menubar_visible ())
1098 XMoveResizeWindow (display->display, menuBar.win, window_vt_x, 1166 XMoveResizeWindow (display->display, menuBar.win,
1167 window_vt_x, 0,
1099 0, TermWin_TotalWidth (), menuBar_TotalHeight ()); 1168 TermWin_TotalWidth (), menuBar_TotalHeight ());
1100 1169
1101 XMoveResizeWindow (display->display, TermWin.vt, window_vt_x, 1170 XMoveResizeWindow (display->display, TermWin.vt,
1102 window_vt_y, TermWin_TotalWidth (), 1171 window_vt_x, window_vt_y,
1103 TermWin_TotalHeight ()); 1172 TermWin_TotalWidth (), TermWin_TotalHeight ());
1104 scr_clear (height != old_height); 1173 scr_clear ();
1105#ifdef XPM_BACKGROUND 1174#ifdef XPM_BACKGROUND
1106 resize_pixmap (); 1175 resize_pixmap ();
1107#endif 1176#endif
1108
1109 } 1177 }
1110 1178
1111 if (fix_screen || old_height == 0) 1179 if (fix_screen || old_height == 0)
1112 { 1180 {
1113 int curr_screen = -1; 1181 int curr_screen = -1;
1386 if (preedit_attr) XFree (preedit_attr); 1454 if (preedit_attr) XFree (preedit_attr);
1387 if (status_attr) XFree (status_attr); 1455 if (status_attr) XFree (status_attr);
1388 1456
1389 if (Input_Context == NULL) 1457 if (Input_Context == NULL)
1390 { 1458 {
1391 rxvt_print_error ("failed to create input context"); 1459 rxvt_warn ("failed to create input context, continuing without XIM.\n");
1392 display->put_xim (input_method); 1460 display->put_xim (input_method);
1393 return false; 1461 return false;
1394 } 1462 }
1395 1463
1396 if (input_style & XIMPreeditArea) 1464 if (input_style & XIMPreeditArea)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines