--- rxvt-unicode/src/rxvttoolkit.C 2011/02/12 00:30:00 1.117 +++ rxvt-unicode/src/rxvttoolkit.C 2011/02/21 08:10:10 1.122 @@ -3,7 +3,7 @@ *----------------------------------------------------------------------* * * All portions of code are copyright by their respective author/s. - * Copyright (c) 2003-2007 Marc Lehmann + * Copyright (c) 2003-2011 Marc Lehmann * Copyright (c) 2011 Emanuele Giaquinta * * This program is free software; you can redistribute it and/or modify @@ -894,8 +894,8 @@ ); } -rxvt_selection::rxvt_selection (rxvt_display *disp, int selnum, Time tm, Window win, Atom prop, sel_cb cb, void *ptr) -: display (disp), request_time (tm), request_win (win), request_prop (prop), request_cb (cb), user_data (ptr) +rxvt_selection::rxvt_selection (rxvt_display *disp, int selnum, Time tm, Window win, Atom prop, rxvt_term *term) +: display (disp), request_time (tm), request_win (win), request_prop (prop), term (term) { assert (selnum >= Sel_Primary && selnum <= Sel_Clipboard); @@ -910,6 +910,20 @@ } void +rxvt_selection::stop () +{ + free (incr_buf); + incr_buf = 0; + timer_ev.stop (); + x_ev.stop (display); +} + +rxvt_selection::~rxvt_selection () +{ + stop (); +} + +void rxvt_selection::run () { int selnum = selection_type; @@ -928,18 +942,24 @@ handle_selection (display->root, XA_CUT_BUFFER0, false); } -rxvt_selection::~rxvt_selection () -{ - stop (); -} - void -rxvt_selection::stop () +rxvt_selection::finish (char *data, unsigned int len) { - free (incr_buf); - incr_buf = 0; - timer_ev.stop (); - x_ev.stop (display); + if (term) + { + if (data) + term->paste (data, len); + + term->selection_req = 0; + delete this; + } +#if ENABLE_PERL + else + { + stop (); // we do not really trust perl callbacks + rxvt_perl.selection_finish (this, data, len); + } +#endif } bool @@ -1114,8 +1134,7 @@ if (selection_wait == Sel_normal) { - stop (); - request_cb (data, data_len, this, user_data); + finish (data, data_len); free (data); } } @@ -1126,8 +1145,7 @@ if (selection_wait == Sel_incr) rxvt_warn ("data loss: timeout on INCR selection paste, ignoring.\n"); - stop (); - request_cb (NULL, 0, this, user_data); + finish (); } void