ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvttoolkit.C
(Generate patch)

Comparing rxvt-unicode/src/rxvttoolkit.C (file contents):
Revision 1.80 by ayin, Fri Dec 7 01:29:00 2007 UTC vs.
Revision 1.95 by root, Sat Jan 26 12:03:36 2008 UTC

1/*----------------------------------------------------------------------* 1/*----------------------------------------------------------------------*
2 * File: rxvttoolkit.C 2 * File: rxvttoolkit.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * 4 *
5 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> 6 * Copyright (c) 2003-2007 Marc Lehmann <pcg@goof.com>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
297 297
298rxvt_display::rxvt_display (const char *id) 298rxvt_display::rxvt_display (const char *id)
299: refcounted (id) 299: refcounted (id)
300, selection_owner (0) 300, selection_owner (0)
301{ 301{
302 x_ev.set<rxvt_display, &rxvt_display::x_cb> (this); 302 x_ev .set<rxvt_display, &rxvt_display::x_cb > (this);
303 flush_ev.set<rxvt_display, &rxvt_display::flush_cb> (this);
303} 304}
304 305
305XrmDatabase 306XrmDatabase
306rxvt_display::get_resources (bool refresh) 307rxvt_display::get_resources (bool refresh)
307{ 308{
471 socklen_t sl = sizeof (sa); 472 socklen_t sl = sizeof (sa);
472 473
473 if (!getsockname (fd, (sockaddr *)&sa, &sl)) 474 if (!getsockname (fd, (sockaddr *)&sa, &sl))
474 is_local = sa.sun_family == AF_UNIX; 475 is_local = sa.sun_family == AF_UNIX;
475 476
477 flush_ev.start ();
476 x_ev.start (fd, ev::READ); 478 x_ev.start (fd, ev::READ);
477 fcntl (fd, F_SETFD, FD_CLOEXEC); 479 fcntl (fd, F_SETFD, FD_CLOEXEC);
478 480
479 XSelectInput (dpy, root, PropertyChangeMask); 481 XSelectInput (dpy, root, PropertyChangeMask);
480 482
499 501
500#ifdef POINTER_BLANK 502#ifdef POINTER_BLANK
501 XFreeCursor (dpy, blank_cursor); 503 XFreeCursor (dpy, blank_cursor);
502#endif 504#endif
503 x_ev.stop (); 505 x_ev.stop ();
506 flush_ev.stop ();
504#ifdef USE_XIM 507#ifdef USE_XIM
505 xims.clear (); 508 xims.clear ();
506#endif 509#endif
507 XCloseDisplay (dpy); 510 XCloseDisplay (dpy);
508} 511}
547 XEvent xev; 550 XEvent xev;
548 XNextEvent (dpy, &xev); 551 XNextEvent (dpy, &xev);
549 552
550#ifdef USE_XIM 553#ifdef USE_XIM
551 if (!XFilterEvent (&xev, None)) 554 if (!XFilterEvent (&xev, None))
555#endif
552 { 556 {
553 if (xev.type == PropertyNotify 557 if (xev.type == PropertyNotify
554 && xev.xany.window == root 558 && xev.xany.window == root
555 && xev.xproperty.atom == xa[XA_XIM_SERVERS]) 559 && xev.xproperty.atom == xa[XA_XIM_SERVERS])
556 im_change_check (); 560 im_change_check ();
557#endif 561
558 if (xev.type == MappingNotify) 562 if (xev.type == MappingNotify)
559 XRefreshKeyboardMapping (&xev.xmapping); 563 XRefreshKeyboardMapping (&xev.xmapping);
560 564
561 for (int i = xw.size (); i--; ) 565 for (int i = xw.size (); i--; )
562 { 566 {
563 if (!xw[i]) 567 if (!xw[i])
564 xw.erase_unordered (i); 568 xw.erase_unordered (i);
565 else if (xw[i]->window == xev.xany.window) 569 else if (xw[i]->window == xev.xany.window)
566 xw[i]->call (xev); 570 xw[i]->call (xev);
567 } 571 }
568#ifdef USE_XIM
569 } 572 }
570#endif
571 } 573 }
572 574
575 flush_ev.start ();
576}
577
578void rxvt_display::flush_cb (ev::prepare &w, int revents)
579{
580 x_cb(x_ev,0);//D
573 XFlush (dpy); 581 XFlush (dpy);
574} 582 w.stop ();
575
576void rxvt_display::flush ()
577{
578 x_cb (x_ev, ev::READ);
579} 583}
580 584
581void rxvt_display::reg (xevent_watcher *w) 585void rxvt_display::reg (xevent_watcher *w)
582{ 586{
583 if (!w->active) 587 if (!w->active)
597} 601}
598 602
599void rxvt_display::set_selection_owner (rxvt_term *owner) 603void rxvt_display::set_selection_owner (rxvt_term *owner)
600{ 604{
601 if (selection_owner && selection_owner != owner) 605 if (selection_owner && selection_owner != owner)
606 {
607 rxvt_term *owner = selection_owner;
608
602 selection_owner->selection_clear (); 609 owner->selection_clear ();
610 owner->flush ();
611 }
603 612
604 selection_owner = owner; 613 selection_owner = owner;
605} 614}
606 615
607#ifdef USE_XIM 616#ifdef USE_XIM
666} 675}
667 676
668bool 677bool
669rxvt_color::alloc (rxvt_screen *screen, const rgba &color) 678rxvt_color::alloc (rxvt_screen *screen, const rgba &color)
670{ 679{
680 //TODO: only supports 24 bit
681 int alpha = color.a >= 0xff00 ? 0xffff : color.a;
682
671#if XFT 683#if XFT
672 XRenderPictFormat *format; 684 XRenderPictFormat *format;
673 685
674 // FUCKING Xft gets it wrong, of course, so work around it. 686 // FUCKING Xft gets it wrong, of course, so work around it.
675 // Transparency users should eat shit and die, and then 687 // Transparency users should eat shit and die, and then
679 { 691 {
680 // the fun lies in doing everything manually... 692 // the fun lies in doing everything manually...
681 c.color.red = color.r; 693 c.color.red = color.r;
682 c.color.green = color.g; 694 c.color.green = color.g;
683 c.color.blue = color.b; 695 c.color.blue = color.b;
684 c.color.alpha = color.a; 696 c.color.alpha = alpha;
685 697
686 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 )
687 | insert_component (color.g, format->direct.greenMask, format->direct.green) 699 | insert_component (color.g, format->direct.greenMask, format->direct.green)
688 | insert_component (color.b, format->direct.blueMask , format->direct.blue ) 700 | insert_component (color.b, format->direct.blueMask , format->direct.blue )
689 | insert_component (color.a, format->direct.alphaMask, format->direct.alpha); 701 | insert_component (alpha , format->direct.alphaMask, format->direct.alpha);
690 702
691 return true; 703 return true;
692 } 704 }
693 else 705 else
694 { 706 {
695 XRenderColor d; 707 XRenderColor d;
696 708
697 d.red = color.r; 709 d.red = color.r;
698 d.green = color.g; 710 d.green = color.g;
699 d.blue = color.b; 711 d.blue = color.b;
700 d.alpha = color.a; 712 d.alpha = alpha;
701 713
702 return XftColorAllocValue (screen->dpy, screen->visual, screen->cmap, &d, &c); 714 return XftColorAllocValue (screen->dpy, screen->visual, screen->cmap, &d, &c);
703 } 715 }
704#else 716#else
705 c.red = color.r; 717 c.red = color.r;
730{ 742{
731 rgba c; 743 rgba c;
732 char eos; 744 char eos;
733 int skip; 745 int skip;
734 746
747 c.a = rgba::MAX_CC;
748
735 // parse the nonstandard "[alphapercent]" prefix 749 // parse the nonstandard "[alphapercent]" prefix
736 if (1 <= sscanf (name, "[%hd]%n", &c.a, &skip)) 750 if (1 <= sscanf (name, "[%hd]%n", &c.a, &skip))
737 { 751 {
738 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);
739 name += skip; 753 name += skip;
740 } 754 }
741 else
742 c.a = rgba::MAX_CC;
743 755
744 // parse the non-standard "#aarrggbb" format
745 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))
746 {
747 if (c.r)
748 c.r = (c.r << 8) | 0x0ff;
749 if (c.g)
750 c.g = (c.g << 8) | 0x0ff;
751 if (c.b)
752 c.b = (c.b << 8) | 0x0ff;
753 if (c.a)
754 c.a = (c.a << 8) | 0x0ff;
755 }
756 // parse the non-standard "rgba:rrrr/gggg/bbbb/aaaa" format 756 // parse the non-standard "rgba:rrrr/gggg/bbbb/aaaa" format
757 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))
758 { 758 {
759 XColor xc; 759 XColor xc;
760 760
761 if (XParseColor (screen->dpy, screen->cmap, name, &xc)) 761 if (XParseColor (screen->dpy, screen->cmap, name, &xc))
762 { 762 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines