--- rxvt-unicode/src/rxvtperl.xs 2011/05/30 18:39:03 1.141 +++ rxvt-unicode/src/rxvtperl.xs 2011/07/01 19:07:08 1.142 @@ -369,6 +369,7 @@ // runs outside of perls ENV term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); + hv_store ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, newRV_noinc ((SV *)newAV ()), 0); } } @@ -399,6 +400,16 @@ for (int i = 0; i <= AvFILL (av); i++) ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); } + else if (htype == HOOK_DESTROY) + { + AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0)); + + for (int i = AvFILL (av); i >= 0; i--) + { + rxvt_selection *req = (rxvt_selection *)SvIV (*av_fetch (av, i, 0)); + delete req; + } + } bool event_consumed; @@ -878,6 +889,8 @@ CODE: rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term); req->cb_sv = newSVsv (cb); + AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0)); + av_push (av, newSViv ((IV)req)); RETVAL = (IV)req; OUTPUT: RETVAL @@ -886,6 +899,18 @@ _delete_selection_request (IV req_) CODE: rxvt_selection *req = (rxvt_selection *)req_; + AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)req->term->perl.self), "_selection", 10, 0)); + int i; + + for (i = AvFILL (av); i >= 0; i--) + if (SvIV (*av_fetch (av, i, 1)) == req_) + break; + + for (; i < AvFILL (av); i++) + av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0))); + + av_pop (av); + delete req; MODULE = urxvt PACKAGE = urxvt::term