--- rxvt-unicode/src/main.C 2007/08/10 22:10:36 1.240 +++ rxvt-unicode/src/main.C 2007/10/18 09:11:42 1.254 @@ -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" @@ -153,8 +158,8 @@ #if ENABLE_TRANSPARENCY || ENABLE_PERL rootwin_ev (this, &rxvt_term::rootwin_cb), #endif -#if ENABLE_TRANSPARENCY - check_our_parents_ev(this, &rxvt_term::check_our_parents_cb), +#if HAVE_BG_PIXMAP + update_background_ev(this, &rxvt_term::update_background_cb), #endif #ifdef HAVE_SCROLLBARS scrollbar_ev (this, &rxvt_term::x_cb), @@ -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); @@ -508,7 +514,6 @@ #endif #ifdef HAVE_BG_PIXMAP { - bool changed = false; bgPixmap.set_target (this); #ifdef ENABLE_TRANSPARENCY @@ -523,7 +528,6 @@ bgPixmap.set_tint (pix_colors_focused [Color_tint]); if (rs [Rs_shade]) bgPixmap.set_shade (rs [Rs_shade]); - changed = true; bgPixmap.set_root_pixmap (); XSelectInput (dpy, display->root, PropertyChangeMask); @@ -531,7 +535,7 @@ } #endif -#ifdef XPM_BACKGROUND +#ifdef BG_IMAGE_FROM_FILE if (rs[Rs_backgroundPixmap] != NULL) { const char *p = rs[Rs_backgroundPixmap]; @@ -544,14 +548,11 @@ else bgPixmap.set_defaultGeometry (); - changed = bgPixmap.set_file (rs[Rs_backgroundPixmap]); + if (bgPixmap.set_file (rs[Rs_backgroundPixmap])) + if (!bgPixmap.window_position_sensitive ()) + update_background (); } #endif - if (changed) - { - bgPixmap.render_background (); - scr_touch (true); - } } #endif @@ -908,14 +909,16 @@ 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); @@ -949,10 +952,10 @@ #endif } -#ifdef XTERM_COLOR_CHANGE void rxvt_term::set_window_color (int idx, const char *color) { +#ifdef XTERM_COLOR_CHANGE rxvt_color xcol; int i; @@ -999,11 +1002,8 @@ update_fade_color (idx); recolour_cursor (); scr_recolour (); -} - -#else -# define set_window_color (idx,color) ((void)0) #endif /* XTERM_COLOR_CHANGE */ +} void rxvt_term::recolour_cursor () @@ -1045,7 +1045,7 @@ if (pix_colors[Color_bg] == pix_colors[i]) { sprintf (bstr, "%d", (i - Color_Black)); -#ifdef XPM_BACKGROUND +#ifdef BG_IMAGE_FROM_FILE xpmb = "default;"; #endif break; @@ -1151,11 +1151,12 @@ window_vt_x, window_vt_y, width, height); - scr_clear (); -#ifdef XPM_BACKGROUND - /* TODO: should that really be here ? */ - bgPixmap.render_background (); +#ifdef HAVE_BG_PIXMAP + if (bgPixmap.window_size_sensitive ()) + update_background (); #endif + + scr_clear (); } if (fix_screen || old_height == 0) @@ -1165,8 +1166,9 @@ //scr_touch (false); #ifdef HAVE_BG_PIXMAP - if (bgPixmap.pixmap) - scr_touch (false); +// TODO: this don't seem to have any effect - do we still need it ? If so - in which case exactly ? +// if (bgPixmap.pixmap) +// scr_touch (false); #endif #ifdef USE_XIM @@ -1705,4 +1707,63 @@ } #endif /* USE_XIM */ +void +rxvt_term::get_window_origin (int &x, int &y) +{ + Window cr; + XTranslateCoordinates (dpy, parent[0], display->root, 0, 0, &x, &y, &cr); +/* fprintf( stderr, "origin is %+d%+d\n", x, y);*/ +} + +Pixmap +rxvt_term::get_pixmap_property (int prop_id) +{ + if (prop_id > 0 && prop_id < NUM_XA) + if (xa[prop_id]) + { + int aformat; + unsigned long nitems, bytes_after; + Atom atype; + unsigned char *prop = NULL; + int result = XGetWindowProperty (dpy, display->root, xa[prop_id], + 0L, 1L, False, XA_PIXMAP, &atype, &aformat, + &nitems, &bytes_after, &prop); + if (result == Success && prop && atype == XA_PIXMAP) + { + return *(Pixmap *)prop; + } + } + return None; +} + +#ifdef HAVE_BG_PIXMAP +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)) + bgPixmap.render (); + else + { + update_background_ev.stop (); + if (!bgPixmap.need_client_side_rendering()) + update_background_ev.start (NOW + .05); + else if (bgPixmap.flags & bgPixmap_t::blurNeeded) + update_background_ev.start (NOW + .2); /* very slow !!! */ + else + update_background_ev.start (NOW + .07); + } + return 0; +} + +void +rxvt_term::update_background_cb (time_watcher &w) +{ + bgPixmap.render (); +} + +#endif /* HAVE_BG_PIXMAP */ + /*----------------------- end-of-file (C source) -----------------------*/