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.46 by root, Wed Feb 1 18:36:48 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 printf ("next\n");//D
403} 404}
404 405
405rxvt_display::~rxvt_display () 406rxvt_display::~rxvt_display ()
406{ 407{
407 if (!display) 408 if (!display)
508 509
509 selection_owner = owner; 510 selection_owner = owner;
510} 511}
511 512
512#ifdef USE_XIM 513#ifdef USE_XIM
514
513void rxvt_display::reg (im_watcher *w) 515void rxvt_display::reg (im_watcher *w)
514{ 516{
515 imw.push_back (w); 517 imw.push_back (w);
516} 518}
517 519
541 return xim; 543 return xim;
542} 544}
543 545
544void rxvt_display::put_xim (rxvt_xim *xim) 546void rxvt_display::put_xim (rxvt_xim *xim)
545{ 547{
546#if XLIB_IS_RACEFREE 548# if XLIB_IS_RACEFREE
547 xims.put (xim); 549 xims.put (xim);
548#endif 550# endif
549} 551}
552
550#endif 553#endif
551 554
552Atom rxvt_display::atom (const char *name) 555Atom rxvt_display::atom (const char *name)
553{ 556{
554 return XInternAtom (display, name, False); 557 return XInternAtom (display, name, False);
596 d.alpha = color.a; 599 d.alpha = color.a;
597 600
598 return XftColorAllocValue (screen->xdisp, screen->visual, screen->cmap, &d, &c); 601 return XftColorAllocValue (screen->xdisp, screen->visual, screen->cmap, &d, &c);
599 } 602 }
600#else 603#else
604 c.red = color.r;
605 c.green = color.g;
606 c.blue = color.b;
607
601 if (screen->visual->c_class == TrueColor || screen->visual->c_class == DirectColor) 608 if (screen->visual->c_class == TrueColor || screen->visual->c_class == DirectColor)
602 { 609 {
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 )) 610 c.pixel = (color.r * (screen->visual->red_mask >> ctz (screen->visual->red_mask ))
607 / rgba::MAX_CC) << ctz (screen->visual->red_mask ) 611 / rgba::MAX_CC) << ctz (screen->visual->red_mask )
608 | (color.g * (screen->visual->green_mask >> ctz (screen->visual->green_mask)) 612 | (color.g * (screen->visual->green_mask >> ctz (screen->visual->green_mask))
609 / rgba::MAX_CC) << ctz (screen->visual->green_mask) 613 / rgba::MAX_CC) << ctz (screen->visual->green_mask)
610 | (color.b * (screen->visual->blue_mask >> ctz (screen->visual->blue_mask )) 614 | (color.b * (screen->visual->blue_mask >> ctz (screen->visual->blue_mask ))
611 / rgba::MAX_CC) << ctz (screen->visual->blue_mask ); 615 / rgba::MAX_CC) << ctz (screen->visual->blue_mask );
612 616
613 return true; 617 return true;
614 } 618 }
619 else if (XAllocColor (screen->xdisp, screen->cmap, &c))
620 return true;
615 else 621 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 622 c.pixel = (color.r + color.g + color.b) > 128*3
625 ? WhitePixelOfScreen (DefaultScreenOfDisplay (screen->xdisp)) 623 ? WhitePixelOfScreen (DefaultScreenOfDisplay (screen->xdisp))
626 : BlackPixelOfScreen (DefaultScreenOfDisplay (screen->xdisp)); 624 : BlackPixelOfScreen (DefaultScreenOfDisplay (screen->xdisp));
627 }
628#endif 625#endif
629 626
630 return false; 627 return false;
631} 628}
632 629
635{ 632{
636 rgba c; 633 rgba c;
637 char eos; 634 char eos;
638 int skip; 635 int skip;
639 636
637 // parse the nonstandard "[alphapercent]" prefix
640 if (1 <= sscanf (name, "[%hd]%n", &c.a, &skip)) 638 if (1 <= sscanf (name, "[%hd]%n", &c.a, &skip))
641 { 639 {
642 c.a = lerp<int, int, int> (0, rgba::MAX_CC, c.a); 640 c.a = lerp<int, int, int> (0, rgba::MAX_CC, c.a);
643 name += skip; 641 name += skip;
644 } 642 }
645 else 643 else
646 c.a = rgba::MAX_CC; 644 c.a = rgba::MAX_CC;
647 645
648 // parse the non-standard rgba format 646 // 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)) 647 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 { 648 {
651 XColor xc, xc_exact; 649 XColor xc, xc_exact;
652 650
653 if (XParseColor (screen->xdisp, screen->cmap, name, &xc)) 651 if (XParseColor (screen->xdisp, screen->cmap, name, &xc))
654 { 652 {
732 color.b = c.blue; 730 color.b = c.blue;
733 color.a = rgba::MAX_CC; 731 color.a = rgba::MAX_CC;
734#endif 732#endif
735} 733}
736 734
735void
736rxvt_color::get (XColor &color)
737{
738 rgba c;
739 get (c);
740
741 color.red = c.r;
742 color.green = c.g;
743 color.blue = c.b;
744 color.pixel = (Pixel)*this;
745}
746
737void 747void
738rxvt_color::free (rxvt_screen *screen) 748rxvt_color::free (rxvt_screen *screen)
739{ 749{
740#if XFT 750#if XFT
741 XftColorFree (screen->xdisp, screen->visual, screen->cmap, &c); 751 XftColorFree (screen->xdisp, screen->visual, screen->cmap, &c);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines