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.45 by root, Wed Feb 1 01:58:47 2006 UTC vs.
Revision 1.47 by root, Thu Feb 2 00:31:47 2006 UTC

395 395
396void 396void
397rxvt_display::ref_next () 397rxvt_display::ref_next ()
398{ 398{
399 // TODO: somehow check wether the database files/resources changed 399 // TODO: somehow check wether the database files/resources changed
400 // before re-loading/parsing 400 // before affording re-loading/parsing
401 XrmDestroyDatabase (XrmGetDatabase (display)); 401 XrmDestroyDatabase (XrmGetDatabase (display));
402 XrmSetDatabase (display, get_resources ()); 402 XrmSetDatabase (display, get_resources ());
403} 403}
404 404
405rxvt_display::~rxvt_display () 405rxvt_display::~rxvt_display ()
508 508
509 selection_owner = owner; 509 selection_owner = owner;
510} 510}
511 511
512#ifdef USE_XIM 512#ifdef USE_XIM
513
513void rxvt_display::reg (im_watcher *w) 514void rxvt_display::reg (im_watcher *w)
514{ 515{
515 imw.push_back (w); 516 imw.push_back (w);
516} 517}
517 518
541 return xim; 542 return xim;
542} 543}
543 544
544void rxvt_display::put_xim (rxvt_xim *xim) 545void rxvt_display::put_xim (rxvt_xim *xim)
545{ 546{
546#if XLIB_IS_RACEFREE 547# if XLIB_IS_RACEFREE
547 xims.put (xim); 548 xims.put (xim);
548#endif 549# endif
549} 550}
551
550#endif 552#endif
551 553
552Atom rxvt_display::atom (const char *name) 554Atom rxvt_display::atom (const char *name)
553{ 555{
554 return XInternAtom (display, name, False); 556 return XInternAtom (display, name, False);
596 d.alpha = color.a; 598 d.alpha = color.a;
597 599
598 return XftColorAllocValue (screen->xdisp, screen->visual, screen->cmap, &d, &c); 600 return XftColorAllocValue (screen->xdisp, screen->visual, screen->cmap, &d, &c);
599 } 601 }
600#else 602#else
603 c.red = color.r;
604 c.green = color.g;
605 c.blue = color.b;
606
601 if (screen->visual->c_class == TrueColor || screen->visual->c_class == DirectColor) 607 if (screen->visual->c_class == TrueColor || screen->visual->c_class == DirectColor)
602 { 608 {
603 c.red = color.g;
604 c.green = color.g;
605 c.blue = color.g;
606 c.pixel = (color.r * (screen->visual->red_mask >> ctz (screen->visual->red_mask )) 609 c.pixel = (color.r * (screen->visual->red_mask >> ctz (screen->visual->red_mask ))
607 / rgba::MAX_CC) << ctz (screen->visual->red_mask ) 610 / rgba::MAX_CC) << ctz (screen->visual->red_mask )
608 | (color.g * (screen->visual->green_mask >> ctz (screen->visual->green_mask)) 611 | (color.g * (screen->visual->green_mask >> ctz (screen->visual->green_mask))
609 / rgba::MAX_CC) << ctz (screen->visual->green_mask) 612 / rgba::MAX_CC) << ctz (screen->visual->green_mask)
610 | (color.b * (screen->visual->blue_mask >> ctz (screen->visual->blue_mask )) 613 | (color.b * (screen->visual->blue_mask >> ctz (screen->visual->blue_mask ))
611 / rgba::MAX_CC) << ctz (screen->visual->blue_mask ); 614 / rgba::MAX_CC) << ctz (screen->visual->blue_mask );
612 615
613 return true; 616 return true;
614 } 617 }
618 else if (XAllocColor (screen->xdisp, screen->cmap, &c))
619 return true;
615 else 620 else
616 {
617 c.red = color.r;
618 c.green = color.g;
619 c.blue = color.b;
620
621 if (XAllocColor (screen->xdisp, screen->cmap, &c))
622 return true;
623 else
624 c.pixel = (color.r + color.g + color.b) > 128*3 621 c.pixel = (color.r + color.g + color.b) > 128*3
625 ? WhitePixelOfScreen (DefaultScreenOfDisplay (screen->xdisp)) 622 ? WhitePixelOfScreen (DefaultScreenOfDisplay (screen->xdisp))
626 : BlackPixelOfScreen (DefaultScreenOfDisplay (screen->xdisp)); 623 : BlackPixelOfScreen (DefaultScreenOfDisplay (screen->xdisp));
627 }
628#endif 624#endif
629 625
630 return false; 626 return false;
631} 627}
632 628
635{ 631{
636 rgba c; 632 rgba c;
637 char eos; 633 char eos;
638 int skip; 634 int skip;
639 635
636 // parse the nonstandard "[alphapercent]" prefix
640 if (1 <= sscanf (name, "[%hd]%n", &c.a, &skip)) 637 if (1 <= sscanf (name, "[%hd]%n", &c.a, &skip))
641 { 638 {
642 c.a = lerp<int, int, int> (0, rgba::MAX_CC, c.a); 639 c.a = lerp<int, int, int> (0, rgba::MAX_CC, c.a);
643 name += skip; 640 name += skip;
644 } 641 }
645 else 642 else
646 c.a = rgba::MAX_CC; 643 c.a = rgba::MAX_CC;
647 644
648 // parse the non-standard rgba format 645 // parse the non-standard "rgba:rrrr/gggg/bbbb/aaaa" format
649 if (strlen (name) != 4+5*4 || 4 != sscanf (name, "rgba:%hx/%hx/%hx/%hx%c", &c.r, &c.g, &c.b, &c.a, &eos)) 646 if (strlen (name) != 4+5*4 || 4 != sscanf (name, "rgba:%4hx/%4hx/%4hx/%4hx%c", &c.r, &c.g, &c.b, &c.a, &eos))
650 { 647 {
651 XColor xc, xc_exact; 648 XColor xc, xc_exact;
652 649
653 if (XParseColor (screen->xdisp, screen->cmap, name, &xc)) 650 if (XParseColor (screen->xdisp, screen->cmap, name, &xc))
654 { 651 {
732 color.b = c.blue; 729 color.b = c.blue;
733 color.a = rgba::MAX_CC; 730 color.a = rgba::MAX_CC;
734#endif 731#endif
735} 732}
736 733
734void
735rxvt_color::get (XColor &color)
736{
737 rgba c;
738 get (c);
739
740 color.red = c.r;
741 color.green = c.g;
742 color.blue = c.b;
743 color.pixel = (Pixel)*this;
744}
745
737void 746void
738rxvt_color::free (rxvt_screen *screen) 747rxvt_color::free (rxvt_screen *screen)
739{ 748{
740#if XFT 749#if XFT
741 XftColorFree (screen->xdisp, screen->visual, screen->cmap, &c); 750 XftColorFree (screen->xdisp, screen->visual, screen->cmap, &c);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines