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