… | |
… | |
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 | { |
… | |
… | |
543 | rxvt_rgba r; |
549 | rxvt_rgba r; |
544 | char eos; |
550 | char eos; |
545 | int mult; |
551 | int mult; |
546 | |
552 | |
547 | if ( l == 1+4*1 && 4 == sscanf (name, "#%1hx%1hx%1hx%1hx%c", &r.a, &r.r, &r.g, &r.b, &eos)) |
553 | if ( l == 1+4*1 && 4 == sscanf (name, "#%1hx%1hx%1hx%1hx%c", &r.a, &r.r, &r.g, &r.b, &eos)) |
548 | mult = 0x1111; |
554 | mult = rxvt_rgba::MAX_CC / 0x000f; |
549 | else if (l == 1+4*2 && 4 == sscanf (name, "#%2hx%2hx%2hx%2hx%c", &r.a, &r.r, &r.g, &r.b, &eos)) |
555 | else if (l == 1+4*2 && 4 == sscanf (name, "#%2hx%2hx%2hx%2hx%c", &r.a, &r.r, &r.g, &r.b, &eos)) |
550 | mult = 0x0101; |
556 | mult = rxvt_rgba::MAX_CC / 0x00ff; |
551 | else if (l == 1+4*4 && 4 == sscanf (name, "#%4hx%4hx%4hx%4hx%c", &r.a, &r.r, &r.g, &r.b, &eos)) |
557 | else if (l == 1+4*4 && 4 == sscanf (name, "#%4hx%4hx%4hx%4hx%c", &r.a, &r.r, &r.g, &r.b, &eos)) |
552 | mult = 0x0001; |
558 | mult = rxvt_rgba::MAX_CC / 0xffff; |
|
|
559 | else if (l == 4+5*4 && 4 == sscanf (name, "rgba:%hx/%hx/%hx/%hx%c", &r.r, &r.g, &r.b, &r.a, &eos)) |
|
|
560 | mult = rxvt_rgba::MAX_CC / 0xffff; |
553 | else |
561 | else |
554 | return XftColorAllocName (screen->xdisp, screen->visual, screen->cmap, name, &c); |
562 | return XftColorAllocName (screen->xdisp, screen->visual, screen->cmap, name, &c); |
555 | |
563 | |
556 | r.r *= mult; r.g *= mult; r.b *= mult; r.a *= mult; |
564 | r.r *= mult; r.g *= mult; r.b *= mult; r.a *= mult; |
557 | return set (screen, r); |
565 | return set (screen, r); |
… | |
… | |
567 | |
575 | |
568 | bool |
576 | bool |
569 | rxvt_color::set (rxvt_screen *screen, rxvt_rgba rgba) |
577 | rxvt_color::set (rxvt_screen *screen, rxvt_rgba rgba) |
570 | { |
578 | { |
571 | #if XFT |
579 | #if XFT |
|
|
580 | XRenderPictFormat *format; |
|
|
581 | |
|
|
582 | // FUCKING Xft gets it wrong, of course, so work around it |
|
|
583 | // transparency users should eat shit and die, and then |
|
|
584 | // XRenderQueryPictIndexValues themselves plenty. |
|
|
585 | if (screen->visual->c_class == TrueColor |
|
|
586 | && (format = XRenderFindVisualFormat (screen->xdisp, screen->visual))) |
|
|
587 | { |
|
|
588 | // the fun lies in doing everything manually... |
|
|
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 >> (16 - popcount (format->direct.redMask )) << format->direct.red) |
|
|
595 | | (rgba.g >> (16 - popcount (format->direct.greenMask)) << format->direct.green) |
|
|
596 | | (rgba.b >> (16 - popcount (format->direct.blueMask )) << format->direct.blue) |
|
|
597 | | (rgba.a >> (16 - popcount (format->direct.alphaMask)) << format->direct.alpha); |
|
|
598 | |
|
|
599 | return true; |
|
|
600 | } |
|
|
601 | else |
|
|
602 | { |
572 | XRenderColor d; |
603 | XRenderColor d; |
573 | |
604 | |
574 | d.red = rgba.r; |
605 | d.red = rgba.r; |
575 | d.green = rgba.g; |
606 | d.green = rgba.g; |
576 | d.blue = rgba.b; |
607 | d.blue = rgba.b; |
577 | d.alpha = rgba.a; |
608 | d.alpha = rgba.a; |
578 | |
609 | |
579 | return XftColorAllocValue (screen->xdisp, screen->visual, screen->cmap, &d, &c); |
610 | return XftColorAllocValue (screen->xdisp, screen->visual, screen->cmap, &d, &c); |
|
|
611 | } |
|
|
612 | |
|
|
613 | return false; |
580 | #else |
614 | #else |
581 | XColor xc; |
615 | XColor xc; |
582 | |
616 | |
583 | xc.red = rgba.r; |
617 | xc.red = rgba.r; |
584 | xc.green = rgba.g; |
618 | xc.green = rgba.g; |