… | |
… | |
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", |
… | |
… | |
469 | is_local = 0; |
469 | is_local = 0; |
470 | sockaddr_un sa; |
470 | sockaddr_un sa; |
471 | socklen_t sl = sizeof (sa); |
471 | socklen_t sl = sizeof (sa); |
472 | |
472 | |
473 | if (!getsockname (fd, (sockaddr *)&sa, &sl)) |
473 | if (!getsockname (fd, (sockaddr *)&sa, &sl)) |
474 | is_local = sa.sun_family == AF_LOCAL; |
474 | is_local = sa.sun_family == AF_UNIX; |
475 | |
475 | |
476 | x_ev.start (fd, EVENT_READ); |
476 | x_ev.start (fd, EVENT_READ); |
477 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
477 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
478 | |
478 | |
479 | XSelectInput (dpy, root, PropertyChangeMask); |
479 | XSelectInput (dpy, root, PropertyChangeMask); |
… | |
… | |
553 | if (xev.type == PropertyNotify |
553 | if (xev.type == PropertyNotify |
554 | && xev.xany.window == root |
554 | && xev.xany.window == root |
555 | && xev.xproperty.atom == xa[XA_XIM_SERVERS]) |
555 | && xev.xproperty.atom == xa[XA_XIM_SERVERS]) |
556 | im_change_check (); |
556 | im_change_check (); |
557 | #endif |
557 | #endif |
|
|
558 | if (xev.type == MappingNotify) |
|
|
559 | XRefreshKeyboardMapping (&xev.xmapping); |
|
|
560 | |
558 | for (int i = xw.size (); i--; ) |
561 | for (int i = xw.size (); i--; ) |
559 | { |
562 | { |
560 | if (!xw[i]) |
563 | if (!xw[i]) |
561 | xw.erase_unordered (i); |
564 | xw.erase_unordered (i); |
562 | else if (xw[i]->window == xev.xany.window) |
565 | else if (xw[i]->window == xev.xany.window) |
… | |
… | |
579 | XFlush (dpy); |
582 | XFlush (dpy); |
580 | } |
583 | } |
581 | |
584 | |
582 | void rxvt_display::reg (xevent_watcher *w) |
585 | void rxvt_display::reg (xevent_watcher *w) |
583 | { |
586 | { |
|
|
587 | if (!w->active) |
|
|
588 | { |
584 | xw.push_back (w); |
589 | xw.push_back (w); |
585 | w->active = xw.size (); |
590 | w->active = xw.size (); |
|
|
591 | } |
586 | } |
592 | } |
587 | |
593 | |
588 | void rxvt_display::unreg (xevent_watcher *w) |
594 | void rxvt_display::unreg (xevent_watcher *w) |
589 | { |
595 | { |
590 | if (w->active) |
596 | if (w->active) |
|
|
597 | { |
591 | xw[w->active - 1] = 0; |
598 | xw[w->active - 1] = 0; |
|
|
599 | w->active = 0; |
|
|
600 | } |
592 | } |
601 | } |
593 | |
602 | |
594 | void rxvt_display::set_selection_owner (rxvt_term *owner) |
603 | void rxvt_display::set_selection_owner (rxvt_term *owner) |
595 | { |
604 | { |
596 | if (selection_owner && selection_owner != owner) |
605 | if (selection_owner && selection_owner != owner) |
… | |
… | |
701 | c.green = color.g; |
710 | c.green = color.g; |
702 | c.blue = color.b; |
711 | c.blue = color.b; |
703 | |
712 | |
704 | if (screen->visual->c_class == TrueColor) |
713 | if (screen->visual->c_class == TrueColor) |
705 | { |
714 | { |
706 | c.pixel = (color.r * (screen->visual->red_mask >> ctz (screen->visual->red_mask )) |
715 | c.pixel = (color.r >> (16 - popcount (screen->visual->red_mask )) << ctz (screen->visual->red_mask )) |
707 | / rgba::MAX_CC) << ctz (screen->visual->red_mask ) |
716 | | (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 )) |
717 | | (color.b >> (16 - popcount (screen->visual->blue_mask )) << ctz (screen->visual->blue_mask )); |
711 | / rgba::MAX_CC) << ctz (screen->visual->blue_mask ); |
|
|
712 | |
718 | |
713 | return true; |
719 | return true; |
714 | } |
720 | } |
715 | else if (XAllocColor (screen->dpy, screen->cmap, &c)) |
721 | else if (XAllocColor (screen->dpy, screen->cmap, &c)) |
716 | return true; |
722 | return true; |
… | |
… | |
737 | name += skip; |
743 | name += skip; |
738 | } |
744 | } |
739 | else |
745 | else |
740 | c.a = rgba::MAX_CC; |
746 | c.a = rgba::MAX_CC; |
741 | |
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 | } |
742 | // parse the non-standard "rgba:rrrr/gggg/bbbb/aaaa" format |
760 | // parse the non-standard "rgba:rrrr/gggg/bbbb/aaaa" format |
743 | 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)) |
744 | { |
762 | { |
745 | XColor xc, xc_exact; |
763 | XColor xc, xc_exact; |
746 | |
764 | |
747 | if (XParseColor (screen->dpy, screen->cmap, name, &xc)) |
765 | if (XParseColor (screen->dpy, screen->cmap, name, &xc)) |
748 | { |
766 | { |
… | |
… | |
803 | //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", |
804 | // 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); |
805 | |
823 | |
806 | got = alloc (screen, rgba (best->red, best->green, best->blue)); |
824 | got = alloc (screen, rgba (best->red, best->green, best->blue)); |
807 | |
825 | |
808 | delete colors; |
826 | delete [] colors; |
809 | } |
827 | } |
810 | #endif |
828 | #endif |
811 | |
829 | |
812 | return got; |
830 | return got; |
813 | } |
831 | } |