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