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.115 by sf-exg, Fri Feb 11 01:24:46 2011 UTC vs.
Revision 1.148 by root, Wed Dec 17 14:25:01 2014 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-2007 Marc Lehmann <pcg@goof.com> 6 * Copyright (c) 2003-2011 Marc Lehmann <schmorp@schmorp.de>
7 * Copyright (c) 2011 Emanuele Giaquinta <e.giaquinta@glauco.it>
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify 9 * 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 10 * 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 11 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version. 12 * (at your option) any later version.
12 * 13 *
13 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 *----------------------------------------------------------------------*/ 22 *----------------------------------------------------------------------*/
22 23
23#include "../config.h" 24#include "../config.h"
24#include <rxvt.h> 25#include <rxvt.h>
25#include <rxvttoolkit.h> 26#include <rxvttoolkit.h>
27
28#include <stdlib.h>
26 29
27#include <unistd.h> 30#include <unistd.h>
28#include <fcntl.h> 31#include <fcntl.h>
29 32
30#include <sys/utsname.h> 33#include <sys/utsname.h>
65#endif 68#endif
66#if USE_XIM 69#if USE_XIM
67 "WM_LOCALE_NAME", 70 "WM_LOCALE_NAME",
68 "XIM_SERVERS", 71 "XIM_SERVERS",
69#endif 72#endif
70#ifdef ENABLE_TRANSPARENCY 73#if HAVE_IMG || ENABLE_PERL
71 "_XROOTPMAP_ID", 74 "_XROOTPMAP_ID",
72 "ESETROOT_PMAP_ID", 75 "ESETROOT_PMAP_ID",
73#endif 76#endif
74#if ENABLE_XEMBED 77#if ENABLE_XEMBED
75 "_XEMBED", 78 "_XEMBED",
152 put (*this->begin ()); 155 put (*this->begin ());
153} 156}
154 157
155///////////////////////////////////////////////////////////////////////////// 158/////////////////////////////////////////////////////////////////////////////
156 159
157#ifdef USE_XIM 160#if USE_XIM
158 161
159static void 162static void
160#if XIMCB_PROTO_BROKEN 163#if XIMCB_PROTO_BROKEN
161im_destroy_cb (XIC unused1, XPointer client_data, XPointer unused3) 164im_destroy_cb (XIC unused1, XPointer client_data, XPointer unused3)
162#else 165#else
259 depth = DefaultDepthOfScreen (screen); 262 depth = DefaultDepthOfScreen (screen);
260 visual = DefaultVisualOfScreen (screen); 263 visual = DefaultVisualOfScreen (screen);
261 cmap = DefaultColormapOfScreen (screen); 264 cmap = DefaultColormapOfScreen (screen);
262} 265}
263 266
267#if ENABLE_FRILLS
268
264void 269void
265rxvt_screen::select_visual (int bitdepth) 270rxvt_screen::select_visual (int id)
266{ 271{
267#if XFT
268 XVisualInfo vinfo; 272 XVisualInfo vinfo;
273 vinfo.visualid = id;
274 int n;
275
276 if (XVisualInfo *vi = XGetVisualInfo (dpy, VisualIDMask, &vinfo, &n))
277 {
278 depth = vi->depth;
279 visual = vi->visual;
280
281 XFree (vi);
282
283 cmap = XCreateColormap (dpy, display->root, visual, AllocNone);
284 }
285 else
286 rxvt_warn ("no visual found for requested id 0x%02x, using default visual.\n", id);
287}
288
289void
290rxvt_screen::select_depth (int bitdepth)
291{
292 XVisualInfo vinfo;
269 293
270 if (XMatchVisualInfo (dpy, display->screen, bitdepth, TrueColor, &vinfo)) 294 if (XMatchVisualInfo (dpy, display->screen, bitdepth, TrueColor, &vinfo))
271 {
272 depth = bitdepth;
273 visual = vinfo.visual; 295 select_visual (vinfo.visualid);
274 cmap = XCreateColormap (dpy, display->root, visual, AllocNone); 296 else
275 } 297 rxvt_warn ("no visual found for requested depth %d, using default visual.\n", bitdepth);
276#endif
277} 298}
299
300#endif
278 301
279void 302void
280rxvt_screen::clear () 303rxvt_screen::clear ()
281{ 304{
282#if XFT 305#if XFT
429bool rxvt_display::ref_init () 452bool rxvt_display::ref_init ()
430{ 453{
431#ifdef LOCAL_X_IS_UNIX 454#ifdef LOCAL_X_IS_UNIX
432 if (id[0] == ':') 455 if (id[0] == ':')
433 { 456 {
434 if (!(val = rxvt_temp_buf<char> (5 + strlen (id) + 1))) 457 char *val = rxvt_temp_buf<char> (5 + strlen (id) + 1);
435 return false; 458
436 strcpy (val, "unix/"); 459 strcpy (val, "unix/");
437 strcat (val, id); 460 strcat (val, id);
461
438 dpy = XOpenDisplay (val); 462 dpy = XOpenDisplay (val);
439 } 463 }
440 else 464 else
441#endif 465#endif
442 dpy = 0; 466 dpy = 0;
448 return false; 472 return false;
449 473
450 screen = DefaultScreen (dpy); 474 screen = DefaultScreen (dpy);
451 root = DefaultRootWindow (dpy); 475 root = DefaultRootWindow (dpy);
452 476
453 assert (ARRAY_LENGTH(xa_names) == NUM_XA); 477 assert (ecb_array_length (xa_names) == NUM_XA);
454 XInternAtoms (dpy, (char **)xa_names, NUM_XA, False, xa); 478 XInternAtoms (dpy, (char **)xa_names, NUM_XA, False, xa);
455 479
456 XrmSetDatabase (dpy, get_resources (false)); 480 XrmSetDatabase (dpy, get_resources (false));
457 481
458#ifdef POINTER_BLANK 482#ifdef POINTER_BLANK
464 blank_cursor = XCreateGlyphCursor (dpy, f, f, ' ', ' ', 488 blank_cursor = XCreateGlyphCursor (dpy, f, f, ' ', ' ',
465 &blackcolour, &blackcolour); 489 &blackcolour, &blackcolour);
466 XUnloadFont (dpy, f); 490 XUnloadFont (dpy, f);
467#endif 491#endif
468 492
493 flags = 0;
494#if XRENDER
495 int major, minor;
496 if (XRenderQueryVersion (dpy, &major, &minor))
497 if (major > 0 || (major == 0 && minor >= 11))
498 {
499 flags |= DISPLAY_HAS_RENDER;
500
501 if (XFilters *filters = XRenderQueryFilters (dpy, root))
502 {
503 for (int i = 0; i < filters->nfilter; i++)
504 if (!strcmp (filters->filter [i], FilterConvolution))
505 flags |= DISPLAY_HAS_RENDER_CONV;
506
507 XFree (filters);
508 }
509 }
510#endif
511
469 int fd = XConnectionNumber (dpy); 512 int fd = XConnectionNumber (dpy);
470 513
471 // try to detect whether we have a local connection. 514 // try to detect whether we have a local connection.
472 // assume unix domain socket == local, everything else not 515 // assume unix domain socket == local, everything else not
473 // TODO: might want to check for inet/127.0.0.1 516 // TODO: might want to check for inet/127.0.0.1
510#ifdef POINTER_BLANK 553#ifdef POINTER_BLANK
511 XFreeCursor (dpy, blank_cursor); 554 XFreeCursor (dpy, blank_cursor);
512#endif 555#endif
513 x_ev.stop (); 556 x_ev.stop ();
514 flush_ev.stop (); 557 flush_ev.stop ();
515#ifdef USE_XIM 558#if USE_XIM
516 xims.clear (); 559 xims.clear ();
517#endif 560#endif
518 XrmDestroyDatabase (XrmGetDatabase (dpy)); 561 XrmDestroyDatabase (XrmGetDatabase (dpy));
519 XCloseDisplay (dpy); 562 XCloseDisplay (dpy);
520} 563}
521 564
522#ifdef USE_XIM 565#if USE_XIM
523void rxvt_display::im_change_cb () 566void rxvt_display::im_change_cb ()
524{ 567{
525 for (im_watcher **i = imw.begin (); i != imw.end (); ++i) 568 for (im_watcher **i = imw.begin (); i != imw.end (); ++i)
526 (*i)->call (); 569 (*i)->call ();
527} 570}
563 do 606 do
564 { 607 {
565 XEvent xev; 608 XEvent xev;
566 XNextEvent (dpy, &xev); 609 XNextEvent (dpy, &xev);
567 610
568#ifdef USE_XIM 611#if USE_XIM
569 if (!XFilterEvent (&xev, None)) 612 if (!XFilterEvent (&xev, None))
570 { 613 {
571 if (xev.type == PropertyNotify 614 if (xev.type == PropertyNotify
572 && xev.xany.window == root 615 && xev.xany.window == root
573 && xev.xproperty.atom == xa[XA_XIM_SERVERS]) 616 && xev.xproperty.atom == xa[XA_XIM_SERVERS])
581 if (!xw[i]) 624 if (!xw[i])
582 xw.erase_unordered (i); 625 xw.erase_unordered (i);
583 else if (xw[i]->window == xev.xany.window) 626 else if (xw[i]->window == xev.xany.window)
584 xw[i]->call (xev); 627 xw[i]->call (xev);
585 } 628 }
586#ifdef USE_XIM 629#if USE_XIM
587 } 630 }
588#endif 631#endif
589 } 632 }
590 while (XEventsQueued (dpy, QueuedAlready)); 633 while (XEventsQueued (dpy, QueuedAlready));
591 634
622 } 665 }
623 666
624 cur_owner = owner; 667 cur_owner = owner;
625} 668}
626 669
627#ifdef USE_XIM 670#if USE_XIM
628 671
629void rxvt_display::reg (im_watcher *w) 672void rxvt_display::reg (im_watcher *w)
630{ 673{
631 imw.push_back (w); 674 imw.push_back (w);
632} 675}
667Atom rxvt_display::atom (const char *name) 710Atom rxvt_display::atom (const char *name)
668{ 711{
669 return XInternAtom (dpy, name, False); 712 return XInternAtom (dpy, name, False);
670} 713}
671 714
715Pixmap
716rxvt_display::get_pixmap_property (Atom property)
717{
718 Pixmap pixmap = None;
719
720 int aformat;
721 unsigned long nitems, bytes_after;
722 Atom atype;
723 unsigned char *prop;
724 int result = XGetWindowProperty (dpy, root, property,
725 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
726 &nitems, &bytes_after, &prop);
727 if (result == Success)
728 {
729 if (atype == XA_PIXMAP)
730 pixmap = *(Pixmap *)prop;
731 XFree (prop);
732 }
733
734 return pixmap;
735}
736
672///////////////////////////////////////////////////////////////////////////// 737/////////////////////////////////////////////////////////////////////////////
673 738
674template class refcache<rxvt_display>; 739template class refcache<rxvt_display>;
675refcache<rxvt_display> displays; 740refcache<rxvt_display> displays;
676 741
685 750
686bool 751bool
687rxvt_color::alloc (rxvt_screen *screen, const rgba &color) 752rxvt_color::alloc (rxvt_screen *screen, const rgba &color)
688{ 753{
689 //TODO: only supports 24 bit 754 //TODO: only supports 24 bit
690 int alpha = color.a >= 0xff00 ? 0xffff : color.a; 755 unsigned int alpha = color.a >= 0xff00 ? 0xffff : color.a;
691 756
692#if XFT 757#if XFT
693 XRenderPictFormat *format; 758 XRenderPictFormat *format;
759
760 // not needed by XftColorAlloc, but by the other paths (ours
761 // and fallback), so just set all components here.
762 c.color.red = color.r;
763 c.color.green = color.g;
764 c.color.blue = color.b;
765 c.color.alpha = alpha;
694 766
695 // FUCKING Xft gets it wrong, of course, so work around it. 767 // FUCKING Xft gets it wrong, of course, so work around it.
696 // Transparency users should eat shit and die, and then 768 // Transparency users should eat shit and die, and then
697 // XRenderQueryPictIndexValues themselves plenty. 769 // XRenderQueryPictIndexValues themselves plenty.
698 if ((screen->visual->c_class == TrueColor) 770 if ((screen->visual->c_class == TrueColor)
699 && (format = XRenderFindVisualFormat (screen->dpy, screen->visual))) 771 && (format = XRenderFindVisualFormat (screen->dpy, screen->visual)))
700 { 772 {
701 // the fun lies in doing everything manually... 773 // the fun lies in doing everything manually...
702 c.color.red = color.r;
703 c.color.green = color.g;
704 c.color.blue = color.b;
705 c.color.alpha = alpha;
706 774
775 // Xft wants premultiplied alpha, but abuses the alpha channel
776 // as blend factor, and doesn't allow us to set the alpha channel
777 c.color.red = c.color.red * alpha / 0xffff;
778 c.color.green = c.color.green * alpha / 0xffff;
779 c.color.blue = c.color.blue * alpha / 0xffff;
780
707 c.pixel = insert_component (color.r, format->direct.redMask , format->direct.red ) 781 c.pixel = insert_component (c.color.red , format->direct.redMask , format->direct.red )
708 | insert_component (color.g, format->direct.greenMask, format->direct.green) 782 | insert_component (c.color.green, format->direct.greenMask, format->direct.green)
709 | insert_component (color.b, format->direct.blueMask , format->direct.blue ) 783 | insert_component (c.color.blue , format->direct.blueMask , format->direct.blue )
710 | insert_component (alpha , format->direct.alphaMask, format->direct.alpha); 784 | insert_component (alpha , format->direct.alphaMask, format->direct.alpha);
711 785
712 return true; 786 return true;
713 } 787 }
714 else 788 else
715 { 789 {
718 d.red = color.r; 792 d.red = color.r;
719 d.green = color.g; 793 d.green = color.g;
720 d.blue = color.b; 794 d.blue = color.b;
721 d.alpha = alpha; 795 d.alpha = alpha;
722 796
797 // XftColorAlloc always returns 100% transparent pixels(!)
723 return XftColorAllocValue (screen->dpy, screen->visual, screen->cmap, &d, &c); 798 if (XftColorAllocValue (screen->dpy, screen->visual, screen->cmap, &d, &c))
799 return true;
724 } 800 }
725#else 801#else
726 c.red = color.r; 802 c.red = color.r;
727 c.green = color.g; 803 c.green = color.g;
728 c.blue = color.b; 804 c.blue = color.b;
729 805
730 if (screen->visual->c_class == TrueColor) 806 if (screen->visual->c_class == TrueColor)
731 { 807 {
732 c.pixel = (color.r >> (16 - rxvt_popcount (screen->visual->red_mask )) << rxvt_ctz (screen->visual->red_mask )) 808 c.pixel = (color.r >> (16 - ecb_popcount32 (screen->visual->red_mask )) << ecb_ctz32 (screen->visual->red_mask ))
733 | (color.g >> (16 - rxvt_popcount (screen->visual->green_mask)) << rxvt_ctz (screen->visual->green_mask)) 809 | (color.g >> (16 - ecb_popcount32 (screen->visual->green_mask)) << ecb_ctz32 (screen->visual->green_mask))
734 | (color.b >> (16 - rxvt_popcount (screen->visual->blue_mask )) << rxvt_ctz (screen->visual->blue_mask )); 810 | (color.b >> (16 - ecb_popcount32 (screen->visual->blue_mask )) << ecb_ctz32 (screen->visual->blue_mask ));
735 811
736 return true; 812 return true;
737 } 813 }
738 else if (XAllocColor (screen->dpy, screen->cmap, &c)) 814 else if (XAllocColor (screen->dpy, screen->cmap, &c))
739 return true; 815 return true;
740 else 816#endif
817
741 c.pixel = (color.r + color.g + color.b) > 128*3 818 c.pixel = (color.r * 2 + color.g * 3 + color.b) >= 0x8000 * 6
742 ? WhitePixelOfScreen (DefaultScreenOfDisplay (screen->dpy)) 819 ? WhitePixelOfScreen (DefaultScreenOfDisplay (screen->dpy))
743 : BlackPixelOfScreen (DefaultScreenOfDisplay (screen->dpy)); 820 : BlackPixelOfScreen (DefaultScreenOfDisplay (screen->dpy));
744#endif
745 821
746 return false; 822 return false;
747} 823}
748 824
749bool 825bool
805 881
806 // many kilobytes transfer per colour, but pseudocolor isn't worth 882 // many kilobytes transfer per colour, but pseudocolor isn't worth
807 // many extra optimisations. 883 // many extra optimisations.
808 XQueryColors (screen->dpy, screen->cmap, colors, cmap_size); 884 XQueryColors (screen->dpy, screen->cmap, colors, cmap_size);
809 885
886 while (cmap_size)
887 {
810 int diff = 0x7fffffffUL; 888 int diff = 0x7fffffffL;
811 XColor *best = colors; 889 XColor *best = colors;
812 890
813 for (int i = 0; i < cmap_size; i++) 891 for (int i = 0; i < cmap_size; i++)
814 {
815 int d = (squared_diff<int> (color.r >> 2, colors [i].red >> 2))
816 + (squared_diff<int> (color.g >> 2, colors [i].green >> 2))
817 + (squared_diff<int> (color.b >> 2, colors [i].blue >> 2));
818
819 if (d < diff)
820 { 892 {
893 // simple weighted rgb distance sucks, but keeps it simple
894 int d = abs (color.r - colors [i].red ) * 2
895 + abs (color.g - colors [i].green) * 3
896 + abs (color.b - colors [i].blue );
897
898 if (d < diff)
899 {
821 diff = d; 900 diff = d;
822 best = colors + i; 901 best = colors + i;
902 }
823 } 903 }
824 }
825 904
826 //rxvt_warn ("could not allocate %04x %04x %04x, getting %04x %04x %04x instead (%d)\n", 905 //rxvt_warn ("could not allocate %04x %04x %04x, getting %04x %04x %04x instead (%d,%d)\n",
827 // color.r, color.g, color.b, best->red, best->green, best->blue, diff); 906 // color.r, color.g, color.b, best->red, best->green, best->blue, diff, best - colors);
828 907
829 got = alloc (screen, rgba (best->red, best->green, best->blue)); 908 got = alloc (screen, rgba (best->red, best->green, best->blue));
909
910 if (got)
911 break;
912
913 *best = colors [--cmap_size];
914 }
830 915
831 delete [] colors; 916 delete [] colors;
832 } 917 }
833#endif 918#endif
834 919
835 return got; 920 return got;
836} 921}
837 922
838void 923void
839rxvt_color::get (rgba &color) 924rxvt_color::get (rgba &color) const
840{ 925{
841#if XFT 926#if XFT
927 //TODO premultiplied alpha??
842 color.r = c.color.red; 928 color.r = c.color.red;
843 color.g = c.color.green; 929 color.g = c.color.green;
844 color.b = c.color.blue; 930 color.b = c.color.blue;
845 color.a = c.color.alpha; 931 color.a = c.color.alpha;
846#else 932#else
850 color.a = rgba::MAX_CC; 936 color.a = rgba::MAX_CC;
851#endif 937#endif
852} 938}
853 939
854void 940void
855rxvt_color::get (XColor &color) 941rxvt_color::get (XColor &color) const
856{ 942{
857 rgba c; 943 rgba c;
858 get (c); 944 get (c);
859 945
860 color.red = c.r; 946 color.red = c.r;
891 lerp (c.a, to.a, percent) 977 lerp (c.a, to.a, percent)
892 ) 978 )
893 ); 979 );
894} 980}
895 981
896rxvt_selection::rxvt_selection (rxvt_display *disp, int selnum, Time tm, Window win, Atom prop, sel_cb cb, void *ptr) 982rxvt_selection::rxvt_selection (rxvt_display *disp, int selnum, Time tm, Window win, Atom prop, rxvt_term *term)
897: display (disp), request_time (tm), request_win (win), request_prop (prop), request_cb (cb), user_data (ptr) 983: display (disp), request_time (tm), request_win (win), request_prop (prop), term (term)
898{ 984{
899 assert (selnum >= Sel_Primary && selnum <= Sel_Clipboard); 985 assert (selnum >= Sel_Primary && selnum <= Sel_Clipboard);
900 986
901 timer_ev.set<rxvt_selection, &rxvt_selection::timer_cb> (this); 987 timer_ev.set<rxvt_selection, &rxvt_selection::timer_cb> (this);
902 timer_ev.repeat = 10.; 988 timer_ev.repeat = 10.;
903 x_ev.set<rxvt_selection, &rxvt_selection::x_cb> (this); 989 x_ev.set<rxvt_selection, &rxvt_selection::x_cb> (this);
904 990
905 incr_buf = 0; 991 incr_buf = 0;
906 incr_buf_size = incr_buf_fill = 0; 992 incr_buf_size = incr_buf_fill = 0;
907 selection_wait = Sel_normal; 993 selection_wait = Sel_normal;
994 selection_type = selnum;
995 cb_sv = 0;
996}
997
998void
999rxvt_selection::stop ()
1000{
1001 free (incr_buf);
1002 incr_buf = 0;
1003 timer_ev.stop ();
1004 x_ev.stop (display);
1005}
1006
1007rxvt_selection::~rxvt_selection ()
1008{
1009 stop ();
1010}
1011
1012void
1013rxvt_selection::run ()
1014{
1015 int selnum = selection_type;
1016
1017#if ENABLE_FRILLS
1018 if (selnum == Sel_Primary && display->selection_owner)
1019 {
1020 /* internal selection */
1021 char *str = rxvt_wcstombs (display->selection_owner->selection.text, display->selection_owner->selection.len);
1022 finish (str, strlen (str));
1023 free (str);
1024 return;
1025 }
1026#endif
908 1027
909#if X_HAVE_UTF8_STRING 1028#if X_HAVE_UTF8_STRING
910 selection_type = Sel_UTF8String; 1029 selection_type = Sel_UTF8String;
911 if (request (display->xa[XA_UTF8_STRING], selnum)) 1030 if (request (display->xa[XA_UTF8_STRING], selnum))
912 return; 1031 return;
918 1037
919 // fallback to CUT_BUFFER0 if the requested property has no owner 1038 // fallback to CUT_BUFFER0 if the requested property has no owner
920 handle_selection (display->root, XA_CUT_BUFFER0, false); 1039 handle_selection (display->root, XA_CUT_BUFFER0, false);
921} 1040}
922 1041
923rxvt_selection::~rxvt_selection ()
924{
925 stop ();
926}
927
928void 1042void
929rxvt_selection::stop () 1043rxvt_selection::finish (char *data, unsigned int len)
930{ 1044{
931 free (incr_buf); 1045 if (!cb_sv)
932 incr_buf = 0; 1046 {
933 timer_ev.stop (); 1047 if (data)
934 x_ev.stop (display); 1048 term->paste (data, len);
1049
1050 term->selection_req = 0;
1051 delete this;
1052 }
1053#if ENABLE_PERL
1054 else
1055 {
1056 stop (); // we do not really trust perl callbacks
1057 rxvt_perl.selection_finish (this, data, len);
1058 }
1059#endif
935} 1060}
936 1061
937bool 1062bool
938rxvt_selection::request (Atom target, int selnum) 1063rxvt_selection::request (Atom target, int selnum)
939{ 1064{
1104bailout: 1229bailout:
1105 XFree (ct.value); 1230 XFree (ct.value);
1106 1231
1107 if (selection_wait == Sel_normal) 1232 if (selection_wait == Sel_normal)
1108 { 1233 {
1109 stop (); 1234 finish (data, data_len);
1110 request_cb (data, data_len, this, user_data);
1111 free (data); 1235 free (data);
1112 } 1236 }
1113} 1237}
1114 1238
1115void 1239void
1116rxvt_selection::timer_cb (ev::timer &w, int revents) 1240rxvt_selection::timer_cb (ev::timer &w, int revents)
1117{ 1241{
1118 if (selection_wait == Sel_incr) 1242 if (selection_wait == Sel_incr)
1119 rxvt_warn ("data loss: timeout on INCR selection paste, ignoring.\n"); 1243 rxvt_warn ("data loss: timeout on INCR selection paste, ignoring.\n");
1120 1244
1121 stop (); 1245 finish ();
1122 request_cb (NULL, 0, this, user_data);
1123} 1246}
1124 1247
1125void 1248void
1126rxvt_selection::x_cb (XEvent &xev) 1249rxvt_selection::x_cb (XEvent &xev)
1127{ 1250{
1134 handle_selection (xev.xproperty.window, xev.xproperty.atom, true); 1257 handle_selection (xev.xproperty.window, xev.xproperty.atom, true);
1135 break; 1258 break;
1136 1259
1137 case SelectionNotify: 1260 case SelectionNotify:
1138 if (selection_wait == Sel_normal 1261 if (selection_wait == Sel_normal
1139 && xev.xselection.time == request_time 1262 && xev.xselection.time == request_time)
1140 && xev.xselection.property == request_prop)
1141 { 1263 {
1142 timer_ev.stop (); 1264 timer_ev.stop ();
1143 handle_selection (xev.xselection.requestor, xev.xselection.property, true); 1265 handle_selection (xev.xselection.requestor, xev.xselection.property, true);
1144 } 1266 }
1145 break; 1267 break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines