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.85 by root, Sun Dec 16 19:44:48 2007 UTC vs.
Revision 1.90 by root, Wed Jan 23 14:09:21 2008 UTC

599} 599}
600 600
601void rxvt_display::set_selection_owner (rxvt_term *owner) 601void rxvt_display::set_selection_owner (rxvt_term *owner)
602{ 602{
603 if (selection_owner && selection_owner != owner) 603 if (selection_owner && selection_owner != owner)
604 {
605 rxvt_term *owner = selection_owner;
606
604 selection_owner->selection_clear (); 607 owner->selection_clear ();
608 owner->flush ();
609 }
605 610
606 selection_owner = owner; 611 selection_owner = owner;
607} 612}
608 613
609#ifdef USE_XIM 614#ifdef USE_XIM
668} 673}
669 674
670bool 675bool
671rxvt_color::alloc (rxvt_screen *screen, const rgba &color) 676rxvt_color::alloc (rxvt_screen *screen, const rgba &color)
672{ 677{
678 //TODO: only supports 24 bit
679 int alpha = color.a >= 0xff00 ? 0xffff : color.a;
680
673#if XFT 681#if XFT
674 XRenderPictFormat *format; 682 XRenderPictFormat *format;
675 683
676 // FUCKING Xft gets it wrong, of course, so work around it. 684 // FUCKING Xft gets it wrong, of course, so work around it.
677 // Transparency users should eat shit and die, and then 685 // Transparency users should eat shit and die, and then
681 { 689 {
682 // the fun lies in doing everything manually... 690 // the fun lies in doing everything manually...
683 c.color.red = color.r; 691 c.color.red = color.r;
684 c.color.green = color.g; 692 c.color.green = color.g;
685 c.color.blue = color.b; 693 c.color.blue = color.b;
686 c.color.alpha = color.a; 694 c.color.alpha = alpha;
687 695
688 c.pixel = insert_component (color.r, format->direct.redMask , format->direct.red ) 696 c.pixel = insert_component (color.r, format->direct.redMask , format->direct.red )
689 | insert_component (color.g, format->direct.greenMask, format->direct.green) 697 | insert_component (color.g, format->direct.greenMask, format->direct.green)
690 | insert_component (color.b, format->direct.blueMask , format->direct.blue ) 698 | insert_component (color.b, format->direct.blueMask , format->direct.blue )
691 | insert_component (color.a, format->direct.alphaMask, format->direct.alpha); 699 | insert_component (alpha , format->direct.alphaMask, format->direct.alpha);
692 700
693 return true; 701 return true;
694 } 702 }
695 else 703 else
696 { 704 {
697 XRenderColor d; 705 XRenderColor d;
698 706
699 d.red = color.r; 707 d.red = color.r;
700 d.green = color.g; 708 d.green = color.g;
701 d.blue = color.b; 709 d.blue = color.b;
702 d.alpha = color.a; 710 d.alpha = alpha;
703 711
704 return XftColorAllocValue (screen->dpy, screen->visual, screen->cmap, &d, &c); 712 return XftColorAllocValue (screen->dpy, screen->visual, screen->cmap, &d, &c);
705 } 713 }
706#else 714#else
707 c.red = color.r; 715 c.red = color.r;
732{ 740{
733 rgba c; 741 rgba c;
734 char eos; 742 char eos;
735 int skip; 743 int skip;
736 744
745 c.a = rgba::MAX_CC;
746
737 // parse the nonstandard "[alphapercent]" prefix 747 // parse the nonstandard "[alphapercent]" prefix
738 if (1 <= sscanf (name, "[%hd]%n", &c.a, &skip)) 748 if (1 <= sscanf (name, "[%hd]%n", &c.a, &skip))
739 { 749 {
740 c.a = lerp<int, int, int> (0, rgba::MAX_CC, c.a); 750 c.a = lerp<int, int, int> (0, rgba::MAX_CC, c.a);
741 name += skip; 751 name += skip;
742 } 752 }
743 else
744 c.a = rgba::MAX_CC;
745 753
746 // parse the non-standard "#aarrggbb" format
747 if (name[0] == '#' && strlen (name) == 1+2+2+2+2 && 4 == sscanf (name+1, "%2hx%2hx%2hx%2hx%c", &c.a, &c.r, &c.g, &c.b, &eos))
748 {
749 if (c.r)
750 c.r = (c.r << 8) | 0x0ff;
751 if (c.g)
752 c.g = (c.g << 8) | 0x0ff;
753 if (c.b)
754 c.b = (c.b << 8) | 0x0ff;
755 if (c.a)
756 c.a = (c.a << 8) | 0x0ff;
757 }
758 // parse the non-standard "rgba:rrrr/gggg/bbbb/aaaa" format 754 // parse the non-standard "rgba:rrrr/gggg/bbbb/aaaa" format
759 else if (strlen (name) != 4+5*4 || 4 != sscanf (name, "rgba:%4hx/%4hx/%4hx/%4hx%c", &c.r, &c.g, &c.b, &c.a, &eos)) 755 if (strlen (name) != 4+5*4 || 4 != sscanf (name, "rgba:%4hx/%4hx/%4hx/%4hx%c", &c.r, &c.g, &c.b, &c.a, &eos))
760 { 756 {
761 XColor xc; 757 XColor xc;
762 758
763 if (XParseColor (screen->dpy, screen->cmap, name, &xc)) 759 if (XParseColor (screen->dpy, screen->cmap, name, &xc))
764 { 760 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines