… | |
… | |
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 | |
448 | assert (sizeof (xa_names) / sizeof (char *) == NUM_XA); |
453 | assert (sizeof (xa_names) / sizeof (char *) == NUM_XA); |
449 | XInternAtoms (dpy, (char **)xa_names, NUM_XA, False, xa); |
454 | XInternAtoms (dpy, (char **)xa_names, NUM_XA, False, xa); |
450 | |
455 | |
451 | XrmSetDatabase (dpy, get_resources (false)); |
456 | XrmSetDatabase (dpy, get_resources (false)); |
452 | |
457 | |
… | |
… | |
707 | c.green = color.g; |
712 | c.green = color.g; |
708 | c.blue = color.b; |
713 | c.blue = color.b; |
709 | |
714 | |
710 | if (screen->visual->c_class == TrueColor) |
715 | if (screen->visual->c_class == TrueColor) |
711 | { |
716 | { |
712 | c.pixel = (color.r * (screen->visual->red_mask >> ctz (screen->visual->red_mask )) |
717 | c.pixel = (color.r >> (16 - popcount (screen->visual->red_mask )) << ctz (screen->visual->red_mask )) |
713 | / rgba::MAX_CC) << ctz (screen->visual->red_mask ) |
718 | | (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 )) |
719 | | (color.b >> (16 - popcount (screen->visual->blue_mask )) << ctz (screen->visual->blue_mask )); |
717 | / rgba::MAX_CC) << ctz (screen->visual->blue_mask ); |
|
|
718 | |
720 | |
719 | return true; |
721 | return true; |
720 | } |
722 | } |
721 | else if (XAllocColor (screen->dpy, screen->cmap, &c)) |
723 | else if (XAllocColor (screen->dpy, screen->cmap, &c)) |
722 | return true; |
724 | return true; |
… | |
… | |
809 | //rxvt_warn ("could not allocate %04x %04x %04x, getting %04x %04x %04x instead (%d)\n", |
811 | //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); |
812 | // color.r, color.g, color.b, best->red, best->green, best->blue, diff); |
811 | |
813 | |
812 | got = alloc (screen, rgba (best->red, best->green, best->blue)); |
814 | got = alloc (screen, rgba (best->red, best->green, best->blue)); |
813 | |
815 | |
814 | delete colors; |
816 | delete [] colors; |
815 | } |
817 | } |
816 | #endif |
818 | #endif |
817 | |
819 | |
818 | return got; |
820 | return got; |
819 | } |
821 | } |