From: root Date: Sat, 18 Feb 2006 14:14:43 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=0a66736273a4667d49cdeb93d798c632282fd24e;p=dana%2Furxvt.git *** empty log message *** --- diff --git a/Changes b/Changes index 1fd55da6..2c6b01d7 100644 --- a/Changes +++ b/Changes @@ -26,6 +26,7 @@ DUMB: support tex fonts in empts spaces, but thats not true when reversing (e.g. selection), so also check for matching fg colours. This fixes the problem where selecting newly scrolled-in lines would exhibit wrong colours. + - fix a race resulting in a crash on exiting. 7.6 Fri Feb 10 08:52:36 CET 2006 - changed interpretation of [alpha] colour prefix. diff --git a/src/main.C b/src/main.C index 148e4f06..09cdf6a1 100644 --- a/src/main.C +++ b/src/main.C @@ -200,6 +200,7 @@ void rxvt_term::emergency_cleanup () if (cmd_pid) kill (-cmd_pid, SIGHUP); + pty_ev.stop (); delete pty; pty = 0; } diff --git a/src/rxvtfont.C b/src/rxvtfont.C index 13b47858..75fc571d 100644 --- a/src/rxvtfont.C +++ b/src/rxvtfont.C @@ -165,24 +165,6 @@ static uint16_t extent_test_chars[] = { ///////////////////////////////////////////////////////////////////////////// -#if XFT -rxvt_drawable::~rxvt_drawable () -{ - if (xftdrawable) - XftDrawDestroy (xftdrawable); -} - -rxvt_drawable::operator XftDraw *() -{ - if (!xftdrawable) - xftdrawable = XftDrawCreate (screen->dpy, drawable, screen->visual, screen->cmap); - - return xftdrawable; -} -#endif - -///////////////////////////////////////////////////////////////////////////// - static const char * enc_char (const text_t *text, uint32_t len, codeset cs, bool &zero) { @@ -1284,8 +1266,6 @@ rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, const text_t *text, int len, int fg, int bg) { - clear_rect (d, x, y, term->fwidth * len, term->fheight, bg); - XGlyphInfo extents; XftGlyphSpec *enc = (XftGlyphSpec *)rxvt_temp_buf (len * sizeof (XftGlyphSpec)); XftGlyphSpec *ep = enc; @@ -1293,10 +1273,18 @@ rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, dTermDisplay; dTermGC; + int w = term->fwidth * len; + int h = term->fheight; + + bool buffered = false; + // cut trailing spaces while (len && text [len - 1] == ' ') len--; + int x_ = buffered ? 0 : x; + int y_ = buffered ? 0 : y; + while (len) { int cwidth = term->fwidth; @@ -1311,21 +1299,39 @@ rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, XftGlyphExtents (disp, f, &glyph, 1, &extents); ep->glyph = glyph; - ep->x = x + (cwidth - extents.xOff >> 1); - ep->y = y + ascent; + ep->x = x_ + (cwidth - extents.xOff >> 1); + ep->y = y_ + ascent; if (extents.xOff == 0) - ep->x = x + cwidth; + ep->x = x_ + cwidth; ep++; } - x += cwidth; + x_ += cwidth; } - if (ep != enc) - XftDrawGlyphSpec (d, &term->pix_colors[fg].c, f, enc, ep - enc); + if (buffered) + { + if (ep != enc) + { + rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); + + XftDrawRect (d2, &term->pix_colors[bg].c, 0, 0, w, h); + + XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc); + XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y); + } + else + clear_rect (d, x, y, w, h, bg); + } + else + { + clear_rect (d, x, y, w, h, bg); + XftDrawGlyphSpec (d, &term->pix_colors[fg].c, f, enc, ep - enc); + } } + #endif ///////////////////////////////////////////////////////////////////////////// diff --git a/src/rxvtfont.h b/src/rxvtfont.h index 6eb296f1..a70ead45 100644 --- a/src/rxvtfont.h +++ b/src/rxvtfont.h @@ -38,29 +38,6 @@ struct rxvt_fontprop { int weight, slant; }; -struct rxvt_drawable { - rxvt_screen *screen; -#if XFT - XftDraw *xftdrawable; - operator XftDraw *(); -#endif - Drawable drawable; - - rxvt_drawable (rxvt_screen *screen, Drawable drawable) - : screen(screen), -#if XFT - xftdrawable(0), -#endif - drawable(drawable) - { } - -#if XFT - ~rxvt_drawable (); -#endif - - operator Drawable() { return drawable; } -}; - struct rxvt_font { // managed by the fontset rxvt_term *term; diff --git a/src/rxvttoolkit.C b/src/rxvttoolkit.C index 42d2080c..711b99fe 100644 --- a/src/rxvttoolkit.C +++ b/src/rxvttoolkit.C @@ -203,6 +203,56 @@ rxvt_xim::~rxvt_xim () ///////////////////////////////////////////////////////////////////////////// +#if XFT +rxvt_drawable::~rxvt_drawable () +{ + if (xftdrawable) + XftDrawDestroy (xftdrawable); +} + +rxvt_drawable::operator XftDraw *() +{ + if (!xftdrawable) + xftdrawable = XftDrawCreate (screen->dpy, drawable, screen->visual, screen->cmap); + + return xftdrawable; +} +#endif + +///////////////////////////////////////////////////////////////////////////// + +#if XFT + +// not strictly necessary as it is only used with superclass of zero_initialised +rxvt_screen::rxvt_screen () +: scratch_area (0) +{ +} + +rxvt_drawable &rxvt_screen::scratch_drawable (int w, int h) +{ + // it's actually faster to re-allocate every time. don't ask me + // why, but its likely no big deal there are no roundtrips + // (I think/hope). + if (!scratch_area || w > scratch_w || h > scratch_h || 1/*D*/) + { + if (scratch_area) + { + XFreePixmap (dpy, scratch_area->drawable); + delete scratch_area; + } + + Pixmap pm = XCreatePixmap (dpy, RootWindowOfScreen (ScreenOfDisplay (dpy, display->screen)), + scratch_w = w, scratch_h = h, depth); + + scratch_area = new rxvt_drawable (this, pm); + } + + return *scratch_area; +} + +#endif + void rxvt_screen::set (rxvt_display *disp) { @@ -236,6 +286,14 @@ rxvt_screen::set (rxvt_display *disp, int bitdepth) void rxvt_screen::clear () { +#if XFT + if (scratch_area) + { + XFreePixmap (dpy, scratch_area->drawable); + delete scratch_area; + } +#endif + if (cmap != DefaultColormapOfScreen (ScreenOfDisplay (dpy, display->screen))) XFreeColormap (dpy, cmap); } diff --git a/src/rxvttoolkit.h b/src/rxvttoolkit.h index 4314289c..06491d30 100644 --- a/src/rxvttoolkit.h +++ b/src/rxvttoolkit.h @@ -107,6 +107,33 @@ struct refcache : vector { ///////////////////////////////////////////////////////////////////////////// +struct rxvt_screen; + +struct rxvt_drawable { + rxvt_screen *screen; + Drawable drawable; + operator Drawable() { return drawable; } + +#if XFT + XftDraw *xftdrawable; + operator XftDraw *(); +#endif + + rxvt_drawable (rxvt_screen *screen, Drawable drawable) + : screen(screen), +#if XFT + xftdrawable(0), +#endif + drawable(drawable) + { } + +#if XFT + ~rxvt_drawable (); +#endif +}; + +///////////////////////////////////////////////////////////////////////////// + #ifdef USE_XIM struct rxvt_xim : refcounted { void destroy (); @@ -128,6 +155,16 @@ struct rxvt_screen { Visual *visual; Colormap cmap; +#if XFT + // scratch pixmap + rxvt_drawable *scratch_area; + int scratch_w, scratch_h; + + rxvt_drawable &scratch_drawable (int w, int h); + + rxvt_screen (); +#endif + void set (rxvt_display *disp); void set (rxvt_display *disp, int bitdepth); void clear ();