… | |
… | |
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), |
|
|
451 | XVisualIDFromVisual (DefaultVisual (dpy, screen)), None, NULL); |
|
|
452 | #endif |
|
|
453 | |
448 | assert (sizeof (xa_names) / sizeof (char *) == NUM_XA); |
454 | assert (sizeof (xa_names) / sizeof (char *) == NUM_XA); |
449 | XInternAtoms (dpy, (char **)xa_names, NUM_XA, False, xa); |
455 | XInternAtoms (dpy, (char **)xa_names, NUM_XA, False, xa); |
450 | |
456 | |
451 | XrmSetDatabase (dpy, get_resources (false)); |
457 | XrmSetDatabase (dpy, get_resources (false)); |
452 | |
458 | |
… | |
… | |
469 | is_local = 0; |
475 | is_local = 0; |
470 | sockaddr_un sa; |
476 | sockaddr_un sa; |
471 | socklen_t sl = sizeof (sa); |
477 | socklen_t sl = sizeof (sa); |
472 | |
478 | |
473 | if (!getsockname (fd, (sockaddr *)&sa, &sl)) |
479 | if (!getsockname (fd, (sockaddr *)&sa, &sl)) |
474 | is_local = sa.sun_family == AF_LOCAL; |
480 | is_local = sa.sun_family == AF_UNIX; |
475 | |
481 | |
476 | x_ev.start (fd, EVENT_READ); |
482 | x_ev.start (fd, EVENT_READ); |
477 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
483 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
478 | |
484 | |
479 | XSelectInput (dpy, root, PropertyChangeMask); |
485 | XSelectInput (dpy, root, PropertyChangeMask); |
… | |
… | |
579 | XFlush (dpy); |
585 | XFlush (dpy); |
580 | } |
586 | } |
581 | |
587 | |
582 | void rxvt_display::reg (xevent_watcher *w) |
588 | void rxvt_display::reg (xevent_watcher *w) |
583 | { |
589 | { |
|
|
590 | if (!w->active) |
|
|
591 | { |
584 | xw.push_back (w); |
592 | xw.push_back (w); |
585 | w->active = xw.size (); |
593 | w->active = xw.size (); |
|
|
594 | } |
586 | } |
595 | } |
587 | |
596 | |
588 | void rxvt_display::unreg (xevent_watcher *w) |
597 | void rxvt_display::unreg (xevent_watcher *w) |
589 | { |
598 | { |
590 | if (w->active) |
599 | if (w->active) |
|
|
600 | { |
591 | xw[w->active - 1] = 0; |
601 | xw[w->active - 1] = 0; |
|
|
602 | w->active = 0; |
|
|
603 | } |
592 | } |
604 | } |
593 | |
605 | |
594 | void rxvt_display::set_selection_owner (rxvt_term *owner) |
606 | void rxvt_display::set_selection_owner (rxvt_term *owner) |
595 | { |
607 | { |
596 | if (selection_owner && selection_owner != owner) |
608 | if (selection_owner && selection_owner != owner) |
… | |
… | |
701 | c.green = color.g; |
713 | c.green = color.g; |
702 | c.blue = color.b; |
714 | c.blue = color.b; |
703 | |
715 | |
704 | if (screen->visual->c_class == TrueColor) |
716 | if (screen->visual->c_class == TrueColor) |
705 | { |
717 | { |
706 | c.pixel = (color.r * (screen->visual->red_mask >> ctz (screen->visual->red_mask )) |
718 | c.pixel = (color.r >> (16 - popcount (screen->visual->red_mask )) << ctz (screen->visual->red_mask )) |
707 | / rgba::MAX_CC) << ctz (screen->visual->red_mask ) |
719 | | (color.g >> (16 - popcount (screen->visual->green_mask)) << ctz (screen->visual->green_mask)) |
708 | | (color.g * (screen->visual->green_mask >> ctz (screen->visual->green_mask)) |
|
|
709 | / rgba::MAX_CC) << ctz (screen->visual->green_mask) |
|
|
710 | | (color.b * (screen->visual->blue_mask >> ctz (screen->visual->blue_mask )) |
720 | | (color.b >> (16 - popcount (screen->visual->blue_mask )) << ctz (screen->visual->blue_mask )); |
711 | / rgba::MAX_CC) << ctz (screen->visual->blue_mask ); |
|
|
712 | |
721 | |
713 | return true; |
722 | return true; |
714 | } |
723 | } |
715 | else if (XAllocColor (screen->dpy, screen->cmap, &c)) |
724 | else if (XAllocColor (screen->dpy, screen->cmap, &c)) |
716 | return true; |
725 | return true; |
… | |
… | |
803 | //rxvt_warn ("could not allocate %04x %04x %04x, getting %04x %04x %04x instead (%d)\n", |
812 | //rxvt_warn ("could not allocate %04x %04x %04x, getting %04x %04x %04x instead (%d)\n", |
804 | // color.r, color.g, color.b, best->red, best->green, best->blue, diff); |
813 | // color.r, color.g, color.b, best->red, best->green, best->blue, diff); |
805 | |
814 | |
806 | got = alloc (screen, rgba (best->red, best->green, best->blue)); |
815 | got = alloc (screen, rgba (best->red, best->green, best->blue)); |
807 | |
816 | |
808 | delete colors; |
817 | delete [] colors; |
809 | } |
818 | } |
810 | #endif |
819 | #endif |
811 | |
820 | |
812 | return got; |
821 | return got; |
813 | } |
822 | } |