--- rxvt-unicode/src/rxvttoolkit.C 2006/01/30 02:21:20 1.34 +++ rxvt-unicode/src/rxvttoolkit.C 2006/01/30 17:49:48 1.37 @@ -605,7 +605,7 @@ // 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 + if ((screen->visual->c_class == TrueColor || screen->visual->c_class == DirectColor) && (format = XRenderFindVisualFormat (screen->xdisp, screen->visual))) { // the fun lies in doing everything manually... @@ -635,18 +635,32 @@ return false; #else - XColor xc; - - xc.red = rgba.r; - xc.green = rgba.g; - xc.blue = rgba.b; - xc.flags = DoRed | DoGreen | DoBlue; - - if (XAllocColor (screen->xdisp, screen->cmap, &xc)) + if (screen->visual->c_class == TrueColor || screen->visual->c_class == DirectColor) { - p = xc.pixel; + p = (rgba.r * (screen->visual->red_mask >> ctz (screen->visual->red_mask )) + / rxvt_rgba::MAX_CC) << ctz (screen->visual->red_mask ) + | (rgba.g * (screen->visual->green_mask >> ctz (screen->visual->green_mask)) + / rxvt_rgba::MAX_CC) << ctz (screen->visual->green_mask) + | (rgba.b * (screen->visual->blue_mask >> ctz (screen->visual->blue_mask )) + / rxvt_rgba::MAX_CC) << ctz (screen->visual->blue_mask ); + return true; } + else + { + XColor xc; + + xc.red = rgba.r; + xc.green = rgba.g; + xc.blue = rgba.b; + xc.flags = DoRed | DoGreen | DoBlue; + + if (XAllocColor (screen->xdisp, screen->cmap, &xc)) + { + p = xc.pixel; + return true; + } + } return false; #endif