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.117 by sf-exg, Sat Feb 12 00:30:00 2011 UTC vs.
Revision 1.121 by root, Mon Feb 21 07:41:03 2011 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 2 of the License, or
892 lerp (c.a, to.a, percent) 892 lerp (c.a, to.a, percent)
893 ) 893 )
894 ); 894 );
895} 895}
896 896
897rxvt_selection::rxvt_selection (rxvt_display *disp, int selnum, Time tm, Window win, Atom prop, sel_cb cb, void *ptr) 897rxvt_selection::rxvt_selection (rxvt_display *disp, int selnum, Time tm, Window win, Atom prop, rxvt_term *term, void *cb_sv)
898: display (disp), request_time (tm), request_win (win), request_prop (prop), request_cb (cb), user_data (ptr) 898: display (disp), request_time (tm), request_win (win), request_prop (prop), term (term), cb_sv (cb_sv)
899{ 899{
900 assert (selnum >= Sel_Primary && selnum <= Sel_Clipboard); 900 assert (selnum >= Sel_Primary && selnum <= Sel_Clipboard);
901 901
902 timer_ev.set<rxvt_selection, &rxvt_selection::timer_cb> (this); 902 timer_ev.set<rxvt_selection, &rxvt_selection::timer_cb> (this);
903 timer_ev.repeat = 10.; 903 timer_ev.repeat = 10.;
905 905
906 incr_buf = 0; 906 incr_buf = 0;
907 incr_buf_size = incr_buf_fill = 0; 907 incr_buf_size = incr_buf_fill = 0;
908 selection_wait = Sel_normal; 908 selection_wait = Sel_normal;
909 selection_type = selnum; 909 selection_type = selnum;
910}
911
912void
913rxvt_selection::stop ()
914{
915 free (incr_buf);
916 incr_buf = 0;
917 timer_ev.stop ();
918 x_ev.stop (display);
919}
920
921rxvt_selection::~rxvt_selection ()
922{
923 stop ();
910} 924}
911 925
912void 926void
913rxvt_selection::run () 927rxvt_selection::run ()
914{ 928{
926 940
927 // fallback to CUT_BUFFER0 if the requested property has no owner 941 // fallback to CUT_BUFFER0 if the requested property has no owner
928 handle_selection (display->root, XA_CUT_BUFFER0, false); 942 handle_selection (display->root, XA_CUT_BUFFER0, false);
929} 943}
930 944
931rxvt_selection::~rxvt_selection () 945void
946rxvt_selection::finish (char *data, unsigned int len)
932{ 947{
948 if (term)
949 {
950 if (data)
951 term->paste (data, len);
952
953 term->selection_req = 0;
954 delete this;
955 }
956#if ENABLE_PERL
957 else
958 {
933 stop (); 959 stop ();
934} 960 abort (); //TODO
935 961 }
936void 962#endif
937rxvt_selection::stop ()
938{
939 free (incr_buf);
940 incr_buf = 0;
941 timer_ev.stop ();
942 x_ev.stop (display);
943} 963}
944 964
945bool 965bool
946rxvt_selection::request (Atom target, int selnum) 966rxvt_selection::request (Atom target, int selnum)
947{ 967{
1112bailout: 1132bailout:
1113 XFree (ct.value); 1133 XFree (ct.value);
1114 1134
1115 if (selection_wait == Sel_normal) 1135 if (selection_wait == Sel_normal)
1116 { 1136 {
1117 stop (); 1137 finish (data, data_len);
1118 request_cb (data, data_len, this, user_data);
1119 free (data); 1138 free (data);
1120 } 1139 }
1121} 1140}
1122 1141
1123void 1142void
1124rxvt_selection::timer_cb (ev::timer &w, int revents) 1143rxvt_selection::timer_cb (ev::timer &w, int revents)
1125{ 1144{
1126 if (selection_wait == Sel_incr) 1145 if (selection_wait == Sel_incr)
1127 rxvt_warn ("data loss: timeout on INCR selection paste, ignoring.\n"); 1146 rxvt_warn ("data loss: timeout on INCR selection paste, ignoring.\n");
1128 1147
1129 stop (); 1148 finish ();
1130 request_cb (NULL, 0, this, user_data);
1131} 1149}
1132 1150
1133void 1151void
1134rxvt_selection::x_cb (XEvent &xev) 1152rxvt_selection::x_cb (XEvent &xev)
1135{ 1153{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines