… | |
… | |
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 | |
576 | void rxvt_display::flush () |
577 | void rxvt_display::flush_cb (ev::prepare &w, int revents) |
577 | { |
578 | { |
|
|
579 | w.stop (); |
578 | XFlush (dpy); |
580 | XFlush (dpy); |
579 | } |
|
|
580 | |
|
|
581 | void rxvt_display::flush_cb (ev::prepare &w, int revents) |
|
|
582 | { |
|
|
583 | flush (); |
|
|
584 | } |
581 | } |
585 | |
582 | |
586 | void rxvt_display::reg (xevent_watcher *w) |
583 | void rxvt_display::reg (xevent_watcher *w) |
587 | { |
584 | { |
588 | if (!w->active) |
585 | if (!w->active) |
… | |
… | |
602 | } |
599 | } |
603 | |
600 | |
604 | void rxvt_display::set_selection_owner (rxvt_term *owner) |
601 | void rxvt_display::set_selection_owner (rxvt_term *owner) |
605 | { |
602 | { |
606 | if (selection_owner && selection_owner != owner) |
603 | if (selection_owner && selection_owner != owner) |
|
|
604 | { |
|
|
605 | rxvt_term *owner = selection_owner; |
|
|
606 | |
607 | selection_owner->selection_clear (); |
607 | owner->selection_clear (); |
|
|
608 | owner->flush (); |
|
|
609 | } |
608 | |
610 | |
609 | selection_owner = owner; |
611 | selection_owner = owner; |
610 | } |
612 | } |
611 | |
613 | |
612 | #ifdef USE_XIM |
614 | #ifdef USE_XIM |
… | |
… | |
671 | } |
673 | } |
672 | |
674 | |
673 | bool |
675 | bool |
674 | rxvt_color::alloc (rxvt_screen *screen, const rgba &color) |
676 | rxvt_color::alloc (rxvt_screen *screen, const rgba &color) |
675 | { |
677 | { |
|
|
678 | //TODO: only supports 24 bit |
|
|
679 | int alpha = color.a >= 0xff00 ? 0xffff : color.a; |
|
|
680 | |
676 | #if XFT |
681 | #if XFT |
677 | XRenderPictFormat *format; |
682 | XRenderPictFormat *format; |
678 | |
683 | |
679 | // FUCKING Xft gets it wrong, of course, so work around it. |
684 | // FUCKING Xft gets it wrong, of course, so work around it. |
680 | // Transparency users should eat shit and die, and then |
685 | // Transparency users should eat shit and die, and then |
… | |
… | |
684 | { |
689 | { |
685 | // the fun lies in doing everything manually... |
690 | // the fun lies in doing everything manually... |
686 | c.color.red = color.r; |
691 | c.color.red = color.r; |
687 | c.color.green = color.g; |
692 | c.color.green = color.g; |
688 | c.color.blue = color.b; |
693 | c.color.blue = color.b; |
689 | c.color.alpha = color.a; |
694 | c.color.alpha = alpha; |
690 | |
695 | |
691 | c.pixel = insert_component (color.r, format->direct.redMask , format->direct.red ) |
696 | c.pixel = insert_component (color.r, format->direct.redMask , format->direct.red ) |
692 | | insert_component (color.g, format->direct.greenMask, format->direct.green) |
697 | | insert_component (color.g, format->direct.greenMask, format->direct.green) |
693 | | insert_component (color.b, format->direct.blueMask , format->direct.blue ) |
698 | | insert_component (color.b, format->direct.blueMask , format->direct.blue ) |
694 | | insert_component (color.a, format->direct.alphaMask, format->direct.alpha); |
699 | | insert_component (alpha , format->direct.alphaMask, format->direct.alpha); |
695 | |
700 | |
696 | return true; |
701 | return true; |
697 | } |
702 | } |
698 | else |
703 | else |
699 | { |
704 | { |
700 | XRenderColor d; |
705 | XRenderColor d; |
701 | |
706 | |
702 | d.red = color.r; |
707 | d.red = color.r; |
703 | d.green = color.g; |
708 | d.green = color.g; |
704 | d.blue = color.b; |
709 | d.blue = color.b; |
705 | d.alpha = color.a; |
710 | d.alpha = alpha; |
706 | |
711 | |
707 | return XftColorAllocValue (screen->dpy, screen->visual, screen->cmap, &d, &c); |
712 | return XftColorAllocValue (screen->dpy, screen->visual, screen->cmap, &d, &c); |
708 | } |
713 | } |
709 | #else |
714 | #else |
710 | c.red = color.r; |
715 | c.red = color.r; |
… | |
… | |
735 | { |
740 | { |
736 | rgba c; |
741 | rgba c; |
737 | char eos; |
742 | char eos; |
738 | int skip; |
743 | int skip; |
739 | |
744 | |
|
|
745 | c.a = rgba::MAX_CC; |
|
|
746 | |
740 | // parse the nonstandard "[alphapercent]" prefix |
747 | // parse the nonstandard "[alphapercent]" prefix |
741 | if (1 <= sscanf (name, "[%hd]%n", &c.a, &skip)) |
748 | if (1 <= sscanf (name, "[%hd]%n", &c.a, &skip)) |
742 | { |
749 | { |
743 | c.a = lerp<int, int, int> (0, rgba::MAX_CC, c.a); |
750 | c.a = lerp<int, int, int> (0, rgba::MAX_CC, c.a); |
744 | name += skip; |
751 | name += skip; |
745 | } |
752 | } |
746 | else |
|
|
747 | c.a = rgba::MAX_CC; |
|
|
748 | |
753 | |
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 |
754 | // 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)) |
755 | 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 | { |
756 | { |
764 | XColor xc; |
757 | XColor xc; |
765 | |
758 | |
766 | if (XParseColor (screen->dpy, screen->cmap, name, &xc)) |
759 | if (XParseColor (screen->dpy, screen->cmap, name, &xc)) |
767 | { |
760 | { |