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