--- rxvt-unicode/src/rxvttoolkit.C 2011/02/21 07:41:03 1.121 +++ rxvt-unicode/src/rxvttoolkit.C 2011/07/01 19:06:51 1.128 @@ -451,7 +451,7 @@ screen = DefaultScreen (dpy); root = DefaultRootWindow (dpy); - assert (ARRAY_LENGTH(xa_names) == NUM_XA); + assert (ecb_array_length (xa_names) == NUM_XA); XInternAtoms (dpy, (char **)xa_names, NUM_XA, False, xa); XrmSetDatabase (dpy, get_resources (false)); @@ -705,10 +705,16 @@ c.color.blue = color.b; c.color.alpha = alpha; - c.pixel = insert_component (color.r, format->direct.redMask , format->direct.red ) - | insert_component (color.g, format->direct.greenMask, format->direct.green) - | insert_component (color.b, format->direct.blueMask , format->direct.blue ) - | insert_component (alpha , format->direct.alphaMask, format->direct.alpha); + // Xft wants premultiplied alpha, but abuses the alpha channel + // as blend factor, and doesn't allow us to set the alpha channel + c.color.red = c.color.red * alpha / 0xffff; + c.color.green = c.color.green * alpha / 0xffff; + c.color.blue = c.color.blue * alpha / 0xffff; + + c.pixel = insert_component (c.color.red , format->direct.redMask , format->direct.red ) + | insert_component (c.color.green, format->direct.greenMask, format->direct.green) + | insert_component (c.color.blue , format->direct.blueMask , format->direct.blue ) + | insert_component (alpha , format->direct.alphaMask, format->direct.alpha); return true; } @@ -730,9 +736,9 @@ if (screen->visual->c_class == TrueColor) { - c.pixel = (color.r >> (16 - rxvt_popcount (screen->visual->red_mask )) << rxvt_ctz (screen->visual->red_mask )) - | (color.g >> (16 - rxvt_popcount (screen->visual->green_mask)) << rxvt_ctz (screen->visual->green_mask)) - | (color.b >> (16 - rxvt_popcount (screen->visual->blue_mask )) << rxvt_ctz (screen->visual->blue_mask )); + c.pixel = (color.r >> (16 - ecb_popcount32 (screen->visual->red_mask )) << ecb_ctz32 (screen->visual->red_mask )) + | (color.g >> (16 - ecb_popcount32 (screen->visual->green_mask)) << ecb_ctz32 (screen->visual->green_mask)) + | (color.b >> (16 - ecb_popcount32 (screen->visual->blue_mask )) << ecb_ctz32 (screen->visual->blue_mask )); return true; } @@ -894,8 +900,8 @@ ); } -rxvt_selection::rxvt_selection (rxvt_display *disp, int selnum, Time tm, Window win, Atom prop, rxvt_term *term, void *cb_sv) -: display (disp), request_time (tm), request_win (win), request_prop (prop), term (term), cb_sv (cb_sv) +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); @@ -907,6 +913,7 @@ incr_buf_size = incr_buf_fill = 0; selection_wait = Sel_normal; selection_type = selnum; + cb_sv = 0; } void @@ -928,6 +935,17 @@ { int selnum = selection_type; +#if ENABLE_FRILLS + if (selnum == Sel_Primary && display->selection_owner) + { + /* internal selection */ + char *str = rxvt_wcstombs (display->selection_owner->selection.text, display->selection_owner->selection.len); + finish (str, strlen (str)); + free (str); + return; + } +#endif + #if X_HAVE_UTF8_STRING selection_type = Sel_UTF8String; if (request (display->xa[XA_UTF8_STRING], selnum)) @@ -945,7 +963,7 @@ void rxvt_selection::finish (char *data, unsigned int len) { - if (term) + if (!cb_sv) { if (data) term->paste (data, len); @@ -956,8 +974,8 @@ #if ENABLE_PERL else { - stop (); - abort (); //TODO + stop (); // we do not really trust perl callbacks + rxvt_perl.selection_finish (this, data, len); } #endif } @@ -1162,8 +1180,7 @@ case SelectionNotify: if (selection_wait == Sel_normal - && xev.xselection.time == request_time - && xev.xselection.property == request_prop) + && xev.xselection.time == request_time) { timer_ev.stop (); handle_selection (xev.xselection.requestor, xev.xselection.property, true);