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.63 by root, Fri Aug 18 23:03:31 2006 UTC vs.
Revision 1.77 by sasha, Wed Nov 14 22:25:42 2007 UTC

64#endif 64#endif
65#if USE_XIM 65#if USE_XIM
66 "WM_LOCALE_NAME", 66 "WM_LOCALE_NAME",
67 "XIM_SERVERS", 67 "XIM_SERVERS",
68#endif 68#endif
69#ifdef TRANSPARENT 69#ifdef ENABLE_TRANSPARENCY
70 "_XROOTPMAP_ID", 70 "_XROOTPMAP_ID",
71 "ESETROOT_PMAP_ID", 71 "ESETROOT_PMAP_ID",
72#endif 72#endif
73#if ENABLE_XEMBED 73#if ENABLE_XEMBED
74 "_XEMBED", 74 "_XEMBED",
183 183
184 XIMCallback ximcallback; 184 XIMCallback ximcallback;
185 ximcallback.client_data = (XPointer)this; 185 ximcallback.client_data = (XPointer)this;
186 ximcallback.callback = im_destroy_cb; 186 ximcallback.callback = im_destroy_cb;
187 187
188 XSetIMValues (xim, XNDestroyCallback, &ximcallback, 0); 188 XSetIMValues (xim, XNDestroyCallback, &ximcallback, (char *)0);
189 189
190 return true; 190 return true;
191} 191}
192 192
193rxvt_xim::~rxvt_xim () 193rxvt_xim::~rxvt_xim ()
462#endif 462#endif
463 463
464 int fd = XConnectionNumber (dpy); 464 int fd = XConnectionNumber (dpy);
465 465
466 // try to detect wether we have a local connection. 466 // try to detect wether we have a local connection.
467 // assume unix domains socket == local, everything else not 467 // assume unix domain socket == local, everything else not
468 // TODO: might want to check for inet/127.0.0.1 468 // TODO: might want to check for inet/127.0.0.1
469 is_local = 0; 469 is_local = 0;
470 sockaddr_un sa; 470 sockaddr_un sa;
471 socklen_t sl = sizeof (sa); 471 socklen_t sl = sizeof (sa);
472 472
473 if (!getsockname (fd, (sockaddr *)&sa, &sl)) 473 if (!getsockname (fd, (sockaddr *)&sa, &sl))
474 is_local = sa.sun_family == AF_LOCAL; 474 is_local = sa.sun_family == AF_UNIX;
475 475
476 x_ev.start (fd, EVENT_READ); 476 x_ev.start (fd, ev::READ);
477 fcntl (fd, F_SETFD, FD_CLOEXEC); 477 fcntl (fd, F_SETFD, FD_CLOEXEC);
478 478
479 XSelectInput (dpy, root, PropertyChangeMask); 479 XSelectInput (dpy, root, PropertyChangeMask);
480 480
481 flush (); 481 flush ();
538 538
539 XFree (atoms); 539 XFree (atoms);
540} 540}
541#endif 541#endif
542 542
543void rxvt_display::x_cb (io_watcher &w, short revents) 543void rxvt_display::x_cb (ev::io &w, int revents)
544{ 544{
545 do 545 do
546 { 546 {
547 XEvent xev; 547 XEvent xev;
548 XNextEvent (dpy, &xev); 548 XNextEvent (dpy, &xev);
553 if (xev.type == PropertyNotify 553 if (xev.type == PropertyNotify
554 && xev.xany.window == root 554 && xev.xany.window == root
555 && xev.xproperty.atom == xa[XA_XIM_SERVERS]) 555 && xev.xproperty.atom == xa[XA_XIM_SERVERS])
556 im_change_check (); 556 im_change_check ();
557#endif 557#endif
558 if (xev.type == MappingNotify)
559 XRefreshKeyboardMapping (&xev.xmapping);
560
558 for (int i = xw.size (); i--; ) 561 for (int i = xw.size (); i--; )
559 { 562 {
560 if (!xw[i]) 563 if (!xw[i])
561 xw.erase_unordered (i); 564 xw.erase_unordered (i);
562 else if (xw[i]->window == xev.xany.window) 565 else if (xw[i]->window == xev.xany.window)
572} 575}
573 576
574void rxvt_display::flush () 577void rxvt_display::flush ()
575{ 578{
576 if (XEventsQueued (dpy, QueuedAlready)) 579 if (XEventsQueued (dpy, QueuedAlready))
577 x_cb (x_ev, EVENT_READ); 580 x_cb (x_ev, ev::READ);
578 581
579 XFlush (dpy); 582 XFlush (dpy);
580} 583}
581 584
582void rxvt_display::reg (xevent_watcher *w) 585void rxvt_display::reg (xevent_watcher *w)
663static unsigned int 666static unsigned int
664insert_component (unsigned int value, unsigned int mask, unsigned int shift) 667insert_component (unsigned int value, unsigned int mask, unsigned int shift)
665{ 668{
666 return (value * (mask + 1) >> 16) << shift; 669 return (value * (mask + 1) >> 16) << shift;
667} 670}
668 671
669bool 672bool
670rxvt_color::alloc (rxvt_screen *screen, const rgba &color) 673rxvt_color::alloc (rxvt_screen *screen, const rgba &color)
671{ 674{
672#if XFT 675#if XFT
673 XRenderPictFormat *format; 676 XRenderPictFormat *format;
707 c.green = color.g; 710 c.green = color.g;
708 c.blue = color.b; 711 c.blue = color.b;
709 712
710 if (screen->visual->c_class == TrueColor) 713 if (screen->visual->c_class == TrueColor)
711 { 714 {
712 c.pixel = (color.r * (screen->visual->red_mask >> ctz (screen->visual->red_mask )) 715 c.pixel = (color.r >> (16 - popcount (screen->visual->red_mask )) << ctz (screen->visual->red_mask ))
713 / rgba::MAX_CC) << ctz (screen->visual->red_mask ) 716 | (color.g >> (16 - popcount (screen->visual->green_mask)) << ctz (screen->visual->green_mask))
714 | (color.g * (screen->visual->green_mask >> ctz (screen->visual->green_mask))
715 / rgba::MAX_CC) << ctz (screen->visual->green_mask)
716 | (color.b * (screen->visual->blue_mask >> ctz (screen->visual->blue_mask )) 717 | (color.b >> (16 - popcount (screen->visual->blue_mask )) << ctz (screen->visual->blue_mask ));
717 / rgba::MAX_CC) << ctz (screen->visual->blue_mask );
718 718
719 return true; 719 return true;
720 } 720 }
721 else if (XAllocColor (screen->dpy, screen->cmap, &c)) 721 else if (XAllocColor (screen->dpy, screen->cmap, &c))
722 return true; 722 return true;
743 name += skip; 743 name += skip;
744 } 744 }
745 else 745 else
746 c.a = rgba::MAX_CC; 746 c.a = rgba::MAX_CC;
747 747
748 // parse the non-standard "#aarrggbb" format
749 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))
750 {
751 if (c.r)
752 c.r = (c.r << 8) | 0x0ff;
753 if (c.g)
754 c.g = (c.g << 8) | 0x0ff;
755 if (c.b)
756 c.b = (c.b << 8) | 0x0ff;
757 if (c.a)
758 c.a = (c.a << 8) | 0x0ff;
759 }
748 // parse the non-standard "rgba:rrrr/gggg/bbbb/aaaa" format 760 // parse the non-standard "rgba:rrrr/gggg/bbbb/aaaa" format
749 if (strlen (name) != 4+5*4 || 4 != sscanf (name, "rgba:%4hx/%4hx/%4hx/%4hx%c", &c.r, &c.g, &c.b, &c.a, &eos)) 761 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))
750 { 762 {
751 XColor xc, xc_exact; 763 XColor xc;
752 764
753 if (XParseColor (screen->dpy, screen->cmap, name, &xc)) 765 if (XParseColor (screen->dpy, screen->cmap, name, &xc))
754 { 766 {
755 c.r = xc.red; 767 c.r = xc.red;
756 c.g = xc.green; 768 c.g = xc.green;
783 { 795 {
784 XColor *colors = new XColor [screen->visual->map_entries]; 796 XColor *colors = new XColor [screen->visual->map_entries];
785 797
786 for (int i = 0; i < cmap_size; i++) 798 for (int i = 0; i < cmap_size; i++)
787 colors [i].pixel = i; 799 colors [i].pixel = i;
788 800
789 // many kilobytes transfer per colour, but pseudocolor isn't worth 801 // many kilobytes transfer per colour, but pseudocolor isn't worth
790 // many extra optimisations. 802 // many extra optimisations.
791 XQueryColors (screen->dpy, screen->cmap, colors, cmap_size); 803 XQueryColors (screen->dpy, screen->cmap, colors, cmap_size);
792 804
793 int diff = 0x7fffffffUL; 805 int diff = 0x7fffffffUL;
806 } 818 }
807 } 819 }
808 820
809 //rxvt_warn ("could not allocate %04x %04x %04x, getting %04x %04x %04x instead (%d)\n", 821 //rxvt_warn ("could not allocate %04x %04x %04x, getting %04x %04x %04x instead (%d)\n",
810 // color.r, color.g, color.b, best->red, best->green, best->blue, diff); 822 // color.r, color.g, color.b, best->red, best->green, best->blue, diff);
811 823
812 got = alloc (screen, rgba (best->red, best->green, best->blue)); 824 got = alloc (screen, rgba (best->red, best->green, best->blue));
813 825
814 delete [] colors; 826 delete [] colors;
815 } 827 }
816#endif 828#endif
844 color.green = c.g; 856 color.green = c.g;
845 color.blue = c.b; 857 color.blue = c.b;
846 color.pixel = (Pixel)*this; 858 color.pixel = (Pixel)*this;
847} 859}
848 860
849void 861void
850rxvt_color::free (rxvt_screen *screen) 862rxvt_color::free (rxvt_screen *screen)
851{ 863{
852 if (screen->visual->c_class == TrueColor) 864 if (screen->visual->c_class == TrueColor)
853 return; // nothing to do 865 return; // nothing to do
854 866
874 lerp (c.a, to.a, percent) 886 lerp (c.a, to.a, percent)
875 ) 887 )
876 ); 888 );
877} 889}
878 890
891#if TRACE_PIXMAPS
892# undef XCreatePixmap
893# undef XFreePixmap
894Pixmap trace_XCreatePixmap (const char *file, int line, Display *dpy, Window r, unsigned int w, unsigned int h, unsigned int d)
895{
896 Pixmap res = XCreatePixmap (dpy, r, w, h, d);
897 fprintf (stderr, "%s:%d: XCreatePixmap (%p,%lX,%u,%u,%u) returned %lX\n", file, line, dpy, r, w, h, d, res);
898 return res;
899}
900
901void trace_XFreePixmap (const char *file, int line, Display *dpy, Pixmap p)
902{
903 fprintf (stderr, "%s:%d: XFreePixmap (%p,%lX)\n", file, line, dpy, p);
904 XFreePixmap (dpy,p);
905}
906#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines