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.102 by root, Tue Nov 4 11:03:29 2008 UTC

59#if ENABLE_EWMH 59#if ENABLE_EWMH
60 "_NET_WM_PID", 60 "_NET_WM_PID",
61 "_NET_WM_NAME", 61 "_NET_WM_NAME",
62 "_NET_WM_ICON_NAME", 62 "_NET_WM_ICON_NAME",
63 "_NET_WM_PING", 63 "_NET_WM_PING",
64 "_NET_WM_ICON",
64#endif 65#endif
65#if USE_XIM 66#if USE_XIM
66 "WM_LOCALE_NAME", 67 "WM_LOCALE_NAME",
67 "XIM_SERVERS", 68 "XIM_SERVERS",
68#endif 69#endif
543} 544}
544#endif 545#endif
545 546
546void rxvt_display::x_cb (ev::io &w, int revents) 547void rxvt_display::x_cb (ev::io &w, int revents)
547{ 548{
549 flush_ev.start ();
550}
551
552void rxvt_display::flush_cb (ev::prepare &w, int revents)
553{
548 while (XEventsQueued (dpy, QueuedAfterReading)) 554 while (XEventsQueued (dpy, QueuedAfterFlush))
555 do
549 { 556 {
550 XEvent xev; 557 XEvent xev;
551 XNextEvent (dpy, &xev); 558 XNextEvent (dpy, &xev);
552 559
553#ifdef USE_XIM 560#ifdef USE_XIM
554 if (!XFilterEvent (&xev, None)) 561 if (!XFilterEvent (&xev, None))
555 { 562 {
556 if (xev.type == PropertyNotify 563 if (xev.type == PropertyNotify
557 && xev.xany.window == root 564 && xev.xany.window == root
558 && xev.xproperty.atom == xa[XA_XIM_SERVERS]) 565 && xev.xproperty.atom == xa[XA_XIM_SERVERS])
559 im_change_check (); 566 im_change_check ();
560#endif 567#endif
561 if (xev.type == MappingNotify) 568 if (xev.type == MappingNotify)
562 XRefreshKeyboardMapping (&xev.xmapping); 569 XRefreshKeyboardMapping (&xev.xmapping);
563 570
564 for (int i = xw.size (); i--; ) 571 for (int i = xw.size (); i--; )
565 { 572 {
566 if (!xw[i]) 573 if (!xw[i])
567 xw.erase_unordered (i); 574 xw.erase_unordered (i);
568 else if (xw[i]->window == xev.xany.window) 575 else if (xw[i]->window == xev.xany.window)
569 xw[i]->call (xev); 576 xw[i]->call (xev);
570 } 577 }
571#ifdef USE_XIM 578#ifdef USE_XIM
572 } 579 }
573#endif 580#endif
574 } 581 }
575} 582 while (XEventsQueued (dpy, QueuedAlready));
576 583
577void rxvt_display::flush_cb (ev::prepare &w, int revents)
578{
579 w.stop (); 584 w.stop ();
580 XFlush (dpy);
581} 585}
582 586
583void rxvt_display::reg (xevent_watcher *w) 587void rxvt_display::reg (xevent_watcher *w)
584{ 588{
585 if (!w->active) 589 if (!w->active)
599} 603}
600 604
601void rxvt_display::set_selection_owner (rxvt_term *owner) 605void rxvt_display::set_selection_owner (rxvt_term *owner)
602{ 606{
603 if (selection_owner && selection_owner != owner) 607 if (selection_owner && selection_owner != owner)
608 {
609 rxvt_term *owner = selection_owner;
610
604 selection_owner->selection_clear (); 611 owner->selection_clear ();
612 owner->flush ();
613 }
605 614
606 selection_owner = owner; 615 selection_owner = owner;
607} 616}
608 617
609#ifdef USE_XIM 618#ifdef USE_XIM
668} 677}
669 678
670bool 679bool
671rxvt_color::alloc (rxvt_screen *screen, const rgba &color) 680rxvt_color::alloc (rxvt_screen *screen, const rgba &color)
672{ 681{
682 //TODO: only supports 24 bit
683 int alpha = color.a >= 0xff00 ? 0xffff : color.a;
684
673#if XFT 685#if XFT
674 XRenderPictFormat *format; 686 XRenderPictFormat *format;
675 687
676 // FUCKING Xft gets it wrong, of course, so work around it. 688 // FUCKING Xft gets it wrong, of course, so work around it.
677 // Transparency users should eat shit and die, and then 689 // Transparency users should eat shit and die, and then
681 { 693 {
682 // the fun lies in doing everything manually... 694 // the fun lies in doing everything manually...
683 c.color.red = color.r; 695 c.color.red = color.r;
684 c.color.green = color.g; 696 c.color.green = color.g;
685 c.color.blue = color.b; 697 c.color.blue = color.b;
686 c.color.alpha = color.a; 698 c.color.alpha = alpha;
687 699
688 c.pixel = insert_component (color.r, format->direct.redMask , format->direct.red ) 700 c.pixel = insert_component (color.r, format->direct.redMask , format->direct.red )
689 | insert_component (color.g, format->direct.greenMask, format->direct.green) 701 | insert_component (color.g, format->direct.greenMask, format->direct.green)
690 | insert_component (color.b, format->direct.blueMask , format->direct.blue ) 702 | insert_component (color.b, format->direct.blueMask , format->direct.blue )
691 | insert_component (color.a, format->direct.alphaMask, format->direct.alpha); 703 | insert_component (alpha , format->direct.alphaMask, format->direct.alpha);
692 704
693 return true; 705 return true;
694 } 706 }
695 else 707 else
696 { 708 {
697 XRenderColor d; 709 XRenderColor d;
698 710
699 d.red = color.r; 711 d.red = color.r;
700 d.green = color.g; 712 d.green = color.g;
701 d.blue = color.b; 713 d.blue = color.b;
702 d.alpha = color.a; 714 d.alpha = alpha;
703 715
704 return XftColorAllocValue (screen->dpy, screen->visual, screen->cmap, &d, &c); 716 return XftColorAllocValue (screen->dpy, screen->visual, screen->cmap, &d, &c);
705 } 717 }
706#else 718#else
707 c.red = color.r; 719 c.red = color.r;
732{ 744{
733 rgba c; 745 rgba c;
734 char eos; 746 char eos;
735 int skip; 747 int skip;
736 748
749 c.a = rgba::MAX_CC;
750
737 // parse the nonstandard "[alphapercent]" prefix 751 // parse the nonstandard "[alphapercent]" prefix
738 if (1 <= sscanf (name, "[%hd]%n", &c.a, &skip)) 752 if (1 <= sscanf (name, "[%hd]%n", &c.a, &skip))
739 { 753 {
740 c.a = lerp<int, int, int> (0, rgba::MAX_CC, c.a); 754 c.a = lerp<int, int, int> (0, rgba::MAX_CC, c.a);
741 name += skip; 755 name += skip;
742 } 756 }
743 else
744 c.a = rgba::MAX_CC;
745 757
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 758 // 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)) 759 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 { 760 {
761 XColor xc; 761 XColor xc;
762 762
763 if (XParseColor (screen->dpy, screen->cmap, name, &xc)) 763 if (XParseColor (screen->dpy, screen->cmap, name, &xc))
764 { 764 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines