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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines