--- rxvt-unicode/src/rxvttoolkit.C 2006/01/29 21:45:47 1.29 +++ rxvt-unicode/src/rxvttoolkit.C 2006/01/29 22:30:21 1.32 @@ -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 @@ -571,27 +577,38 @@ 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; - - if (XftColorAllocValue (screen->xdisp, screen->visual, screen->cmap, &d, &c)) - { - // FUCKING Xft gets it wrong, of course, fix it for the common case - // transparency users should eat shit and die, and then - // XRenderQueryPictIndexValues themselves plenty. - if (screen->depth == 32 - && screen->visual->c_class == TrueColor - && screen->visual->red_mask == 0x00ff0000 - && screen->visual->green_mask == 0x0000ff00 - && screen->visual->blue_mask == 0x000000ff) - c.pixel = c.pixel & 0x00ffffffUL | ((rgba.a >> 8) << 24); + // 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 * format->direct.redMask / rxvt_rgba::MAX_CC) << format->direct.red) + | ((rgba.g * format->direct.greenMask / rxvt_rgba::MAX_CC) << format->direct.green) + | ((rgba.b * format->direct.blueMask / rxvt_rgba::MAX_CC) << format->direct.blue) + | ((rgba.a * format->direct.alphaMask / rxvt_rgba::MAX_CC) << format->direct.alpha); 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