… | |
… | |
892 | lerp (c.a, to.a, percent) |
892 | lerp (c.a, to.a, percent) |
893 | ) |
893 | ) |
894 | ); |
894 | ); |
895 | } |
895 | } |
896 | |
896 | |
897 | rxvt_selection::rxvt_selection (rxvt_display *disp, int selnum, Time tm, Window win, Atom prop, sel_cb cb, void *ptr) |
897 | rxvt_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.; |
… | |
… | |
932 | { |
932 | { |
933 | stop (); |
933 | stop (); |
934 | } |
934 | } |
935 | |
935 | |
936 | void |
936 | void |
|
|
937 | rxvt_selection::finish (char *data, unsigned int len) |
|
|
938 | { |
|
|
939 | if (term) |
|
|
940 | { |
|
|
941 | if (data) |
|
|
942 | term->paste (data, len); |
|
|
943 | |
|
|
944 | term->selection_req = 0; |
|
|
945 | delete this; |
|
|
946 | } |
|
|
947 | #if ENABLE_PERL |
|
|
948 | else |
|
|
949 | { |
|
|
950 | stop (); |
|
|
951 | abort (); //TODO |
|
|
952 | } |
|
|
953 | #endif |
|
|
954 | } |
|
|
955 | |
|
|
956 | void |
937 | rxvt_selection::stop () |
957 | rxvt_selection::stop () |
938 | { |
958 | { |
939 | free (incr_buf); |
959 | free (incr_buf); |
940 | incr_buf = 0; |
960 | incr_buf = 0; |
941 | timer_ev.stop (); |
961 | timer_ev.stop (); |
… | |
… | |
1112 | bailout: |
1132 | bailout: |
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); |
|
|
1119 | free (data); |
1138 | free (data); |
1120 | } |
1139 | } |
1121 | } |
1140 | } |
1122 | |
1141 | |
1123 | void |
1142 | void |
1124 | rxvt_selection::timer_cb (ev::timer &w, int revents) |
1143 | rxvt_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); |
|
|
1131 | } |
1149 | } |
1132 | |
1150 | |
1133 | void |
1151 | void |
1134 | rxvt_selection::x_cb (XEvent &xev) |
1152 | rxvt_selection::x_cb (XEvent &xev) |
1135 | { |
1153 | { |