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.253 by ayin, Mon Oct 15 07:33:48 2007 UTC vs.
Revision 1.261 by root, Mon Nov 19 15:33:34 2007 UTC

38#include <limits> 38#include <limits>
39 39
40#include <csignal> 40#include <csignal>
41#include <cstring> 41#include <cstring>
42 42
43#ifdef TTY_GID_SUPPORT
44# include <grp.h>
45#endif
46
47#ifdef HAVE_TERMIOS_H 43#ifdef HAVE_TERMIOS_H
48# include <termios.h> 44# include <termios.h>
45#endif
46
47#ifdef HAVE_XSETLOCALE
48# define X_LOCALE
49# include <X11/Xlocale.h>
50#else
51# ifdef HAVE_SETLOCALE
52# include <clocale>
53# endif
49#endif 54#endif
50 55
51vector<rxvt_term *> rxvt_term::termlist; 56vector<rxvt_term *> rxvt_term::termlist;
52 57
53// used to tell global functions which terminal instance is "active" 58// used to tell global functions which terminal instance is "active"
88class rxvt_composite_vec rxvt_composite; 93class rxvt_composite_vec rxvt_composite;
89 94
90text_t rxvt_composite_vec::compose (unicode_t c1, unicode_t c2) 95text_t rxvt_composite_vec::compose (unicode_t c1, unicode_t c2)
91{ 96{
92 compose_char *cc; 97 compose_char *cc;
93 98
94 // break compose chains, as stupid readline really likes to duplicate 99 // break compose chains, as stupid readline really likes to duplicate
95 // composing characters for some reason near the end of a line. 100 // composing characters for some reason near the end of a line.
96 cc = (*this)[c1]; 101 cc = (*this)[c1];
97 while (cc) 102 while (cc)
98 { 103 {
176#endif 181#endif
177#ifdef POINTER_BLANK 182#ifdef POINTER_BLANK
178 pointer_ev (this, &rxvt_term::pointer_cb), 183 pointer_ev (this, &rxvt_term::pointer_cb),
179#endif 184#endif
180#ifdef USE_XIM 185#ifdef USE_XIM
181 im_ev (this, &rxvt_term::im_cb), 186 im_ev (this, &rxvt_term::im_cb),
182#endif 187#endif
183#ifndef NO_BELL 188#ifndef NO_BELL
184 bell_ev (this, &rxvt_term::bell_cb), 189 bell_ev (this, &rxvt_term::bell_cb),
185#endif 190#endif
186 termwin_ev (this, &rxvt_term::x_cb), 191 termwin_ev (this, &rxvt_term::x_cb),
187 vt_ev (this, &rxvt_term::x_cb), 192 vt_ev (this, &rxvt_term::x_cb),
188 child_ev (this, &rxvt_term::child_cb), 193 child_ev (this, &rxvt_term::child_cb),
189 check_ev (this, &rxvt_term::check_cb), 194 prepare_ev (this, &rxvt_term::prepare_cb),
190 flush_ev (this, &rxvt_term::flush_cb), 195 flush_ev (this, &rxvt_term::flush_cb),
191 destroy_ev (this, &rxvt_term::destroy_cb), 196 destroy_ev (this, &rxvt_term::destroy_cb),
192 pty_ev (this, &rxvt_term::pty_cb), 197 pty_ev (this, &rxvt_term::pty_cb),
193 incr_ev (this, &rxvt_term::incr_cb) 198 incr_ev (this, &rxvt_term::incr_cb)
194{ 199{
195 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; 200 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base;
196 201
197 termlist.push_back (this); 202 termlist.push_back (this);
198 203
279 delete [] pix_colors_focused; 284 delete [] pix_colors_focused;
280#if OFF_FOCUS_FADING 285#if OFF_FOCUS_FADING
281 delete [] pix_colors_unfocused; 286 delete [] pix_colors_unfocused;
282#endif 287#endif
283 288
289 bgPixmap.destroy ();
284 displays.put (display); 290 displays.put (display);
285 291
286 scr_release (); 292 scr_release ();
287 293
288 /* clear all resources */ 294 /* clear all resources */
305#endif 311#endif
306} 312}
307 313
308// child has exited, usually destroys 314// child has exited, usually destroys
309void 315void
310rxvt_term::child_cb (child_watcher &w, int status) 316rxvt_term::child_cb (ev::child &w, int status)
311{ 317{
312 HOOK_INVOKE ((this, HOOK_CHILD_EXIT, DT_INT, status, DT_END)); 318 HOOK_INVOKE ((this, HOOK_CHILD_EXIT, DT_INT, status, DT_END));
313 319
314 cmd_pid = 0; 320 cmd_pid = 0;
315 321
343 incr_ev.stop (); 349 incr_ev.stop ();
344 termwin_ev.stop (display); 350 termwin_ev.stop (display);
345 vt_ev.stop (display); 351 vt_ev.stop (display);
346 } 352 }
347 353
348 check_ev.stop (); 354 prepare_ev.stop ();
349 pty_ev.stop (); 355 pty_ev.stop ();
350#ifdef CURSOR_BLINK 356#ifdef CURSOR_BLINK
351 cursor_blink_ev.stop (); 357 cursor_blink_ev.stop ();
352#endif 358#endif
353#ifdef TEXT_BLINK 359#ifdef TEXT_BLINK
361#endif 367#endif
362#ifdef POINTER_BLANK 368#ifdef POINTER_BLANK
363 pointer_ev.stop (); 369 pointer_ev.stop ();
364#endif 370#endif
365 371
366 destroy_ev.start (0); 372 destroy_ev.start ();
367} 373}
368 374
369void 375void
370rxvt_term::destroy_cb (time_watcher &w) 376rxvt_term::destroy_cb (ev::idle &w, int revents)
371{ 377{
372 make_current (); 378 make_current ();
373 379
374 delete this; 380 delete this;
375} 381}
429 else 435 else
430 XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x", 436 XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
431 mesg, BUFSIZ); 437 mesg, BUFSIZ);
432 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->resourceid); 438 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->resourceid);
433 } 439 }
434 XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d", 440 XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
435 mesg, BUFSIZ); 441 mesg, BUFSIZ);
436 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->serial); 442 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->serial);
437} 443}
438#endif 444#endif
439 445
513 519
514#ifdef ENABLE_TRANSPARENCY 520#ifdef ENABLE_TRANSPARENCY
515 if (option (Opt_transparent)) 521 if (option (Opt_transparent))
516 { 522 {
517 bgPixmap.set_transparent (); 523 bgPixmap.set_transparent ();
518#ifdef HAVE_AFTERIMAGE 524#ifdef HAVE_AFTERIMAGE
519 if (rs [Rs_blurradius]) 525 if (rs [Rs_blurradius])
520 bgPixmap.set_blur_radius (rs [Rs_blurradius]); 526 bgPixmap.set_blur_radius (rs [Rs_blurradius]);
521#endif 527#endif
522 if (ISSET_PIXCOLOR (Color_tint)) 528 if (ISSET_PIXCOLOR (Color_tint))
523 bgPixmap.set_tint (pix_colors_focused [Color_tint]); 529 bgPixmap.set_tint (pix_colors_focused [Color_tint]);
524 if (rs [Rs_shade]) 530 if (rs [Rs_shade])
525 bgPixmap.set_shade (rs [Rs_shade]); 531 bgPixmap.set_shade (rs [Rs_shade]);
526 532
560 init_command (cmd_argv); 566 init_command (cmd_argv);
561 567
562 free (cmd_argv); 568 free (cmd_argv);
563 569
564 if (pty->pty >= 0) 570 if (pty->pty >= 0)
565 pty_ev.start (pty->pty, EVENT_READ); 571 pty_ev.start (pty->pty, ev::READ);
566 572
567 check_ev.start (); 573 prepare_ev.start ();
568 574
569 HOOK_INVOKE ((this, HOOK_START, DT_END)); 575 HOOK_INVOKE ((this, HOOK_START, DT_END));
570 576
571#if ENABLE_XEMBED 577#if ENABLE_XEMBED
572 if (rs[Rs_embed]) 578 if (rs[Rs_embed])
584 return true; 590 return true;
585} 591}
586 592
587static struct sig_handlers 593static struct sig_handlers
588{ 594{
589 sig_watcher sw_term, sw_int; 595 ev::sig sw_term, sw_int;
590 596
591 /* 597 /*
592 * Catch a fatal signal and tidy up before quitting 598 * Catch a fatal signal and tidy up before quitting
593 */ 599 */
594 void 600 void
595 sig_term (sig_watcher &w) 601 sig_term (ev::sig &w, int revents)
596 { 602 {
597 rxvt_emergency_cleanup (); 603 rxvt_emergency_cleanup ();
598 signal (w.signum, SIG_DFL); 604 w.stop ();
599 kill (getpid (), w.signum); 605 kill (getpid (), w.signum);
600 } 606 }
601 607
602 sig_handlers () 608 sig_handlers ()
603 : sw_term (this, &sig_handlers::sig_term), 609 : sw_term (this, &sig_handlers::sig_term),
611void 617void
612rxvt_init () 618rxvt_init ()
613{ 619{
614 ptytty::init (); 620 ptytty::init ();
615 621
622 if (!ev::ev_default_loop (0))
623 rxvt_fatal ("cannot initialise libev (bad value for LIBEV_METHODS?)\n");
624
616 rxvt_environ = environ; 625 rxvt_environ = environ;
617 626
618 signal (SIGHUP, SIG_IGN); 627 signal (SIGHUP, SIG_IGN);
619 signal (SIGPIPE, SIG_IGN); 628 signal (SIGPIPE, SIG_IGN);
620 629
621 sig_handlers.sw_term.start (SIGTERM); 630 sig_handlers.sw_term.start (SIGTERM); ev::ev_unref ();
622 sig_handlers.sw_int.start (SIGINT); 631 sig_handlers.sw_int.start (SIGINT); ev::ev_unref ();
623 632
624 /* need to trap SIGURG for SVR4 (Unixware) rlogin */ 633 /* need to trap SIGURG for SVR4 (Unixware) rlogin */
625 /* signal (SIGURG, SIG_DFL); */ 634 /* signal (SIGURG, SIG_DFL); */
626 635
627 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); 636 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
897 if (parent[0]) 906 if (parent[0])
898 { 907 {
899 resize_all_windows (0, 0, 0); 908 resize_all_windows (0, 0, 0);
900 scr_remap_chars (); 909 scr_remap_chars ();
901 scr_touch (true); 910 scr_touch (true);
902 } 911 }
903 912
904 return true; 913 return true;
905} 914}
906 915
907void 916void
951rxvt_term::set_window_color (int idx, const char *color) 960rxvt_term::set_window_color (int idx, const char *color)
952{ 961{
953#ifdef XTERM_COLOR_CHANGE 962#ifdef XTERM_COLOR_CHANGE
954 rxvt_color xcol; 963 rxvt_color xcol;
955 int i; 964 int i;
956 965
957 if (color == NULL || *color == '\0') 966 if (color == NULL || *color == '\0')
958 return; 967 return;
959 968
960 color = strdup (color); 969 color = strdup (color);
961 allocated.push_back ((void *)color); 970 allocated.push_back ((void *)color);
995 /*TODO: handle Color_BD, scrollbar background, etc. */ 1004 /*TODO: handle Color_BD, scrollbar background, etc. */
996 1005
997 update_fade_color (idx); 1006 update_fade_color (idx);
998 recolour_cursor (); 1007 recolour_cursor ();
999 scr_recolour (); 1008 scr_recolour ();
1000#endif /* XTERM_COLOR_CHANGE */ 1009#endif /* XTERM_COLOR_CHANGE */
1001} 1010}
1002 1011
1003void 1012void
1004rxvt_term::recolour_cursor () 1013rxvt_term::recolour_cursor ()
1005{ 1014{
1342 if (term->rs[Rs_imLocale]) 1351 if (term->rs[Rs_imLocale])
1343 SET_LOCALE (term->locale); 1352 SET_LOCALE (term->locale);
1344 } 1353 }
1345 else 1354 else
1346 str = (void *)text->string.wide_char; 1355 str = (void *)text->string.wide_char;
1347 1356
1348 HOOK_INVOKE ((term, HOOK_XIM_PREEDIT_DRAW, 1357 HOOK_INVOKE ((term, HOOK_XIM_PREEDIT_DRAW,
1349 DT_INT, call_data->caret, 1358 DT_INT, call_data->caret,
1350 DT_INT, call_data->chg_first, 1359 DT_INT, call_data->chg_first,
1351 DT_INT, call_data->chg_length, 1360 DT_INT, call_data->chg_length,
1352 DT_LCS_LEN, (void *)text->feedback, text->feedback ? (int)text->length : 0, 1361 DT_LCS_LEN, (void *)text->feedback, text->feedback ? (int)text->length : 0,
1671 1680
1672 if (input_style & XIMPreeditPosition) 1681 if (input_style & XIMPreeditPosition)
1673 { 1682 {
1674 im_set_size (preedit_rect); 1683 im_set_size (preedit_rect);
1675 preedit_attr = XVaCreateNestedList (0, XNArea, &preedit_rect, NULL); 1684 preedit_attr = XVaCreateNestedList (0, XNArea, &preedit_rect, NULL);
1676 1685
1677 XSetICValues (Input_Context, 1686 XSetICValues (Input_Context,
1678 XNPreeditAttributes, preedit_attr, NULL); 1687 XNPreeditAttributes, preedit_attr, NULL);
1679 } 1688 }
1680 else 1689 else
1681 { 1690 {
1698 XFree (status_attr); 1707 XFree (status_attr);
1699 } 1708 }
1700 1709
1701 XFree (preedit_attr); 1710 XFree (preedit_attr);
1702} 1711}
1703#endif /* USE_XIM */ 1712#endif /* USE_XIM */
1704 1713
1705void 1714void
1706rxvt_term::get_window_origin (int &x, int &y) 1715rxvt_term::get_window_origin (int &x, int &y)
1707{ 1716{
1708 Window cr; 1717 Window cr;
1730 } 1739 }
1731 return None; 1740 return None;
1732} 1741}
1733 1742
1734#ifdef HAVE_BG_PIXMAP 1743#ifdef HAVE_BG_PIXMAP
1744# if TRACE_PIXMAPS
1745# undef update_background
1746int rxvt_term::trace_update_background (const char* file, int line)
1747{
1748 fprintf (stderr, "%s:%d:update_background()\n", file, line);
1749 update_background ();
1750}
1751# endif
1735int 1752int
1736rxvt_term::update_background () 1753rxvt_term::update_background ()
1737{ 1754{
1738 bgPixmap.invalidate (); 1755 bgPixmap.invalidate ();
1739 1756
1740 /* no chance of real time refresh if we are blurring ! */ 1757 /* no chance of real time refresh if we are blurring! */
1741 if (bgPixmap.invalid_since + 0.5 < NOW && !(bgPixmap.flags & bgPixmap_t::blurNeeded)) 1758 if (bgPixmap.invalid_since + 0.5 < ev::now () && !(bgPixmap.flags & bgPixmap_t::blurNeeded))
1742 bgPixmap.render (); 1759 bgPixmap.render ();
1743 else 1760 else
1744 { 1761 {
1745 update_background_ev.stop (); 1762 update_background_ev.stop ();
1763
1746 if (!bgPixmap.need_client_side_rendering()) 1764 if (!bgPixmap.need_client_side_rendering())
1747 update_background_ev.start (NOW + .05); 1765 update_background_ev.start (.05);
1748 else if (bgPixmap.flags & bgPixmap_t::blurNeeded) 1766 else if (bgPixmap.flags & bgPixmap_t::blurNeeded)
1749 update_background_ev.start (NOW + .2); /* very slow !!! */ 1767 update_background_ev.start (.20); /* very slow !!! */
1750 else 1768 else
1751 update_background_ev.start (NOW + .07); 1769 update_background_ev.start (.07);
1752 } 1770 }
1771
1753 return 0; 1772 return 0;
1754} 1773}
1755 1774
1756void 1775void
1757rxvt_term::update_background_cb (time_watcher &w) 1776rxvt_term::update_background_cb (ev::timer &w, int revents)
1758{ 1777{
1759 bgPixmap.render (); 1778 bgPixmap.render ();
1760} 1779}
1761 1780
1762#endif /* HAVE_BG_PIXMAP */ 1781#endif /* HAVE_BG_PIXMAP */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines