… | |
… | |
755 | unsigned int alpha = color.a >= 0xff00 ? 0xffff : color.a; |
755 | unsigned int alpha = color.a >= 0xff00 ? 0xffff : color.a; |
756 | |
756 | |
757 | #if XFT |
757 | #if XFT |
758 | XRenderPictFormat *format; |
758 | XRenderPictFormat *format; |
759 | |
759 | |
|
|
760 | // not needed by XftColorAlloc, but by the other paths (ours |
|
|
761 | // and fallback), so just set all components here. |
|
|
762 | c.color.red = color.r; |
|
|
763 | c.color.green = color.g; |
|
|
764 | c.color.blue = color.b; |
|
|
765 | c.color.alpha = alpha; |
|
|
766 | |
760 | // FUCKING Xft gets it wrong, of course, so work around it. |
767 | // FUCKING Xft gets it wrong, of course, so work around it. |
761 | // Transparency users should eat shit and die, and then |
768 | // Transparency users should eat shit and die, and then |
762 | // XRenderQueryPictIndexValues themselves plenty. |
769 | // XRenderQueryPictIndexValues themselves plenty. |
763 | if ((screen->visual->c_class == TrueColor) |
770 | if ((screen->visual->c_class == TrueColor) |
764 | && (format = XRenderFindVisualFormat (screen->dpy, screen->visual))) |
771 | && (format = XRenderFindVisualFormat (screen->dpy, screen->visual))) |
765 | { |
772 | { |
766 | // the fun lies in doing everything manually... |
773 | // the fun lies in doing everything manually... |
767 | c.color.red = color.r; |
|
|
768 | c.color.green = color.g; |
|
|
769 | c.color.blue = color.b; |
|
|
770 | c.color.alpha = alpha; |
|
|
771 | |
774 | |
772 | // Xft wants premultiplied alpha, but abuses the alpha channel |
775 | // Xft wants premultiplied alpha, but abuses the alpha channel |
773 | // as blend factor, and doesn't allow us to set the alpha channel |
776 | // as blend factor, and doesn't allow us to set the alpha channel |
774 | c.color.red = c.color.red * alpha / 0xffff; |
777 | c.color.red = c.color.red * alpha / 0xffff; |
775 | c.color.green = c.color.green * alpha / 0xffff; |
778 | c.color.green = c.color.green * alpha / 0xffff; |
… | |
… | |
810 | } |
813 | } |
811 | else if (XAllocColor (screen->dpy, screen->cmap, &c)) |
814 | else if (XAllocColor (screen->dpy, screen->cmap, &c)) |
812 | return true; |
815 | return true; |
813 | #endif |
816 | #endif |
814 | |
817 | |
815 | //TODO: set c.color* or c.* |
|
|
816 | c.pixel = (color.r * 2 + color.g * 3 + color.b) >= 0x8000 * 6 |
818 | c.pixel = (color.r * 2 + color.g * 3 + color.b) >= 0x8000 * 6 |
817 | ? WhitePixelOfScreen (DefaultScreenOfDisplay (screen->dpy)) |
819 | ? WhitePixelOfScreen (DefaultScreenOfDisplay (screen->dpy)) |
818 | : BlackPixelOfScreen (DefaultScreenOfDisplay (screen->dpy)); |
820 | : BlackPixelOfScreen (DefaultScreenOfDisplay (screen->dpy)); |
819 | |
821 | |
820 | return false; |
822 | return false; |