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.82 by root, Fri Dec 14 05:25:26 2007 UTC vs.
Revision 1.93 by root, Sat Jan 26 10:24:47 2008 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines