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.65 by sasha, Fri Jun 8 20:04:12 2007 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 ()
443 return false; 443 return false;
444 444
445 screen = DefaultScreen (dpy); 445 screen = DefaultScreen (dpy);
446 root = DefaultRootWindow (dpy); 446 root = DefaultRootWindow (dpy);
447 447
448#ifdef HAVE_AFTERIMAGE
449 ::dpy = dpy; /* init global var from libAfter... */
450 asv = create_asvisual_for_id( dpy, screen, DefaultDepth(dpy,screen), XVisualIDFromVisual(DefaultVisual(dpy,screen)), None, NULL );
451#endif
452
453 assert (sizeof (xa_names) / sizeof (char *) == NUM_XA); 448 assert (sizeof (xa_names) / sizeof (char *) == NUM_XA);
454 XInternAtoms (dpy, (char **)xa_names, NUM_XA, False, xa); 449 XInternAtoms (dpy, (char **)xa_names, NUM_XA, False, xa);
455 450
456 XrmSetDatabase (dpy, get_resources (false)); 451 XrmSetDatabase (dpy, get_resources (false));
457 452
467#endif 462#endif
468 463
469 int fd = XConnectionNumber (dpy); 464 int fd = XConnectionNumber (dpy);
470 465
471 // try to detect wether we have a local connection. 466 // try to detect wether we have a local connection.
472 // assume unix domains socket == local, everything else not 467 // assume unix domain socket == local, everything else not
473 // TODO: might want to check for inet/127.0.0.1 468 // TODO: might want to check for inet/127.0.0.1
474 is_local = 0; 469 is_local = 0;
475 sockaddr_un sa; 470 sockaddr_un sa;
476 socklen_t sl = sizeof (sa); 471 socklen_t sl = sizeof (sa);
477 472
478 if (!getsockname (fd, (sockaddr *)&sa, &sl)) 473 if (!getsockname (fd, (sockaddr *)&sa, &sl))
479 is_local = sa.sun_family == AF_LOCAL; 474 is_local = sa.sun_family == AF_UNIX;
480 475
481 x_ev.start (fd, EVENT_READ); 476 x_ev.start (fd, ev::READ);
482 fcntl (fd, F_SETFD, FD_CLOEXEC); 477 fcntl (fd, F_SETFD, FD_CLOEXEC);
483 478
484 XSelectInput (dpy, root, PropertyChangeMask); 479 XSelectInput (dpy, root, PropertyChangeMask);
485 480
486 flush (); 481 flush ();
543 538
544 XFree (atoms); 539 XFree (atoms);
545} 540}
546#endif 541#endif
547 542
548void rxvt_display::x_cb (io_watcher &w, short revents) 543void rxvt_display::x_cb (ev::io &w, int revents)
549{ 544{
550 do 545 do
551 { 546 {
552 XEvent xev; 547 XEvent xev;
553 XNextEvent (dpy, &xev); 548 XNextEvent (dpy, &xev);
558 if (xev.type == PropertyNotify 553 if (xev.type == PropertyNotify
559 && xev.xany.window == root 554 && xev.xany.window == root
560 && xev.xproperty.atom == xa[XA_XIM_SERVERS]) 555 && xev.xproperty.atom == xa[XA_XIM_SERVERS])
561 im_change_check (); 556 im_change_check ();
562#endif 557#endif
558 if (xev.type == MappingNotify)
559 XRefreshKeyboardMapping (&xev.xmapping);
560
563 for (int i = xw.size (); i--; ) 561 for (int i = xw.size (); i--; )
564 { 562 {
565 if (!xw[i]) 563 if (!xw[i])
566 xw.erase_unordered (i); 564 xw.erase_unordered (i);
567 else if (xw[i]->window == xev.xany.window) 565 else if (xw[i]->window == xev.xany.window)
577} 575}
578 576
579void rxvt_display::flush () 577void rxvt_display::flush ()
580{ 578{
581 if (XEventsQueued (dpy, QueuedAlready)) 579 if (XEventsQueued (dpy, QueuedAlready))
582 x_cb (x_ev, EVENT_READ); 580 x_cb (x_ev, ev::READ);
583 581
584 XFlush (dpy); 582 XFlush (dpy);
585} 583}
586 584
587void rxvt_display::reg (xevent_watcher *w) 585void rxvt_display::reg (xevent_watcher *w)
668static unsigned int 666static unsigned int
669insert_component (unsigned int value, unsigned int mask, unsigned int shift) 667insert_component (unsigned int value, unsigned int mask, unsigned int shift)
670{ 668{
671 return (value * (mask + 1) >> 16) << shift; 669 return (value * (mask + 1) >> 16) << shift;
672} 670}
673 671
674bool 672bool
675rxvt_color::alloc (rxvt_screen *screen, const rgba &color) 673rxvt_color::alloc (rxvt_screen *screen, const rgba &color)
676{ 674{
677#if XFT 675#if XFT
678 XRenderPictFormat *format; 676 XRenderPictFormat *format;
745 name += skip; 743 name += skip;
746 } 744 }
747 else 745 else
748 c.a = rgba::MAX_CC; 746 c.a = rgba::MAX_CC;
749 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 }
750 // parse the non-standard "rgba:rrrr/gggg/bbbb/aaaa" format 760 // parse the non-standard "rgba:rrrr/gggg/bbbb/aaaa" format
751 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))
752 { 762 {
753 XColor xc, xc_exact; 763 XColor xc;
754 764
755 if (XParseColor (screen->dpy, screen->cmap, name, &xc)) 765 if (XParseColor (screen->dpy, screen->cmap, name, &xc))
756 { 766 {
757 c.r = xc.red; 767 c.r = xc.red;
758 c.g = xc.green; 768 c.g = xc.green;
785 { 795 {
786 XColor *colors = new XColor [screen->visual->map_entries]; 796 XColor *colors = new XColor [screen->visual->map_entries];
787 797
788 for (int i = 0; i < cmap_size; i++) 798 for (int i = 0; i < cmap_size; i++)
789 colors [i].pixel = i; 799 colors [i].pixel = i;
790 800
791 // many kilobytes transfer per colour, but pseudocolor isn't worth 801 // many kilobytes transfer per colour, but pseudocolor isn't worth
792 // many extra optimisations. 802 // many extra optimisations.
793 XQueryColors (screen->dpy, screen->cmap, colors, cmap_size); 803 XQueryColors (screen->dpy, screen->cmap, colors, cmap_size);
794 804
795 int diff = 0x7fffffffUL; 805 int diff = 0x7fffffffUL;
808 } 818 }
809 } 819 }
810 820
811 //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",
812 // 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);
813 823
814 got = alloc (screen, rgba (best->red, best->green, best->blue)); 824 got = alloc (screen, rgba (best->red, best->green, best->blue));
815 825
816 delete [] colors; 826 delete [] colors;
817 } 827 }
818#endif 828#endif
846 color.green = c.g; 856 color.green = c.g;
847 color.blue = c.b; 857 color.blue = c.b;
848 color.pixel = (Pixel)*this; 858 color.pixel = (Pixel)*this;
849} 859}
850 860
851void 861void
852rxvt_color::free (rxvt_screen *screen) 862rxvt_color::free (rxvt_screen *screen)
853{ 863{
854 if (screen->visual->c_class == TrueColor) 864 if (screen->visual->c_class == TrueColor)
855 return; // nothing to do 865 return; // nothing to do
856 866
876 lerp (c.a, to.a, percent) 886 lerp (c.a, to.a, percent)
877 ) 887 )
878 ); 888 );
879} 889}
880 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