--- rxvt-unicode/src/rxvtfont.C 2006/02/20 22:42:00 1.98 +++ rxvt-unicode/src/rxvtfont.C 2007/08/17 22:01:33 1.111 @@ -234,9 +234,9 @@ dTermDisplay; dTermGC; - if (color < 0 || color == Color_bg) + if (color == Color_bg || color == Color_transparent) XClearArea (disp, d, x, y, w, h, false); - else + else if (color >= 0) { #if XFT XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h); @@ -272,7 +272,7 @@ return p; } - bool load (const rxvt_fontprop &prop) + bool load (const rxvt_fontprop &prop, bool force_prop) { width = 1; height = 1; ascent = 1; descent = 0; @@ -443,7 +443,7 @@ ? f1 : (*fs)[fs->find_font (cc->c2)]; - f2->draw (d, x, y, chrs, width, fg, -1); + f2->draw (d, x, y, chrs, width, fg, Color_none); } } #endif @@ -473,7 +473,7 @@ rxvt_fontprop properties (); - bool load (const rxvt_fontprop &prop); + bool load (const rxvt_fontprop &prop, bool force_prop); bool has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const; @@ -483,7 +483,6 @@ bool slow; // wether this is a proportional font or has other funny characteristics XFontStruct *f; - codeset cs; bool enc2b, encm; char *get_property (XFontStruct *f, Atom property, const char *repl) const; @@ -629,7 +628,7 @@ } bool -rxvt_font_x11::load (const rxvt_fontprop &prop) +rxvt_font_x11::load (const rxvt_fontprop &prop, bool force_prop) { dTermDisplay; @@ -638,8 +637,7 @@ char field_str[64]; // enough for 128 bits // first morph the font if required - if (prop.weight != rxvt_fontprop::unset - || prop.slant != rxvt_fontprop::unset) + if (force_prop) { char fname[1024]; @@ -1041,7 +1039,7 @@ rxvt_fontprop properties (); - bool load (const rxvt_fontprop &prop); + bool load (const rxvt_fontprop &prop, bool force_prop); void draw (rxvt_drawable &d, int x, int y, const text_t *text, int len, @@ -1084,7 +1082,7 @@ } bool -rxvt_font_xft::load (const rxvt_fontprop &prop) +rxvt_font_xft::load (const rxvt_fontprop &prop, bool force_prop) { dTermDisplay; @@ -1103,11 +1101,11 @@ FcPatternAddInteger (p, FC_PIXEL_SIZE, prop.height); if (prop.weight != rxvt_fontprop::unset - && FcPatternGet (p, FC_WEIGHT, 0, &v) != FcResultMatch) + && (force_prop || FcPatternGet (p, FC_WEIGHT, 0, &v) != FcResultMatch)) FcPatternAddInteger (p, FC_WEIGHT, prop.weight); if (prop.slant != rxvt_fontprop::unset - && FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch) + && (force_prop || FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch)) FcPatternAddInteger (p, FC_SLANT, prop.slant); #if 0 // clipping unfortunately destroys our precious double-width-characters @@ -1276,13 +1274,15 @@ int w = term->fwidth * len; int h = term->fheight; - bool buffered = 0 -#if defined(XPM_BACKGROUND) || defined(TRANSPARENT) - || !term->am_transparent // we aren't transparent - || term->am_pixmap_trans // we have a pixmap + /* TODO: this logic needs some more thinking, since we no longer do pseudo-transparency. + * Maybe make buffering into a resource flag? Compile time option doesn't seems like a + * good idea from the perspective of packaging for wide variety of user configs. + */ + bool buffered = true +#ifdef FORCE_UNBUFFERED_XFT + && bg >= 0 #endif - || bg >= 0; // we don't use a transparent bg - + ; // cut trailing spaces while (len && text [len - 1] == ' ') len--; @@ -1321,29 +1321,57 @@ if (ep != enc) { rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); + bool back_rendered = false; -#if defined(XPM_BACKGROUND) || defined(TRANSPARENT) - if (bg < 0 && term->am_pixmap_trans) - XCopyArea (disp, term->pixmap, d2, gc, x, y, w, h, 0, 0); - else if (bg < 0 && term->bgPixmap.pixmap) +#ifdef HAVE_BG_PIXMAP + if (term->bgPixmap.pixmap && (bg < 0 || term->pix_colors[bg].c.color.alpha < 0x0ff00)) { - XGCValues gcv; - - gcv.fill_style = FillTiled; - gcv.tile = term->pixmap; - gcv.ts_x_origin = -x; - gcv.ts_y_origin = -y; + if (term->bgPixmap.pmap_width >= x + term->window_vt_x+w + && term->bgPixmap.pmap_height >= y + term->window_vt_y+h) + { + XCopyArea (disp, term->bgPixmap.pixmap, d2, gc, + x + term->window_vt_x, y + term->window_vt_y, + w, h, 0, 0); + } + else + { + XGCValues gcv; - GC gc2 = XCreateGC (disp, d2, - GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, - &gcv); + gcv.fill_style = FillTiled; + gcv.tile = term->bgPixmap.pixmap; + gcv.ts_x_origin = -x; + gcv.ts_y_origin = -y; - XFillRectangle (disp, d2, gc2, 0, 0, w, h); +#if 0 + GC gc2 = XCreateGC (disp, d2, + GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, + &gcv); +#endif + XChangeGC (disp, gc, + GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle, + &gcv); + + XFillRectangle (disp, d2, gc/*gc2*/, 0, 0, w, h); + + gcv.fill_style = FillSolid; + XChangeGC (disp, gc, GCFillStyle, &gcv); + /* XFreeGC (disp, gc2); */ - XFreeGC (disp, gc2); + } + if (bg > 0) + { + Picture dst = XftDrawPicture(d2); + if (dst != 0) + { + Picture solid_color_pict = XftDrawSrcPicture (d2, &term->pix_colors[bg].c); + XRenderComposite (disp, PictOpOver, solid_color_pict, None, dst, 0, 0, 0, 0, 0, 0, w, h); + } + } + back_rendered = true; } - else #endif + + if(bg > 0 && !back_rendered) XftDrawRect (d2, &term->pix_colors[bg].c, 0, 0, w, h); XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc); @@ -1379,6 +1407,7 @@ { prop.width = prop.height = prop.ascent = prop.weight = prop.slant = rxvt_fontprop::unset; + force_prop = false; for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) FONT_UNREF (*i); @@ -1500,7 +1529,7 @@ fonts[i]->loaded = true; - if (!fonts[i]->load (prop)) + if (!fonts[i]->load (prop, force_prop)) { fonts[i]->cs = CS_UNKNOWN; return false;