… | |
… | |
501 | |
501 | |
502 | #ifdef POINTER_BLANK |
502 | #ifdef POINTER_BLANK |
503 | XFreeCursor (dpy, blank_cursor); |
503 | XFreeCursor (dpy, blank_cursor); |
504 | #endif |
504 | #endif |
505 | x_ev.stop (); |
505 | x_ev.stop (); |
|
|
506 | flush_ev.stop (); |
506 | #ifdef USE_XIM |
507 | #ifdef USE_XIM |
507 | xims.clear (); |
508 | xims.clear (); |
508 | #endif |
509 | #endif |
509 | XCloseDisplay (dpy); |
510 | XCloseDisplay (dpy); |
510 | } |
511 | } |
… | |
… | |
555 | if (xev.type == PropertyNotify |
556 | if (xev.type == PropertyNotify |
556 | && xev.xany.window == root |
557 | && xev.xany.window == root |
557 | && xev.xproperty.atom == xa[XA_XIM_SERVERS]) |
558 | && xev.xproperty.atom == xa[XA_XIM_SERVERS]) |
558 | im_change_check (); |
559 | im_change_check (); |
559 | #endif |
560 | #endif |
|
|
561 | |
560 | if (xev.type == MappingNotify) |
562 | if (xev.type == MappingNotify) |
561 | XRefreshKeyboardMapping (&xev.xmapping); |
563 | XRefreshKeyboardMapping (&xev.xmapping); |
562 | |
564 | |
563 | for (int i = xw.size (); i--; ) |
565 | for (int i = xw.size (); i--; ) |
564 | { |
566 | { |
… | |
… | |
571 | } |
573 | } |
572 | #endif |
574 | #endif |
573 | } |
575 | } |
574 | } |
576 | } |
575 | |
577 | |
576 | void rxvt_display::flush () |
|
|
577 | { |
|
|
578 | flush_ev.start (); |
|
|
579 | } |
|
|
580 | |
|
|
581 | void rxvt_display::flush_cb (ev::prepare &w, int revents) |
578 | void rxvt_display::flush_cb (ev::prepare &w, int revents) |
582 | { |
579 | { |
|
|
580 | while (XEventsQueued (dpy, QueuedAfterFlush)) |
|
|
581 | x_cb (x_ev, EV_READ); |
|
|
582 | |
583 | w.stop (); |
583 | w.stop (); |
584 | XFlush (dpy); |
|
|
585 | } |
584 | } |
586 | |
585 | |
587 | void rxvt_display::reg (xevent_watcher *w) |
586 | void rxvt_display::reg (xevent_watcher *w) |
588 | { |
587 | { |
589 | if (!w->active) |
588 | if (!w->active) |
… | |
… | |
603 | } |
602 | } |
604 | |
603 | |
605 | void rxvt_display::set_selection_owner (rxvt_term *owner) |
604 | void rxvt_display::set_selection_owner (rxvt_term *owner) |
606 | { |
605 | { |
607 | if (selection_owner && selection_owner != owner) |
606 | if (selection_owner && selection_owner != owner) |
|
|
607 | { |
|
|
608 | rxvt_term *owner = selection_owner; |
|
|
609 | |
608 | selection_owner->selection_clear (); |
610 | owner->selection_clear (); |
|
|
611 | owner->flush (); |
|
|
612 | } |
609 | |
613 | |
610 | selection_owner = owner; |
614 | selection_owner = owner; |
611 | } |
615 | } |
612 | |
616 | |
613 | #ifdef USE_XIM |
617 | #ifdef USE_XIM |
… | |
… | |
672 | } |
676 | } |
673 | |
677 | |
674 | bool |
678 | bool |
675 | rxvt_color::alloc (rxvt_screen *screen, const rgba &color) |
679 | rxvt_color::alloc (rxvt_screen *screen, const rgba &color) |
676 | { |
680 | { |
|
|
681 | //TODO: only supports 24 bit |
|
|
682 | int alpha = color.a >= 0xff00 ? 0xffff : color.a; |
|
|
683 | |
677 | #if XFT |
684 | #if XFT |
678 | XRenderPictFormat *format; |
685 | XRenderPictFormat *format; |
679 | |
686 | |
680 | // FUCKING Xft gets it wrong, of course, so work around it. |
687 | // FUCKING Xft gets it wrong, of course, so work around it. |
681 | // Transparency users should eat shit and die, and then |
688 | // Transparency users should eat shit and die, and then |
… | |
… | |
685 | { |
692 | { |
686 | // the fun lies in doing everything manually... |
693 | // the fun lies in doing everything manually... |
687 | c.color.red = color.r; |
694 | c.color.red = color.r; |
688 | c.color.green = color.g; |
695 | c.color.green = color.g; |
689 | c.color.blue = color.b; |
696 | c.color.blue = color.b; |
690 | c.color.alpha = color.a; |
697 | c.color.alpha = alpha; |
691 | |
698 | |
692 | c.pixel = insert_component (color.r, format->direct.redMask , format->direct.red ) |
699 | c.pixel = insert_component (color.r, format->direct.redMask , format->direct.red ) |
693 | | insert_component (color.g, format->direct.greenMask, format->direct.green) |
700 | | insert_component (color.g, format->direct.greenMask, format->direct.green) |
694 | | insert_component (color.b, format->direct.blueMask , format->direct.blue ) |
701 | | insert_component (color.b, format->direct.blueMask , format->direct.blue ) |
695 | | insert_component (color.a, format->direct.alphaMask, format->direct.alpha); |
702 | | insert_component (alpha , format->direct.alphaMask, format->direct.alpha); |
696 | |
703 | |
697 | return true; |
704 | return true; |
698 | } |
705 | } |
699 | else |
706 | else |
700 | { |
707 | { |
701 | XRenderColor d; |
708 | XRenderColor d; |
702 | |
709 | |
703 | d.red = color.r; |
710 | d.red = color.r; |
704 | d.green = color.g; |
711 | d.green = color.g; |
705 | d.blue = color.b; |
712 | d.blue = color.b; |
706 | d.alpha = color.a; |
713 | d.alpha = alpha; |
707 | |
714 | |
708 | return XftColorAllocValue (screen->dpy, screen->visual, screen->cmap, &d, &c); |
715 | return XftColorAllocValue (screen->dpy, screen->visual, screen->cmap, &d, &c); |
709 | } |
716 | } |
710 | #else |
717 | #else |
711 | c.red = color.r; |
718 | c.red = color.r; |
… | |
… | |
736 | { |
743 | { |
737 | rgba c; |
744 | rgba c; |
738 | char eos; |
745 | char eos; |
739 | int skip; |
746 | int skip; |
740 | |
747 | |
|
|
748 | c.a = rgba::MAX_CC; |
|
|
749 | |
741 | // parse the nonstandard "[alphapercent]" prefix |
750 | // parse the nonstandard "[alphapercent]" prefix |
742 | if (1 <= sscanf (name, "[%hd]%n", &c.a, &skip)) |
751 | if (1 <= sscanf (name, "[%hd]%n", &c.a, &skip)) |
743 | { |
752 | { |
744 | c.a = lerp<int, int, int> (0, rgba::MAX_CC, c.a); |
753 | c.a = lerp<int, int, int> (0, rgba::MAX_CC, c.a); |
745 | name += skip; |
754 | name += skip; |
746 | } |
755 | } |
747 | else |
|
|
748 | c.a = rgba::MAX_CC; |
|
|
749 | |
756 | |
750 | // parse the non-standard "#aarrggbb" format |
|
|
751 | 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)) |
|
|
752 | { |
|
|
753 | if (c.r) |
|
|
754 | c.r = (c.r << 8) | 0x0ff; |
|
|
755 | if (c.g) |
|
|
756 | c.g = (c.g << 8) | 0x0ff; |
|
|
757 | if (c.b) |
|
|
758 | c.b = (c.b << 8) | 0x0ff; |
|
|
759 | if (c.a) |
|
|
760 | c.a = (c.a << 8) | 0x0ff; |
|
|
761 | } |
|
|
762 | // parse the non-standard "rgba:rrrr/gggg/bbbb/aaaa" format |
757 | // parse the non-standard "rgba:rrrr/gggg/bbbb/aaaa" format |
763 | 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)) |
758 | if (strlen (name) != 4+5*4 || 4 != sscanf (name, "rgba:%4hx/%4hx/%4hx/%4hx%c", &c.r, &c.g, &c.b, &c.a, &eos)) |
764 | { |
759 | { |
765 | XColor xc; |
760 | XColor xc; |
766 | |
761 | |
767 | if (XParseColor (screen->dpy, screen->cmap, name, &xc)) |
762 | if (XParseColor (screen->dpy, screen->cmap, name, &xc)) |
768 | { |
763 | { |