--- rxvt-unicode/src/main.C 2007/12/11 11:53:48 1.274 +++ rxvt-unicode/src/main.C 2008/01/19 00:24:53 1.300 @@ -13,7 +13,7 @@ * Copyright (c) 1997,1998 Oezguer Kesim * Copyright (c) 1998-2001 Geoff Wing * - extensive modifications - * Copyright (c) 2003-2006 Marc Lehmann + * Copyright (c) 2003-2007 Marc Lehmann * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,7 +40,7 @@ #include #include -# include +#include #ifdef HAVE_XSETLOCALE # define X_LOCALE @@ -157,10 +157,10 @@ update_background_ev.set (this); #endif #ifdef CURSOR_BLINK - cursor_blink_ev.set (this); + cursor_blink_ev.set (this); cursor_blink_ev.set (0., CURSOR_BLINK_INTERVAL); #endif #ifdef TEXT_BLINK - text_blink_ev.set (this); + text_blink_ev.set (this); text_blink_ev.set (0., TEXT_BLINK_INTERVAL); #endif #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING cont_scroll_ev.set (this); @@ -172,7 +172,7 @@ slip_wheel_ev.set (this); #endif #if ENABLE_TRANSPARENCY || ENABLE_PERL - rootwin_ev.set (this), + rootwin_ev.set (this), #endif #ifdef HAVE_SCROLLBARS scrollbar_ev.set (this), @@ -187,7 +187,6 @@ bell_ev.set (this); #endif child_ev.set (this); - prepare_ev.set (this); flush_ev.set (this); destroy_ev.set (this); pty_ev.set (this); @@ -229,6 +228,10 @@ #endif delete fontset[0]; +#ifdef HAVE_BG_PIXMAP + bgPixmap.destroy (); +#endif + if (display) { selection_clear (); @@ -277,17 +280,10 @@ } clear (); - } - delete [] pix_colors_focused; -#if OFF_FOCUS_FADING - delete [] pix_colors_unfocused; -#endif - -#ifdef HAVE_BG_PIXMAP - bgPixmap.destroy (); -#endif - displays.put (display); + display->flush (); /* ideally .put should do this */ + displays.put (display); + } scr_release (); @@ -329,7 +325,7 @@ void rxvt_term::destroy () { - if (ev_is_active (&destroy_ev)) + if (destroy_ev.is_active ()) return; HOOK_INVOKE ((this, HOOK_DESTROY, DT_END)); @@ -354,7 +350,7 @@ vt_ev.stop (display); } - prepare_ev.stop (); + flush_ev.stop (); pty_ev.stop (); #ifdef CURSOR_BLINK cursor_blink_ev.stop (); @@ -475,7 +471,7 @@ } /*----------------------------------------------------------------------*/ -bool +void rxvt_term::init (int argc, const char *const *argv, stringvec *envv) { this->envv = envv; @@ -484,8 +480,7 @@ set_locale (""); set_environ (envv); // few things in X do not call setlocale :( - if (!init_vars ()) - return false; + init_vars (); init_secondary (); @@ -519,17 +514,20 @@ #ifdef HAVE_BG_PIXMAP { bgPixmap.set_target (this); + bgPixmap.invalidate (); #ifdef ENABLE_TRANSPARENCY if (option (Opt_transparent)) { bgPixmap.set_transparent (); + #ifdef HAVE_AFTERIMAGE if (rs [Rs_blurradius]) bgPixmap.set_blur_radius (rs [Rs_blurradius]); #endif if (ISSET_PIXCOLOR (Color_tint)) bgPixmap.set_tint (pix_colors_focused [Color_tint]); + if (rs [Rs_shade]) bgPixmap.set_shade (rs [Rs_shade]); @@ -540,11 +538,11 @@ #endif #ifdef BG_IMAGE_FROM_FILE - if (rs[Rs_backgroundPixmap] != NULL) + if (rs[Rs_backgroundPixmap]) { const char *p = rs[Rs_backgroundPixmap]; - if ((p = strchr (p, ';')) != NULL) + if ((p = strchr (p, ';')) != 0) { p++; bgPixmap.set_geometry (p); @@ -573,8 +571,6 @@ if (pty->pty >= 0) pty_ev.start (pty->pty, ev::READ); - prepare_ev.start (); - HOOK_INVOKE ((this, HOOK_START, DT_END)); #if ENABLE_XEMBED @@ -590,7 +586,7 @@ XMapWindow (dpy, vt); XMapWindow (dpy, parent[0]); - return true; + refresh_check (); } static struct sig_handlers @@ -645,42 +641,6 @@ XrmInitialize (); } -/* ------------------------------------------------------------------------- * - * MEMORY ALLOCATION WRAPPERS * - * ------------------------------------------------------------------------- */ -void * -rxvt_malloc (size_t size) -{ - void *p = malloc (size); - - if (!p) - rxvt_fatal ("memory allocation failure. aborting.\n"); - - return p; -} - -void * -rxvt_calloc (size_t number, size_t size) -{ - void *p = calloc (number, size); - - if (!p) - rxvt_fatal ("memory allocation failure. aborting.\n"); - - return p; -} - -void * -rxvt_realloc (void *ptr, size_t size) -{ - void *p = realloc (ptr, size); - - if (!p) - rxvt_fatal ("memory allocation failure. aborting.\n"); - - return p; -} - /*----------------------------------------------------------------------*/ /* * window size/position calculations for XSizeHint and other storage. @@ -1720,7 +1680,7 @@ { Window cr; XTranslateCoordinates (dpy, parent[0], display->root, 0, 0, &x, &y, &cr); -/* fprintf( stderr, "origin is %+d%+d\n", x, y);*/ +/* fprintf (stderr, "origin is %+d%+d\n", x, y);*/ } Pixmap @@ -1737,50 +1697,47 @@ 0L, 1L, False, XA_PIXMAP, &atype, &aformat, &nitems, &bytes_after, &prop); if (result == Success && prop && atype == XA_PIXMAP) - { - return *(Pixmap *)prop; - } + return *(Pixmap *)prop; } + return None; } #ifdef HAVE_BG_PIXMAP # if TRACE_PIXMAPS # undef update_background -int rxvt_term::trace_update_background (const char *file, int line) +void +rxvt_term::trace_update_background (const char *file, int line) { fprintf (stderr, "%s:%d:update_background()\n", file, line); update_background (); } # endif -int +void rxvt_term::update_background () { + if (update_background_ev.is_active ()) + return; + bgPixmap.invalidate (); - /* no chance of real time refresh if we are blurring! */ - if (bgPixmap.invalid_since + 0.5 < ev::now () && !(bgPixmap.flags & bgPixmap_t::blurNeeded)) + ev_tstamp to_wait = 0.5 - (ev::now () - bgPixmap.valid_since); + + if (to_wait <= 0.) bgPixmap.render (); else - { - update_background_ev.stop (); - - if (!bgPixmap.need_client_side_rendering()) - update_background_ev.start (.05); - else if (bgPixmap.flags & bgPixmap_t::blurNeeded) - update_background_ev.start (.20); /* very slow !!! */ - else - update_background_ev.start (.07); - } - - return 0; + update_background_ev.start (to_wait); } void rxvt_term::update_background_cb (ev::timer &w, int revents) { + make_current (); + + update_background_ev.stop (); bgPixmap.render (); + refresh_check (); } #endif /* HAVE_BG_PIXMAP */