--- rxvt-unicode/src/main.C 2007/10/08 07:05:23 1.252 +++ rxvt-unicode/src/main.C 2007/11/26 10:08:36 1.265 @@ -40,14 +40,19 @@ #include #include -#ifdef TTY_GID_SUPPORT -# include -#endif - #ifdef HAVE_TERMIOS_H # include #endif +#ifdef HAVE_XSETLOCALE +# define X_LOCALE +# include +#else +# ifdef HAVE_SETLOCALE +# include +# endif +#endif + vector rxvt_term::termlist; // used to tell global functions which terminal instance is "active" @@ -90,7 +95,7 @@ text_t rxvt_composite_vec::compose (unicode_t c1, unicode_t c2) { compose_char *cc; - + // break compose chains, as stupid readline really likes to duplicate // composing characters for some reason near the end of a line. cc = (*this)[c1]; @@ -178,19 +183,19 @@ pointer_ev (this, &rxvt_term::pointer_cb), #endif #ifdef USE_XIM - im_ev (this, &rxvt_term::im_cb), + im_ev (this, &rxvt_term::im_cb), #endif -#ifndef NO_BELL - bell_ev (this, &rxvt_term::bell_cb), +#ifndef NO_BELL + bell_ev (this, &rxvt_term::bell_cb), #endif termwin_ev (this, &rxvt_term::x_cb), - vt_ev (this, &rxvt_term::x_cb), - child_ev (this, &rxvt_term::child_cb), - check_ev (this, &rxvt_term::check_cb), - flush_ev (this, &rxvt_term::flush_cb), + vt_ev (this, &rxvt_term::x_cb), + child_ev (this, &rxvt_term::child_cb), + prepare_ev (this, &rxvt_term::prepare_cb), + flush_ev (this, &rxvt_term::flush_cb), destroy_ev (this, &rxvt_term::destroy_cb), - pty_ev (this, &rxvt_term::pty_cb), - incr_ev (this, &rxvt_term::incr_cb) + pty_ev (this, &rxvt_term::pty_cb), + incr_ev (this, &rxvt_term::incr_cb) { cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; @@ -203,7 +208,8 @@ // clean up the most important stuff, do *not* call x or free mem etc. // for use before an emergency exit -void rxvt_term::emergency_cleanup () +void +rxvt_term::emergency_cleanup () { if (cmd_pid) kill (-cmd_pid, SIGHUP); @@ -280,6 +286,9 @@ delete [] pix_colors_unfocused; #endif +#ifdef HAVE_BG_PIXMAP + bgPixmap.destroy (); +#endif displays.put (display); scr_release (); @@ -302,11 +311,14 @@ #ifdef KEYSYM_RESOURCE delete keyboard; #endif +#ifndef NO_RESOURCES + XrmDestroyDatabase (option_db); +#endif } // child has exited, usually destroys void -rxvt_term::child_cb (child_watcher &w, int status) +rxvt_term::child_cb (ev::child &w, int status) { HOOK_INVOKE ((this, HOOK_CHILD_EXIT, DT_INT, status, DT_END)); @@ -344,7 +356,7 @@ vt_ev.stop (display); } - check_ev.stop (); + prepare_ev.stop (); pty_ev.stop (); #ifdef CURSOR_BLINK cursor_blink_ev.stop (); @@ -362,11 +374,11 @@ pointer_ev.stop (); #endif - destroy_ev.start (0); + destroy_ev.start (); } void -rxvt_term::destroy_cb (time_watcher &w) +rxvt_term::destroy_cb (ev::idle &w, int revents) { make_current (); @@ -430,7 +442,7 @@ mesg, BUFSIZ); rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->resourceid); } - XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d", + XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d", mesg, BUFSIZ); rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->serial); } @@ -514,10 +526,10 @@ if (option (Opt_transparent)) { bgPixmap.set_transparent (); -#ifdef HAVE_AFTERIMAGE +#ifdef HAVE_AFTERIMAGE if (rs [Rs_blurradius]) bgPixmap.set_blur_radius (rs [Rs_blurradius]); -#endif +#endif if (ISSET_PIXCOLOR (Color_tint)) bgPixmap.set_tint (pix_colors_focused [Color_tint]); if (rs [Rs_shade]) @@ -561,9 +573,9 @@ free (cmd_argv); if (pty->pty >= 0) - pty_ev.start (pty->pty, EVENT_READ); + pty_ev.start (pty->pty, ev::READ); - check_ev.start (); + prepare_ev.start (); HOOK_INVOKE ((this, HOOK_START, DT_END)); @@ -585,16 +597,16 @@ static struct sig_handlers { - sig_watcher sw_term, sw_int; - + ev::sig sw_term, sw_int; + /* * Catch a fatal signal and tidy up before quitting */ void - sig_term (sig_watcher &w) + sig_term (ev::sig &w, int revents) { rxvt_emergency_cleanup (); - signal (w.signum, SIG_DFL); + w.stop (); kill (getpid (), w.signum); } @@ -612,13 +624,16 @@ { ptytty::init (); + if (!ev_default_loop (0)) + rxvt_fatal ("cannot initialise libev (bad value for LIBEV_METHODS?)\n"); + rxvt_environ = environ; signal (SIGHUP, SIG_IGN); signal (SIGPIPE, SIG_IGN); - sig_handlers.sw_term.start (SIGTERM); - sig_handlers.sw_int.start (SIGINT); + sig_handlers.sw_term.start (SIGTERM); ev_unref (); + sig_handlers.sw_int.start (SIGINT); ev_unref (); /* need to trap SIGURG for SVR4 (Unixware) rlogin */ /* signal (SIGURG, SIG_DFL); */ @@ -898,19 +913,21 @@ resize_all_windows (0, 0, 0); scr_remap_chars (); scr_touch (true); - } + } return true; } -void rxvt_term::set_string_property (Atom prop, const char *str, int len) +void +rxvt_term::set_string_property (Atom prop, const char *str, int len) { XChangeProperty (dpy, parent[0], prop, XA_STRING, 8, PropModeReplace, (const unsigned char *)str, len >= 0 ? len : strlen (str)); } -void rxvt_term::set_utf8_property (Atom prop, const char *str, int len) +void +rxvt_term::set_utf8_property (Atom prop, const char *str, int len) { wchar_t *ws = rxvt_mbstowcs (str, len); char *s = rxvt_wcstoutf8 (ws); @@ -950,7 +967,7 @@ #ifdef XTERM_COLOR_CHANGE rxvt_color xcol; int i; - + if (color == NULL || *color == '\0') return; @@ -964,14 +981,16 @@ i = atoi (color); if (i >= 8 && i <= 15) - { /* bright colors */ + { + /* bright colors */ i -= 8; pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; goto done; } if (i >= 0 && i <= 7) - { /* normal colors */ + { + /* normal colors */ pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; goto done; } @@ -986,15 +1005,13 @@ pix_colors_focused[idx] = xcol; - /* XSetWindowAttributes attr; */ - /* Cursor cursor; */ done: /*TODO: handle Color_BD, scrollbar background, etc. */ update_fade_color (idx); recolour_cursor (); scr_recolour (); -#endif /* XTERM_COLOR_CHANGE */ +#endif /* XTERM_COLOR_CHANGE */ } void @@ -1341,7 +1358,7 @@ } else str = (void *)text->string.wide_char; - + HOOK_INVOKE ((term, HOOK_XIM_PREEDIT_DRAW, DT_INT, call_data->caret, DT_INT, call_data->chg_first, @@ -1670,7 +1687,7 @@ { im_set_size (preedit_rect); preedit_attr = XVaCreateNestedList (0, XNArea, &preedit_rect, NULL); - + XSetICValues (Input_Context, XNPreeditAttributes, preedit_attr, NULL); } @@ -1697,7 +1714,7 @@ XFree (preedit_attr); } -#endif /* USE_XIM */ +#endif /* USE_XIM */ void rxvt_term::get_window_origin (int &x, int &y) @@ -1729,29 +1746,39 @@ } #ifdef HAVE_BG_PIXMAP +# if TRACE_PIXMAPS +# undef update_background +int rxvt_term::trace_update_background (const char* file, int line) +{ + fprintf (stderr, "%s:%d:update_background()\n", file, line); + update_background (); +} +# endif int rxvt_term::update_background () { bgPixmap.invalidate (); - /* no chance of real time refresh if we are blurring ! */ - if (bgPixmap.invalid_since + 0.5 < NOW && !(bgPixmap.flags & bgPixmap_t::blurNeeded)) + /* no chance of real time refresh if we are blurring! */ + if (bgPixmap.invalid_since + 0.5 < ev::now () && !(bgPixmap.flags & bgPixmap_t::blurNeeded)) bgPixmap.render (); else { update_background_ev.stop (); + if (!bgPixmap.need_client_side_rendering()) - update_background_ev.start (NOW + .05); + update_background_ev.start (.05); else if (bgPixmap.flags & bgPixmap_t::blurNeeded) - update_background_ev.start (NOW + .2); /* very slow !!! */ + update_background_ev.start (.20); /* very slow !!! */ else - update_background_ev.start (NOW + .07); + update_background_ev.start (.07); } + return 0; } void -rxvt_term::update_background_cb (time_watcher &w) +rxvt_term::update_background_cb (ev::timer &w, int revents) { bgPixmap.render (); }