ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvttoolkit.C
(Generate patch)

Comparing rxvt-unicode/src/rxvttoolkit.C (file contents):
Revision 1.28 by root, Sun Jan 29 20:51:28 2006 UTC vs.
Revision 1.34 by root, Mon Jan 30 02:21:20 2006 UTC

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
37const char *const xa_names[] = 41const char *const xa_names[] =
38 { 42{
39 "TEXT", 43 "TEXT",
40 "COMPOUND_TEXT", 44 "COMPOUND_TEXT",
41 "UTF8_STRING", 45 "UTF8_STRING",
42 "MULTIPLE", 46 "MULTIPLE",
43 "TARGETS", 47 "TARGETS",
44 "TIMESTAMP", 48 "TIMESTAMP",
45 "VT_SELECTION", 49 "VT_SELECTION",
46 "INCR", 50 "INCR",
47 "WM_PROTOCOLS", 51 "WM_PROTOCOLS",
48 "WM_DELETE_WINDOW", 52 "WM_DELETE_WINDOW",
49 "CLIPBOARD", 53 "CLIPBOARD",
54 "AVERAGE_WIDTH",
55 "WEIGHT_NAME",
56 "SLANT",
57 "CHARSET_REGISTRY",
58 "CHARSET_ENCODING",
50#if ENABLE_FRILLS 59#if ENABLE_FRILLS
51 "_MOTIF_WM_HINTS", 60 "_MOTIF_WM_HINTS",
52#endif 61#endif
53#if ENABLE_EWMH 62#if ENABLE_EWMH
54 "_NET_WM_PID", 63 "_NET_WM_PID",
55 "_NET_WM_NAME", 64 "_NET_WM_NAME",
56 "_NET_WM_ICON_NAME", 65 "_NET_WM_ICON_NAME",
57 "_NET_WM_PING", 66 "_NET_WM_PING",
58#endif 67#endif
59#if USE_XIM 68#if USE_XIM
60 "WM_LOCALE_NAME", 69 "WM_LOCALE_NAME",
61 "XIM_SERVERS", 70 "XIM_SERVERS",
62#endif 71#endif
63#ifdef TRANSPARENT 72#ifdef TRANSPARENT
64 "_XROOTPMAP_ID", 73 "_XROOTPMAP_ID",
65 "ESETROOT_PMAP_ID", 74 "ESETROOT_PMAP_ID",
66#endif 75#endif
67#if ENABLE_XEMBED 76#if ENABLE_XEMBED
68 "_XEMBED", 77 "_XEMBED",
69 "_XEMBED_INFO", 78 "_XEMBED_INFO",
70#endif 79#endif
71 }; 80#if !ENABLE_MINIMAL
81 "SCREEN_RESOURCES",
82 "XDCCC_LINEAR_RGB_CORRECTION",
83 "XDCCC_LINEAR_RGB_MATRICES",
84 "WM_COLORMAP_WINDOWS",
85 "WM_STATE",
86#endif
87};
72 88
73///////////////////////////////////////////////////////////////////////////// 89/////////////////////////////////////////////////////////////////////////////
74 90
75refcounted::refcounted (const char *id) 91refcounted::refcounted (const char *id)
76{ 92{
195void 211void
196rxvt_screen::set (rxvt_display *disp, int bitdepth) 212rxvt_screen::set (rxvt_display *disp, int bitdepth)
197{ 213{
198 set (disp); 214 set (disp);
199 215
216#if XFT
200 XVisualInfo vinfo; 217 XVisualInfo vinfo;
201 218
202 if (XMatchVisualInfo (xdisp, display->screen, bitdepth, TrueColor, &vinfo)) 219 if (XMatchVisualInfo (xdisp, display->screen, bitdepth, TrueColor, &vinfo))
203 { 220 {
204 depth = bitdepth; 221 depth = bitdepth;
205 visual = vinfo.visual; 222 visual = vinfo.visual;
206 cmap = XCreateColormap (xdisp, disp->root, visual, AllocNone); 223 cmap = XCreateColormap (xdisp, disp->root, visual, AllocNone);
207 } 224 }
225#endif
208} 226}
209 227
210void 228void
211rxvt_screen::clear () 229rxvt_screen::clear ()
212{ 230{
542 int l = strlen (name); 560 int l = strlen (name);
543 rxvt_rgba r; 561 rxvt_rgba r;
544 char eos; 562 char eos;
545 int mult; 563 int mult;
546 564
565 // shortcutting this saves countless server RTTs for the built-in colours
566 if (l == 3+3*3 && 3 == sscanf (name, "rgb:%hx/%hx/%hx/%hx%c", &r.r, &r.g, &r.b, &r.a, &eos))
567 {
568 r.a = rxvt_rgba::MAX_CC;
569 mult = rxvt_rgba::MAX_CC / 0x00ff;
570 }
571
572 // parse a number of non-standard ARGB colour specifications
547 if ( l == 1+4*1 && 4 == sscanf (name, "#%1hx%1hx%1hx%1hx%c", &r.a, &r.r, &r.g, &r.b, &eos)) 573 else 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; 574 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)) 575 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; 576 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)) 577 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; 578 mult = rxvt_rgba::MAX_CC / 0xffff;
579 else if (l == 4+5*4 && 4 == sscanf (name, "rgba:%hx/%hx/%hx/%hx%c", &r.r, &r.g, &r.b, &r.a, &eos))
580 mult = rxvt_rgba::MAX_CC / 0xffff;
581
582 // slow case: server round trip
553 else 583 else
554 return XftColorAllocName (screen->xdisp, screen->visual, screen->cmap, name, &c); 584 return XftColorAllocName (screen->xdisp, screen->visual, screen->cmap, name, &c);
555 585
556 r.r *= mult; r.g *= mult; r.b *= mult; r.a *= mult; 586 r.r *= mult; r.g *= mult; r.b *= mult; r.a *= mult;
587
557 return set (screen, r); 588 return set (screen, r);
558#else 589#else
559 XColor xc; 590 XColor xc;
560 591
561 if (XParseColor (screen->xdisp, screen->cmap, name, &xc)) 592 if (XParseColor (screen->xdisp, screen->cmap, name, &xc))
567 598
568bool 599bool
569rxvt_color::set (rxvt_screen *screen, rxvt_rgba rgba) 600rxvt_color::set (rxvt_screen *screen, rxvt_rgba rgba)
570{ 601{
571#if XFT 602#if XFT
603 XRenderPictFormat *format;
604
605 // FUCKING Xft gets it wrong, of course, so work around it
606 // transparency users should eat shit and die, and then
607 // XRenderQueryPictIndexValues themselves plenty.
608 if (screen->visual->c_class == TrueColor
609 && (format = XRenderFindVisualFormat (screen->xdisp, screen->visual)))
610 {
611 // the fun lies in doing everything manually...
612 c.color.red = rgba.r;
613 c.color.green = rgba.g;
614 c.color.blue = rgba.b;
615 c.color.alpha = rgba.a;
616
617 c.pixel = ((rgba.r * format->direct.redMask / rxvt_rgba::MAX_CC) << format->direct.red )
618 | ((rgba.g * format->direct.greenMask / rxvt_rgba::MAX_CC) << format->direct.green)
619 | ((rgba.b * format->direct.blueMask / rxvt_rgba::MAX_CC) << format->direct.blue )
620 | ((rgba.a * format->direct.alphaMask / rxvt_rgba::MAX_CC) << format->direct.alpha);
621
622 return true;
623 }
624 else
625 {
572 XRenderColor d; 626 XRenderColor d;
573 627
574 d.red = rgba.r; 628 d.red = rgba.r;
575 d.green = rgba.g; 629 d.green = rgba.g;
576 d.blue = rgba.b; 630 d.blue = rgba.b;
577 d.alpha = rgba.a; 631 d.alpha = rgba.a;
578 632
579 return XftColorAllocValue (screen->xdisp, screen->visual, screen->cmap, &d, &c); 633 return XftColorAllocValue (screen->xdisp, screen->visual, screen->cmap, &d, &c);
634 }
635
636 return false;
580#else 637#else
581 XColor xc; 638 XColor xc;
582 639
583 xc.red = rgba.r; 640 xc.red = rgba.r;
584 xc.green = rgba.g; 641 xc.green = rgba.g;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines