… | |
… | |
32 | #ifndef NO_SLOW_LINK_SUPPORT |
32 | #ifndef NO_SLOW_LINK_SUPPORT |
33 | # include <sys/socket.h> |
33 | # include <sys/socket.h> |
34 | # include <sys/un.h> |
34 | # include <sys/un.h> |
35 | #endif |
35 | #endif |
36 | |
36 | |
|
|
37 | #if XFT |
|
|
38 | # include <X11/extensions/Xrender.h> |
|
|
39 | #endif |
|
|
40 | |
37 | const char *const xa_names[] = |
41 | const char *const xa_names[] = |
38 | { |
42 | { |
39 | "TEXT", |
43 | "TEXT", |
40 | "COMPOUND_TEXT", |
44 | "COMPOUND_TEXT", |
41 | "UTF8_STRING", |
45 | "UTF8_STRING", |
… | |
… | |
195 | void |
199 | void |
196 | rxvt_screen::set (rxvt_display *disp, int bitdepth) |
200 | rxvt_screen::set (rxvt_display *disp, int bitdepth) |
197 | { |
201 | { |
198 | set (disp); |
202 | set (disp); |
199 | |
203 | |
|
|
204 | #if XFT |
200 | XVisualInfo vinfo; |
205 | XVisualInfo vinfo; |
201 | |
206 | |
202 | if (XMatchVisualInfo (xdisp, display->screen, bitdepth, TrueColor, &vinfo)) |
207 | if (XMatchVisualInfo (xdisp, display->screen, bitdepth, TrueColor, &vinfo)) |
203 | { |
208 | { |
204 | depth = bitdepth; |
209 | depth = bitdepth; |
205 | visual = vinfo.visual; |
210 | visual = vinfo.visual; |
206 | cmap = XCreateColormap (xdisp, disp->root, visual, AllocNone); |
211 | cmap = XCreateColormap (xdisp, disp->root, visual, AllocNone); |
207 | } |
212 | } |
|
|
213 | #endif |
208 | } |
214 | } |
209 | |
215 | |
210 | void |
216 | void |
211 | rxvt_screen::clear () |
217 | rxvt_screen::clear () |
212 | { |
218 | { |
… | |
… | |
569 | |
575 | |
570 | bool |
576 | bool |
571 | rxvt_color::set (rxvt_screen *screen, rxvt_rgba rgba) |
577 | rxvt_color::set (rxvt_screen *screen, rxvt_rgba rgba) |
572 | { |
578 | { |
573 | #if XFT |
579 | #if XFT |
574 | XRenderColor d; |
580 | XRenderPictFormat *format; |
575 | |
581 | |
576 | d.red = rgba.r; |
582 | // FUCKING Xft gets it wrong, of course, so work around it |
577 | d.green = rgba.g; |
|
|
578 | d.blue = rgba.b; |
|
|
579 | d.alpha = rgba.a; |
|
|
580 | |
|
|
581 | if (XftColorAllocValue (screen->xdisp, screen->visual, screen->cmap, &d, &c)) |
|
|
582 | { |
|
|
583 | // FUCKING Xft gets it wrong, of course, fix it for the common case |
|
|
584 | // transparency users should eat shit and die, and then |
583 | // transparency users should eat shit and die, and then |
585 | // XRenderQueryPictIndexValues themselves plenty. |
584 | // XRenderQueryPictIndexValues themselves plenty. |
586 | if (screen->depth == 32 && screen->visual->c_class == TrueColor) |
585 | if (screen->visual->c_class == TrueColor |
587 | if ((screen->visual->red_mask | screen->visual->green_mask | screen->visual->blue_mask) == 0x00ffffffUL) |
586 | && (format = XRenderFindVisualFormat (screen->xdisp, screen->visual))) |
588 | c.pixel = c.pixel & 0x00ffffffUL | ((rgba.a >> 8) << 24); |
587 | { |
589 | else if ((screen->visual->red_mask | screen->visual->green_mask | screen->visual->blue_mask) == 0xffffff00UL) |
588 | // the fun lies in doing everything manually... |
590 | c.pixel = c.pixel & 0xffffff00UL | (rgba.a >> 8); |
589 | c.color.red = rgba.r; |
|
|
590 | c.color.green = rgba.g; |
|
|
591 | c.color.blue = rgba.b; |
|
|
592 | c.color.alpha = rgba.a; |
|
|
593 | |
|
|
594 | c.pixel = ((rgba.r * format->direct.redMask / rxvt_rgba::MAX_CC) << format->direct.red) |
|
|
595 | | ((rgba.g * format->direct.greenMask / rxvt_rgba::MAX_CC) << format->direct.green) |
|
|
596 | | ((rgba.b * format->direct.blueMask / rxvt_rgba::MAX_CC) << format->direct.blue) |
|
|
597 | | ((rgba.a * format->direct.alphaMask / rxvt_rgba::MAX_CC) << format->direct.alpha); |
591 | |
598 | |
592 | return true; |
599 | return true; |
|
|
600 | } |
|
|
601 | else |
|
|
602 | { |
|
|
603 | XRenderColor d; |
|
|
604 | |
|
|
605 | d.red = rgba.r; |
|
|
606 | d.green = rgba.g; |
|
|
607 | d.blue = rgba.b; |
|
|
608 | d.alpha = rgba.a; |
|
|
609 | |
|
|
610 | return XftColorAllocValue (screen->xdisp, screen->visual, screen->cmap, &d, &c); |
593 | } |
611 | } |
594 | |
612 | |
595 | return false; |
613 | return false; |
596 | #else |
614 | #else |
597 | XColor xc; |
615 | XColor xc; |