--- rxvt-unicode/src/rxvttoolkit.C 2006/01/31 19:53:31 1.44 +++ rxvt-unicode/src/rxvttoolkit.C 2006/02/02 12:51:22 1.48 @@ -397,7 +397,7 @@ rxvt_display::ref_next () { // TODO: somehow check wether the database files/resources changed - // before re-loading/parsing + // before affording re-loading/parsing XrmDestroyDatabase (XrmGetDatabase (display)); XrmSetDatabase (display, get_resources ()); } @@ -510,6 +510,7 @@ } #ifdef USE_XIM + void rxvt_display::reg (im_watcher *w) { imw.push_back (w); @@ -543,10 +544,11 @@ void rxvt_display::put_xim (rxvt_xim *xim) { -#if XLIB_IS_RACEFREE +# if XLIB_IS_RACEFREE xims.put (xim); -#endif +# endif } + #endif Atom rxvt_display::atom (const char *name) @@ -567,10 +569,10 @@ #if XFT XRenderPictFormat *format; - // FUCKING Xft gets it wrong, of course, so work around it - // transparency users should eat shit and die, and then + // 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 || screen->visual->c_class == DirectColor) + if ((screen->visual->c_class == TrueColor) && (format = XRenderFindVisualFormat (screen->xdisp, screen->visual))) { // the fun lies in doing everything manually... @@ -598,11 +600,12 @@ return XftColorAllocValue (screen->xdisp, screen->visual, screen->cmap, &d, &c); } #else - if (screen->visual->c_class == TrueColor || screen->visual->c_class == DirectColor) + c.red = color.r; + c.green = color.g; + c.blue = color.b; + + if (screen->visual->c_class == TrueColor) { - c.red = color.g; - c.green = color.g; - c.blue = color.g; c.pixel = (color.r * (screen->visual->red_mask >> ctz (screen->visual->red_mask )) / rgba::MAX_CC) << ctz (screen->visual->red_mask ) | (color.g * (screen->visual->green_mask >> ctz (screen->visual->green_mask)) @@ -612,19 +615,12 @@ return true; } + else if (XAllocColor (screen->xdisp, screen->cmap, &c)) + return true; else - { - c.red = color.r; - c.green = color.g; - c.blue = color.b; - - if (XAllocColor (screen->xdisp, screen->cmap, &c)) - return true; - else - c.pixel = (color.r + color.g + color.b) > 128*3 - ? WhitePixelOfScreen (DefaultScreenOfDisplay (screen->xdisp)) - : BlackPixelOfScreen (DefaultScreenOfDisplay (screen->xdisp)); - } + c.pixel = (color.r + color.g + color.b) > 128*3 + ? WhitePixelOfScreen (DefaultScreenOfDisplay (screen->xdisp)) + : BlackPixelOfScreen (DefaultScreenOfDisplay (screen->xdisp)); #endif return false; @@ -637,18 +633,17 @@ char eos; int skip; + // parse the nonstandard "[alphapercent]" prefix if (1 <= sscanf (name, "[%hd]%n", &c.a, &skip)) { - printf ("X %d\n", c.a); c.a = lerp (0, rgba::MAX_CC, c.a); name += skip; - printf ("y %04x\n", c.a); } else c.a = rgba::MAX_CC; - // parse the non-standard rgba format - if (strlen (name) != 4+5*4 || 4 != sscanf (name, "rgba:%hx/%hx/%hx/%hx%c", &c.r, &c.g, &c.b, &c.a, &eos)) + // parse the non-standard "rgba:rrrr/gggg/bbbb/aaaa" format + if (strlen (name) != 4+5*4 || 4 != sscanf (name, "rgba:%4hx/%4hx/%4hx/%4hx%c", &c.r, &c.g, &c.b, &c.a, &eos)) { XColor xc, xc_exact; @@ -736,6 +731,18 @@ #endif } +void +rxvt_color::get (XColor &color) +{ + rgba c; + get (c); + + color.red = c.r; + color.green = c.g; + color.blue = c.b; + color.pixel = (Pixel)*this; +} + void rxvt_color::free (rxvt_screen *screen) {