--- rxvt-unicode/src/rxvttoolkit.C 2006/01/29 20:51:28 1.28 +++ rxvt-unicode/src/rxvttoolkit.C 2006/01/29 22:27:04 1.31 @@ -34,6 +34,10 @@ # include #endif +#if XFT +# include +#endif + const char *const xa_names[] = { "TEXT", @@ -197,6 +201,7 @@ { set (disp); +#if XFT XVisualInfo vinfo; if (XMatchVisualInfo (xdisp, display->screen, bitdepth, TrueColor, &vinfo)) @@ -205,6 +210,7 @@ visual = vinfo.visual; cmap = XCreateColormap (xdisp, disp->root, visual, AllocNone); } +#endif } void @@ -545,11 +551,13 @@ int mult; if ( l == 1+4*1 && 4 == sscanf (name, "#%1hx%1hx%1hx%1hx%c", &r.a, &r.r, &r.g, &r.b, &eos)) - mult = 0x1111; + mult = rxvt_rgba::MAX_CC / 0x000f; else if (l == 1+4*2 && 4 == sscanf (name, "#%2hx%2hx%2hx%2hx%c", &r.a, &r.r, &r.g, &r.b, &eos)) - mult = 0x0101; + mult = rxvt_rgba::MAX_CC / 0x00ff; else if (l == 1+4*4 && 4 == sscanf (name, "#%4hx%4hx%4hx%4hx%c", &r.a, &r.r, &r.g, &r.b, &eos)) - mult = 0x0001; + mult = rxvt_rgba::MAX_CC / 0xffff; + else if (l == 4+5*4 && 4 == sscanf (name, "rgba:%hx/%hx/%hx/%hx%c", &r.r, &r.g, &r.b, &r.a, &eos)) + mult = rxvt_rgba::MAX_CC / 0xffff; else return XftColorAllocName (screen->xdisp, screen->visual, screen->cmap, name, &c); @@ -569,14 +577,40 @@ rxvt_color::set (rxvt_screen *screen, rxvt_rgba rgba) { #if XFT - XRenderColor d; + XRenderPictFormat *format; - d.red = rgba.r; - d.green = rgba.g; - d.blue = rgba.b; - d.alpha = rgba.a; + // FUCKING Xft gets it wrong, of course, so work around it + // transparency users should eat shit and die, and then + // XRenderQueryPictIndexValues themselves plenty. + if (screen->visual->c_class == TrueColor + && (format = XRenderFindVisualFormat (screen->xdisp, screen->visual))) + { + // the fun lies in doing everything manually... + c.color.red = rgba.r; + c.color.green = rgba.g; + c.color.blue = rgba.b; + c.color.alpha = rgba.a; + + c.pixel = (rgba.r >> (16 - popcount (format->direct.redMask )) << format->direct.red) + | (rgba.g >> (16 - popcount (format->direct.greenMask)) << format->direct.green) + | (rgba.b >> (16 - popcount (format->direct.blueMask )) << format->direct.blue) + | (rgba.a >> (16 - popcount (format->direct.alphaMask)) << format->direct.alpha); - return XftColorAllocValue (screen->xdisp, screen->visual, screen->cmap, &d, &c); + return true; + } + else + { + XRenderColor d; + + d.red = rgba.r; + d.green = rgba.g; + d.blue = rgba.b; + d.alpha = rgba.a; + + return XftColorAllocValue (screen->xdisp, screen->visual, screen->cmap, &d, &c); + } + + return false; #else XColor xc;