… | |
… | |
550 | XEvent xev; |
550 | XEvent xev; |
551 | XNextEvent (dpy, &xev); |
551 | XNextEvent (dpy, &xev); |
552 | |
552 | |
553 | #ifdef USE_XIM |
553 | #ifdef USE_XIM |
554 | if (!XFilterEvent (&xev, None)) |
554 | if (!XFilterEvent (&xev, None)) |
|
|
555 | #endif |
555 | { |
556 | { |
556 | if (xev.type == PropertyNotify |
557 | if (xev.type == PropertyNotify |
557 | && xev.xany.window == root |
558 | && xev.xany.window == root |
558 | && xev.xproperty.atom == xa[XA_XIM_SERVERS]) |
559 | && xev.xproperty.atom == xa[XA_XIM_SERVERS]) |
559 | im_change_check (); |
560 | im_change_check (); |
560 | #endif |
561 | |
561 | if (xev.type == MappingNotify) |
562 | if (xev.type == MappingNotify) |
562 | XRefreshKeyboardMapping (&xev.xmapping); |
563 | XRefreshKeyboardMapping (&xev.xmapping); |
563 | |
564 | |
564 | for (int i = xw.size (); i--; ) |
565 | for (int i = xw.size (); i--; ) |
565 | { |
566 | { |
566 | if (!xw[i]) |
567 | if (!xw[i]) |
567 | xw.erase_unordered (i); |
568 | xw.erase_unordered (i); |
568 | else if (xw[i]->window == xev.xany.window) |
569 | else if (xw[i]->window == xev.xany.window) |
569 | xw[i]->call (xev); |
570 | xw[i]->call (xev); |
570 | } |
571 | } |
571 | #ifdef USE_XIM |
|
|
572 | } |
572 | } |
573 | #endif |
|
|
574 | } |
573 | } |
|
|
574 | |
|
|
575 | flush_ev.start (); |
575 | } |
576 | } |
576 | |
577 | |
577 | void rxvt_display::flush_cb (ev::prepare &w, int revents) |
578 | void rxvt_display::flush_cb (ev::prepare &w, int revents) |
578 | { |
579 | { |
|
|
580 | x_cb(x_ev,0);//D |
|
|
581 | XFlush (dpy); |
579 | w.stop (); |
582 | w.stop (); |
580 | XFlush (dpy); |
|
|
581 | } |
583 | } |
582 | |
584 | |
583 | void rxvt_display::reg (xevent_watcher *w) |
585 | void rxvt_display::reg (xevent_watcher *w) |
584 | { |
586 | { |
585 | if (!w->active) |
587 | if (!w->active) |
… | |
… | |
673 | } |
675 | } |
674 | |
676 | |
675 | bool |
677 | bool |
676 | rxvt_color::alloc (rxvt_screen *screen, const rgba &color) |
678 | rxvt_color::alloc (rxvt_screen *screen, const rgba &color) |
677 | { |
679 | { |
|
|
680 | //TODO: only supports 24 bit |
|
|
681 | int alpha = color.a >= 0xff00 ? 0xffff : color.a; |
|
|
682 | |
678 | #if XFT |
683 | #if XFT |
679 | XRenderPictFormat *format; |
684 | XRenderPictFormat *format; |
680 | |
685 | |
681 | // FUCKING Xft gets it wrong, of course, so work around it. |
686 | // FUCKING Xft gets it wrong, of course, so work around it. |
682 | // Transparency users should eat shit and die, and then |
687 | // Transparency users should eat shit and die, and then |
… | |
… | |
686 | { |
691 | { |
687 | // the fun lies in doing everything manually... |
692 | // the fun lies in doing everything manually... |
688 | c.color.red = color.r; |
693 | c.color.red = color.r; |
689 | c.color.green = color.g; |
694 | c.color.green = color.g; |
690 | c.color.blue = color.b; |
695 | c.color.blue = color.b; |
691 | c.color.alpha = color.a; |
696 | c.color.alpha = alpha; |
692 | |
697 | |
693 | c.pixel = insert_component (color.r, format->direct.redMask , format->direct.red ) |
698 | c.pixel = insert_component (color.r, format->direct.redMask , format->direct.red ) |
694 | | insert_component (color.g, format->direct.greenMask, format->direct.green) |
699 | | insert_component (color.g, format->direct.greenMask, format->direct.green) |
695 | | insert_component (color.b, format->direct.blueMask , format->direct.blue ) |
700 | | insert_component (color.b, format->direct.blueMask , format->direct.blue ) |
696 | | insert_component (color.a, format->direct.alphaMask, format->direct.alpha); |
701 | | insert_component (alpha , format->direct.alphaMask, format->direct.alpha); |
697 | |
702 | |
698 | return true; |
703 | return true; |
699 | } |
704 | } |
700 | else |
705 | else |
701 | { |
706 | { |
702 | XRenderColor d; |
707 | XRenderColor d; |
703 | |
708 | |
704 | d.red = color.r; |
709 | d.red = color.r; |
705 | d.green = color.g; |
710 | d.green = color.g; |
706 | d.blue = color.b; |
711 | d.blue = color.b; |
707 | d.alpha = color.a; |
712 | d.alpha = alpha; |
708 | |
713 | |
709 | return XftColorAllocValue (screen->dpy, screen->visual, screen->cmap, &d, &c); |
714 | return XftColorAllocValue (screen->dpy, screen->visual, screen->cmap, &d, &c); |
710 | } |
715 | } |
711 | #else |
716 | #else |
712 | c.red = color.r; |
717 | c.red = color.r; |
… | |
… | |
737 | { |
742 | { |
738 | rgba c; |
743 | rgba c; |
739 | char eos; |
744 | char eos; |
740 | int skip; |
745 | int skip; |
741 | |
746 | |
|
|
747 | c.a = rgba::MAX_CC; |
|
|
748 | |
742 | // parse the nonstandard "[alphapercent]" prefix |
749 | // parse the nonstandard "[alphapercent]" prefix |
743 | if (1 <= sscanf (name, "[%hd]%n", &c.a, &skip)) |
750 | if (1 <= sscanf (name, "[%hd]%n", &c.a, &skip)) |
744 | { |
751 | { |
745 | c.a = lerp<int, int, int> (0, rgba::MAX_CC, c.a); |
752 | c.a = lerp<int, int, int> (0, rgba::MAX_CC, c.a); |
746 | name += skip; |
753 | name += skip; |
747 | } |
754 | } |
748 | else |
|
|
749 | c.a = rgba::MAX_CC; |
|
|
750 | |
755 | |
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 |
756 | // 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)) |
757 | 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 | { |
758 | { |
766 | XColor xc; |
759 | XColor xc; |
767 | |
760 | |
768 | if (XParseColor (screen->dpy, screen->cmap, name, &xc)) |
761 | if (XParseColor (screen->dpy, screen->cmap, name, &xc)) |
769 | { |
762 | { |