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