… | |
… | |
59 | #if ENABLE_EWMH |
59 | #if ENABLE_EWMH |
60 | "_NET_WM_PID", |
60 | "_NET_WM_PID", |
61 | "_NET_WM_NAME", |
61 | "_NET_WM_NAME", |
62 | "_NET_WM_ICON_NAME", |
62 | "_NET_WM_ICON_NAME", |
63 | "_NET_WM_PING", |
63 | "_NET_WM_PING", |
|
|
64 | "_NET_WM_ICON", |
64 | #endif |
65 | #endif |
65 | #if USE_XIM |
66 | #if USE_XIM |
66 | "WM_LOCALE_NAME", |
67 | "WM_LOCALE_NAME", |
67 | "XIM_SERVERS", |
68 | "XIM_SERVERS", |
68 | #endif |
69 | #endif |
… | |
… | |
543 | } |
544 | } |
544 | #endif |
545 | #endif |
545 | |
546 | |
546 | void rxvt_display::x_cb (ev::io &w, int revents) |
547 | void rxvt_display::x_cb (ev::io &w, int revents) |
547 | { |
548 | { |
|
|
549 | flush_ev.start (); |
|
|
550 | } |
|
|
551 | |
|
|
552 | void rxvt_display::flush_cb (ev::prepare &w, int revents) |
|
|
553 | { |
548 | while (XEventsQueued (dpy, QueuedAfterReading)) |
554 | while (XEventsQueued (dpy, QueuedAfterFlush)) |
|
|
555 | do |
549 | { |
556 | { |
550 | XEvent xev; |
557 | XEvent xev; |
551 | XNextEvent (dpy, &xev); |
558 | XNextEvent (dpy, &xev); |
552 | |
559 | |
553 | #ifdef USE_XIM |
560 | #ifdef USE_XIM |
554 | if (!XFilterEvent (&xev, None)) |
561 | if (!XFilterEvent (&xev, None)) |
555 | { |
562 | { |
556 | if (xev.type == PropertyNotify |
563 | if (xev.type == PropertyNotify |
557 | && xev.xany.window == root |
564 | && xev.xany.window == root |
558 | && xev.xproperty.atom == xa[XA_XIM_SERVERS]) |
565 | && xev.xproperty.atom == xa[XA_XIM_SERVERS]) |
559 | im_change_check (); |
566 | im_change_check (); |
560 | #endif |
567 | #endif |
561 | if (xev.type == MappingNotify) |
568 | if (xev.type == MappingNotify) |
562 | XRefreshKeyboardMapping (&xev.xmapping); |
569 | XRefreshKeyboardMapping (&xev.xmapping); |
563 | |
570 | |
564 | for (int i = xw.size (); i--; ) |
571 | for (int i = xw.size (); i--; ) |
565 | { |
572 | { |
566 | if (!xw[i]) |
573 | if (!xw[i]) |
567 | xw.erase_unordered (i); |
574 | xw.erase_unordered (i); |
568 | else if (xw[i]->window == xev.xany.window) |
575 | else if (xw[i]->window == xev.xany.window) |
569 | xw[i]->call (xev); |
576 | xw[i]->call (xev); |
570 | } |
577 | } |
571 | #ifdef USE_XIM |
578 | #ifdef USE_XIM |
572 | } |
579 | } |
573 | #endif |
580 | #endif |
574 | } |
581 | } |
575 | } |
582 | while (XEventsQueued (dpy, QueuedAlready)); |
576 | |
583 | |
577 | void rxvt_display::flush_cb (ev::prepare &w, int revents) |
|
|
578 | { |
|
|
579 | w.stop (); |
584 | w.stop (); |
580 | XFlush (dpy); |
|
|
581 | } |
585 | } |
582 | |
586 | |
583 | void rxvt_display::reg (xevent_watcher *w) |
587 | void rxvt_display::reg (xevent_watcher *w) |
584 | { |
588 | { |
585 | if (!w->active) |
589 | if (!w->active) |
… | |
… | |
673 | } |
677 | } |
674 | |
678 | |
675 | bool |
679 | bool |
676 | rxvt_color::alloc (rxvt_screen *screen, const rgba &color) |
680 | rxvt_color::alloc (rxvt_screen *screen, const rgba &color) |
677 | { |
681 | { |
|
|
682 | //TODO: only supports 24 bit |
|
|
683 | int alpha = color.a >= 0xff00 ? 0xffff : color.a; |
|
|
684 | |
678 | #if XFT |
685 | #if XFT |
679 | XRenderPictFormat *format; |
686 | XRenderPictFormat *format; |
680 | |
687 | |
681 | // FUCKING Xft gets it wrong, of course, so work around it. |
688 | // FUCKING Xft gets it wrong, of course, so work around it. |
682 | // Transparency users should eat shit and die, and then |
689 | // Transparency users should eat shit and die, and then |
… | |
… | |
686 | { |
693 | { |
687 | // the fun lies in doing everything manually... |
694 | // the fun lies in doing everything manually... |
688 | c.color.red = color.r; |
695 | c.color.red = color.r; |
689 | c.color.green = color.g; |
696 | c.color.green = color.g; |
690 | c.color.blue = color.b; |
697 | c.color.blue = color.b; |
691 | c.color.alpha = color.a; |
698 | c.color.alpha = alpha; |
692 | |
699 | |
693 | c.pixel = insert_component (color.r, format->direct.redMask , format->direct.red ) |
700 | c.pixel = insert_component (color.r, format->direct.redMask , format->direct.red ) |
694 | | insert_component (color.g, format->direct.greenMask, format->direct.green) |
701 | | insert_component (color.g, format->direct.greenMask, format->direct.green) |
695 | | insert_component (color.b, format->direct.blueMask , format->direct.blue ) |
702 | | insert_component (color.b, format->direct.blueMask , format->direct.blue ) |
696 | | insert_component (color.a, format->direct.alphaMask, format->direct.alpha); |
703 | | insert_component (alpha , format->direct.alphaMask, format->direct.alpha); |
697 | |
704 | |
698 | return true; |
705 | return true; |
699 | } |
706 | } |
700 | else |
707 | else |
701 | { |
708 | { |
702 | XRenderColor d; |
709 | XRenderColor d; |
703 | |
710 | |
704 | d.red = color.r; |
711 | d.red = color.r; |
705 | d.green = color.g; |
712 | d.green = color.g; |
706 | d.blue = color.b; |
713 | d.blue = color.b; |
707 | d.alpha = color.a; |
714 | d.alpha = alpha; |
708 | |
715 | |
709 | return XftColorAllocValue (screen->dpy, screen->visual, screen->cmap, &d, &c); |
716 | return XftColorAllocValue (screen->dpy, screen->visual, screen->cmap, &d, &c); |
710 | } |
717 | } |
711 | #else |
718 | #else |
712 | c.red = color.r; |
719 | c.red = color.r; |
713 | c.green = color.g; |
720 | c.green = color.g; |
714 | c.blue = color.b; |
721 | c.blue = color.b; |
715 | |
722 | |
716 | if (screen->visual->c_class == TrueColor) |
723 | if (screen->visual->c_class == TrueColor) |
717 | { |
724 | { |
718 | c.pixel = (color.r >> (16 - popcount (screen->visual->red_mask )) << ctz (screen->visual->red_mask )) |
725 | c.pixel = (color.r >> (16 - rxvt_popcount (screen->visual->red_mask )) << rxvt_ctz (screen->visual->red_mask )) |
719 | | (color.g >> (16 - popcount (screen->visual->green_mask)) << ctz (screen->visual->green_mask)) |
726 | | (color.g >> (16 - rxvt_popcount (screen->visual->green_mask)) << rxvt_ctz (screen->visual->green_mask)) |
720 | | (color.b >> (16 - popcount (screen->visual->blue_mask )) << ctz (screen->visual->blue_mask )); |
727 | | (color.b >> (16 - rxvt_popcount (screen->visual->blue_mask )) << rxvt_ctz (screen->visual->blue_mask )); |
721 | |
728 | |
722 | return true; |
729 | return true; |
723 | } |
730 | } |
724 | else if (XAllocColor (screen->dpy, screen->cmap, &c)) |
731 | else if (XAllocColor (screen->dpy, screen->cmap, &c)) |
725 | return true; |
732 | return true; |
… | |
… | |
737 | { |
744 | { |
738 | rgba c; |
745 | rgba c; |
739 | char eos; |
746 | char eos; |
740 | int skip; |
747 | int skip; |
741 | |
748 | |
|
|
749 | c.a = rgba::MAX_CC; |
|
|
750 | |
742 | // parse the nonstandard "[alphapercent]" prefix |
751 | // parse the nonstandard "[alphapercent]" prefix |
743 | if (1 <= sscanf (name, "[%hd]%n", &c.a, &skip)) |
752 | if (1 <= sscanf (name, "[%hd]%n", &c.a, &skip)) |
744 | { |
753 | { |
745 | c.a = lerp<int, int, int> (0, rgba::MAX_CC, c.a); |
754 | c.a = lerp<int, int, int> (0, rgba::MAX_CC, c.a); |
746 | name += skip; |
755 | name += skip; |
747 | } |
756 | } |
748 | else |
|
|
749 | c.a = rgba::MAX_CC; |
|
|
750 | |
757 | |
751 | // parse the non-standard "#aarrggbb" format |
|
|
752 | 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)) |
|
|
753 | { |
|
|
754 | if (c.r) |
|
|
755 | c.r = (c.r << 8) | 0x0ff; |
|
|
756 | if (c.g) |
|
|
757 | c.g = (c.g << 8) | 0x0ff; |
|
|
758 | if (c.b) |
|
|
759 | c.b = (c.b << 8) | 0x0ff; |
|
|
760 | if (c.a) |
|
|
761 | c.a = (c.a << 8) | 0x0ff; |
|
|
762 | } |
|
|
763 | // parse the non-standard "rgba:rrrr/gggg/bbbb/aaaa" format |
758 | // parse the non-standard "rgba:rrrr/gggg/bbbb/aaaa" format |
764 | 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)) |
759 | if (strlen (name) != 4+5*4 || 4 != sscanf (name, "rgba:%4hx/%4hx/%4hx/%4hx%c", &c.r, &c.g, &c.b, &c.a, &eos)) |
765 | { |
760 | { |
766 | XColor xc; |
761 | XColor xc; |
767 | |
762 | |
768 | if (XParseColor (screen->dpy, screen->cmap, name, &xc)) |
763 | if (XParseColor (screen->dpy, screen->cmap, name, &xc)) |
769 | { |
764 | { |