… | |
… | |
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", |
… | |
… | |
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); |
… | |
… | |
553 | if (xev.type == PropertyNotify |
559 | if (xev.type == PropertyNotify |
554 | && xev.xany.window == root |
560 | && xev.xany.window == root |
555 | && xev.xproperty.atom == xa[XA_XIM_SERVERS]) |
561 | && xev.xproperty.atom == xa[XA_XIM_SERVERS]) |
556 | im_change_check (); |
562 | im_change_check (); |
557 | #endif |
563 | #endif |
|
|
564 | if (xev.type == MappingNotify) |
|
|
565 | XRefreshKeyboardMapping (&xev.xmapping); |
|
|
566 | |
558 | for (int i = xw.size (); i--; ) |
567 | for (int i = xw.size (); i--; ) |
559 | { |
568 | { |
560 | if (!xw[i]) |
569 | if (!xw[i]) |
561 | xw.erase_unordered (i); |
570 | xw.erase_unordered (i); |
562 | else if (xw[i]->window == xev.xany.window) |
571 | else if (xw[i]->window == xev.xany.window) |
… | |
… | |
707 | c.green = color.g; |
716 | c.green = color.g; |
708 | c.blue = color.b; |
717 | c.blue = color.b; |
709 | |
718 | |
710 | if (screen->visual->c_class == TrueColor) |
719 | if (screen->visual->c_class == TrueColor) |
711 | { |
720 | { |
712 | c.pixel = (color.r * (screen->visual->red_mask >> ctz (screen->visual->red_mask )) |
721 | c.pixel = (color.r >> (16 - popcount (screen->visual->red_mask )) << ctz (screen->visual->red_mask )) |
713 | / rgba::MAX_CC) << ctz (screen->visual->red_mask ) |
722 | | (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 )) |
723 | | (color.b >> (16 - popcount (screen->visual->blue_mask )) << ctz (screen->visual->blue_mask )); |
717 | / rgba::MAX_CC) << ctz (screen->visual->blue_mask ); |
|
|
718 | |
724 | |
719 | return true; |
725 | return true; |
720 | } |
726 | } |
721 | else if (XAllocColor (screen->dpy, screen->cmap, &c)) |
727 | else if (XAllocColor (screen->dpy, screen->cmap, &c)) |
722 | return true; |
728 | return true; |
… | |
… | |
809 | //rxvt_warn ("could not allocate %04x %04x %04x, getting %04x %04x %04x instead (%d)\n", |
815 | //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); |
816 | // color.r, color.g, color.b, best->red, best->green, best->blue, diff); |
811 | |
817 | |
812 | got = alloc (screen, rgba (best->red, best->green, best->blue)); |
818 | got = alloc (screen, rgba (best->red, best->green, best->blue)); |
813 | |
819 | |
814 | delete colors; |
820 | delete [] colors; |
815 | } |
821 | } |
816 | #endif |
822 | #endif |
817 | |
823 | |
818 | return got; |
824 | return got; |
819 | } |
825 | } |