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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines