--- rxvt-unicode/src/screen.C 2004/09/07 21:05:41 1.136 +++ rxvt-unicode/src/screen.C 2005/02/21 19:26:07 1.159 @@ -30,7 +30,6 @@ #include /* get the typedef for CARD32 */ #include -#include #include "salloc.C" // HACK, should be a seperate compile! @@ -41,7 +40,8 @@ } /* ------------------------------------------------------------------------- */ -#define PROP_SIZE 16384 +#define PROP_SIZE 256*1024 +#define PASTE_SIZE 32768 #define TABSIZE 8 /* default tab size */ /* ------------------------------------------------------------------------- * @@ -204,17 +204,17 @@ * Note: this is still needed so that all the scrollback lines are NULL */ screen.text = (text_t **)rxvt_calloc (total_rows, sizeof (text_t *)); - buf_text = (text_t **)rxvt_calloc (total_rows, sizeof (text_t *)); - drawn_text = (text_t **)rxvt_calloc (nrow, sizeof (text_t *)); - swap.text = (text_t **)rxvt_calloc (nrow, sizeof (text_t *)); + buf_text = (text_t **)rxvt_calloc (total_rows, sizeof (text_t *)); + drawn_text = (text_t **)rxvt_calloc (nrow, sizeof (text_t *)); + swap.text = (text_t **)rxvt_calloc (nrow, sizeof (text_t *)); screen.tlen = (int16_t *)rxvt_calloc (total_rows, sizeof (int16_t)); - swap.tlen = (int16_t *)rxvt_calloc (nrow, sizeof (int16_t)); + swap.tlen = (int16_t *)rxvt_calloc (nrow, sizeof (int16_t)); screen.rend = (rend_t **)rxvt_calloc (total_rows, sizeof (rend_t *)); - buf_rend = (rend_t **)rxvt_calloc (total_rows, sizeof (rend_t *)); - drawn_rend = (rend_t **)rxvt_calloc (nrow, sizeof (rend_t *)); - swap.rend = (rend_t **)rxvt_calloc (nrow, sizeof (rend_t *)); + buf_rend = (rend_t **)rxvt_calloc (total_rows, sizeof (rend_t *)); + drawn_rend = (rend_t **)rxvt_calloc (nrow, sizeof (rend_t *)); + swap.rend = (rend_t **)rxvt_calloc (nrow, sizeof (rend_t *)); for (p = 0; p < nrow; p++) { @@ -295,7 +295,6 @@ /* we have fewer rows so fix up cursor position */ MIN_IT (screen.cur.row, (int32_t)nrow - 1); - MIN_IT (swap.cur.row, (int32_t)nrow - 1); scr_reset_realloc (); /* realloc _last_ */ } @@ -336,13 +335,11 @@ screen.s_cur.row += k; TermWin.nscrolled -= k; } + #ifdef DEBUG_STRICT assert (screen.cur.row < TermWin.nrow); - assert (swap.cur.row < TermWin.nrow); #else /* drive with your eyes closed */ - MIN_IT (screen.cur.row, nrow - 1); - MIN_IT (swap.cur.row, nrow - 1); #endif TermWin.ncol = ncol; // save b/c scr_blank_screen_mem uses this } @@ -395,7 +392,6 @@ } MIN_IT (screen.cur.col, (int16_t)ncol - 1); - MIN_IT (swap.cur.col, (int16_t)ncol - 1); delete talloc; talloc = ta; delete ralloc; ralloc = ra; @@ -567,29 +563,28 @@ selection_check (2); /* check for boundary cross */ - SWAP_IT (current_screen, scrn, int); + i = current_screen; current_screen = scrn; scrn = i; + + SWAP_IT (screen.cur.row, swap.cur.row, int16_t); + SWAP_IT (screen.cur.col, swap.cur.col, int16_t); + MAX_IT (screen.cur.row, 0); + MIN_IT (screen.cur.row, (int32_t)prev_nrow - 1); + MAX_IT (screen.cur.col, 0); + MIN_IT (screen.cur.col, (int32_t)prev_ncol - 1); + #if NSCREENS if (options & Opt_secondaryScreen) { num_scr = 0; offset = TermWin.saveLines; + for (i = prev_nrow; i--;) { SWAP_IT (screen.text[i + offset], swap.text[i], text_t *); SWAP_IT (screen.tlen[i + offset], swap.tlen[i], int16_t); SWAP_IT (screen.rend[i + offset], swap.rend[i], rend_t *); } - SWAP_IT (screen.cur.row, swap.cur.row, int16_t); - SWAP_IT (screen.cur.col, swap.cur.col, int16_t); -# ifdef DEBUG_STRICT - assert ((screen.cur.row >= 0) && (screen.cur.row < prev_nrow)); - assert ((screen.cur.col >= 0) && (screen.cur.col < prev_ncol)); -# else /* drive with your eyes closed */ - MAX_IT (screen.cur.row, 0); - MIN_IT (screen.cur.row, (int32_t)prev_nrow - 1); - MAX_IT (screen.cur.col, 0); - MIN_IT (screen.cur.col, (int32_t)prev_ncol - 1); -# endif + SWAP_IT (screen.charset, swap.charset, int16_t); SWAP_IT (screen.flags, swap.flags, int); screen.flags |= Screen_VisibleCursor; @@ -598,8 +593,8 @@ else #endif if (options & Opt_secondaryScroll) - //if (current_screen == PRIMARY) - scr_scroll_text (0, (prev_nrow - 1), prev_nrow, 0); + scr_scroll_text (0, prev_nrow - 1, prev_nrow, 0); + return scrn; } @@ -706,8 +701,8 @@ else if (j >= row1 && j <= row2) { /* move selected region too */ - selection.beg.row -= count; - selection.end.row -= count; + selection.beg.row -= count; + selection.end.row -= count; selection.mark.row -= count; } } @@ -725,13 +720,13 @@ if (j > 0) { - /* A: scroll up */ + /* scroll up */ - /* A1: Copy lines that will get clobbered by the rotation */ + /* Copy lines that will get clobbered by the rotation */ memcpy (buf_text, screen.text + row1, count * sizeof (text_t *)); memcpy (buf_rend, screen.rend + row1, count * sizeof (rend_t *)); - /* A2: Rotate lines */ + /* Rotate lines */ i = row2 - row1 - count + 1; memmove (screen.tlen + row1, screen.tlen + row1 + count, i * sizeof (int16_t)); memmove (screen.text + row1, screen.text + row1 + count, i * sizeof (text_t *)); @@ -741,16 +736,16 @@ } else /* if (j < 0) */ { - /* B: scroll down */ + /* scroll down */ - /* B1: Copy lines that will get clobbered by the rotation */ + /* Copy lines that will get clobbered by the rotation */ for (i = 0, j = row2; i < count; i++, j--) { buf_text[i] = screen.text[j]; buf_rend[i] = screen.rend[j]; } - /* B2: Rotate lines */ + /* Rotate lines */ for (j = row2, i = j - count; i >= row1; i--, j--) { screen.tlen[j] = screen.tlen[i]; @@ -762,7 +757,7 @@ count = -count; } - /* C: Resurrect lines */ + /* Resurrect lines */ memset (screen.tlen + j, 0, i * sizeof (int16_t)); memcpy (screen.text + j, buf_text, i * sizeof (text_t *)); memcpy (screen.rend + j, buf_rend, i * sizeof (text_t *)); @@ -880,9 +875,6 @@ srp = screen.rend[row]; /* _must_ refresh */ } - if (screen.flags & Screen_Insert) - scr_insdel_chars (1, INSERT); - // rely on wcwidth to tell us the character width, at least for non-latin1 // do wcwidth before further replacements, as wcwidth says that line-drawing // characters have width -1 (DOH!) on GNU/Linux sometimes. @@ -893,7 +885,7 @@ // vt100 special graphics and line drawing // 5f-7e standard vt100 // 40-5e rxvt extension for extra curses acs chars - static uint16_t vt100_0[63] = { // 5f .. 7e + static uint16_t vt100_0[63] = { // 40 .. 7e 0x0000, 0x2191, 0x2193, 0x2192, 0x2190, 0x2588, 0x259a, 0x2603, // 40-47 hi mr. snowman! 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 48-4f 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 50-57 @@ -911,6 +903,9 @@ } } + if (screen.flags & Screen_Insert) + scr_insdel_chars (width, INSERT); + if (width != 0) { // some utf-8 decoders decode surrogate characters. @@ -970,11 +965,12 @@ while (--width > 0); // pad with spaces when overwriting wide character with smaller one - for (int c = screen.cur.col; c < last_col && stp[c] == NOCHAR; c++) - { - stp[c] = ' '; - srp[c] = rend; - } + if (!width) + for (int c = screen.cur.col; c < last_col && stp[c] == NOCHAR; c++) + { + stp[c] = ' '; + srp[c] = rend; + } } else if (width == 0) { @@ -1097,7 +1093,7 @@ // store horizontal tab commands as characters inside the text // buffer so they can be selected and pasted. - if (ht) + if (ht && options & Opt_pastableTabs) { base_rend = SET_FONT (base_rend, 0); @@ -1380,7 +1376,7 @@ } else { - ren = (rstyle & (RS_fgMask | RS_bgMask)); + ren = rstyle & (RS_fgMask | RS_bgMask); gcvalue.foreground = pix_colors[GET_BGCOLOR (rstyle)]; XChangeGC (display->display, TermWin.gc, GCForeground, &gcvalue); ERASE_ROWS (row, num); @@ -1390,14 +1386,26 @@ for (; num--; row++) { - scr_blank_screen_mem (screen.text, screen.rend, - (unsigned int) (row + row_offset), rstyle); + scr_blank_screen_mem (screen.text, screen.rend, (unsigned int) (row + row_offset), rstyle); screen.tlen[row + row_offset] = 0; - scr_blank_line (drawn_text[row], drawn_rend[row], - (unsigned int)TermWin.ncol, ren); + scr_blank_line (drawn_text[row], drawn_rend[row], (unsigned int)TermWin.ncol, ren); } } +void +rxvt_term::scr_erase_savelines () +{ + want_refresh = 1; + ZERO_SCROLLBACK (); + + for (int i = 0; i < TermWin.saveLines; ++i) + if (screen.text [i]) + { + screen.tlen[i] = 0; + scr_blank_line (screen.text [i], screen.rend [i], (unsigned int)TermWin.ncol, DEFAULT_RSTYLE); + } +} + /* ------------------------------------------------------------------------- */ /* * Fill the screen with `E's @@ -1406,8 +1414,8 @@ void rxvt_term::scr_E () { - int i, j, k; - rend_t *r1, fs; + int i, j, k; + rend_t *r1, fs; want_refresh = 1; ZERO_SCROLLBACK (); @@ -1900,10 +1908,8 @@ int n; unsigned int oldviewstart; -#ifdef DEBUG_STRICT - assert ((nlines >= 0) && (nlines <= TermWin.nrow)); -#endif oldviewstart = TermWin.view_start; + if (direction == UP) { n = TermWin.view_start + nlines; @@ -1914,6 +1920,7 @@ n = TermWin.view_start - nlines; TermWin.view_start = max (n, 0); } + return scr_changeview (oldviewstart); } @@ -2243,7 +2250,7 @@ // redraw one or more characters - // seek to the beginning if wide characters + // seek to the beginning of wide characters while (stp[col] == NOCHAR && col > 0) --col; @@ -2397,9 +2404,18 @@ font->draw (*TermWin.drawable, xpixel, ypixel, text, count, fore, back); if (rend & RS_Uline && font->descent > 1 && fore != back) - XDrawLine (display->display, drawBuffer, TermWin.gc, - xpixel, ypixel + font->ascent + 1, - xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); + { +#if ENABLE_FRILLS + if (ISSET_PIXCOLOR (Color_underline)) + XSetForeground (display->display, TermWin.gc, pix_colors[Color_underline]); + else +#endif + XSetForeground (display->display, TermWin.gc, pix_colors[fore]); + + XDrawLine (display->display, drawBuffer, TermWin.gc, + xpixel, ypixel + font->ascent + 1, + xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); + } } /* for (col....) */ } /* for (row....) */ @@ -2651,25 +2667,14 @@ * Paste a selection direct to the command fd */ void -rxvt_term::paste (const unsigned char *data, unsigned int len) +rxvt_term::paste (unsigned char *data, unsigned int len) { - unsigned int i, j, n; - unsigned char *ds = (unsigned char *)rxvt_malloc (PROP_SIZE); - /* convert normal newline chars into common keyboard Return key sequence */ - for (i = 0; i < len; i += PROP_SIZE) - { - n = min (len - i, PROP_SIZE); - memcpy (ds, data + i, n); - - for (j = 0; j < n; j++) - if (ds[j] == C0_LF) - ds[j] = C0_CR; + for (unsigned int i = 0; i < len; i++) + if (data[i] == C0_LF) + data[i] = C0_CR; - tt_write (ds, (int)n); - } - - free (ds); + tt_write (data, len); } /* ------------------------------------------------------------------------- */ @@ -2677,13 +2682,9 @@ * Respond to a notification that a primary selection has been sent * EXT: SelectionNotify */ -int +void rxvt_term::selection_paste (Window win, Atom prop, bool delete_prop) { - long nread = 0; - unsigned long bytes_after; - XTextProperty ct; - if (prop == None) /* check for failed XConvertSelection */ { if ((selection_type & Sel_CompoundText)) @@ -2706,36 +2707,80 @@ selection_type = 0; } - return 0; + return; } - for (;;) + unsigned long bytes_after; + XTextProperty ct; + + if (XGetWindowProperty (display->display, win, prop, + 0, PROP_SIZE / 4, + delete_prop, AnyPropertyType, + &ct.encoding, &ct.format, + &ct.nitems, &bytes_after, + &ct.value) != Success) { - if (XGetWindowProperty (display->display, win, prop, (long) (nread / 4), - (long) (PROP_SIZE / 4), delete_prop, - AnyPropertyType, &ct.encoding, &ct.format, - &ct.nitems, &bytes_after, - &ct.value) != Success) - break; + ct.value = 0; + goto bailout; + } - if (ct.encoding == 0) - break; + if (ct.encoding == None) + goto bailout; - if (ct.encoding == xa[XA_INCR]) - { - // INCR selection, start handshake - XDeleteProperty (display->display, win, prop); - selection_wait = Sel_incr; - incr_ev.start (NOW + 10); - break; - } + if (bytes_after) + { + // fetch and append remaining data + XTextProperty ct2; + + if (XGetWindowProperty (display->display, win, prop, + ct.nitems / 4, (bytes_after + 3) / 4, + delete_prop, AnyPropertyType, + &ct2.encoding, &ct2.format, + &ct2.nitems, &bytes_after, + &ct2.value) != Success) + goto bailout; + + // realloc should be compatible to XFree, here, and elsewhere, too + ct.value = (unsigned char *)realloc (ct.value, ct.nitems + ct2.nitems + 1); + memcpy (ct.value + ct.nitems, ct2.value, ct2.nitems + 1); + ct.nitems += ct2.nitems; - if (ct.value == NULL) - continue; + XFree (ct2.value); + } + + if (ct.value == 0) + goto bailout; + + if (ct.encoding == xa[XA_INCR]) + { + // INCR selection, start handshake + if (!delete_prop) + XDeleteProperty (display->display, win, prop); - if (ct.nitems == 0) + selection_wait = Sel_incr; + incr_buf_fill = 0; + incr_ev.start (NOW + 10); + + goto bailout; + } + + if (ct.nitems == 0) + { + if (selection_wait == Sel_incr) + { + XFree (ct.value); + + // finally complete, now paste the whole thing + selection_wait = Sel_normal; + ct.value = (unsigned char *)incr_buf; + ct.nitems = incr_buf_fill; + incr_buf = 0; + incr_buf_size = 0; + incr_ev.stop (); + } + else { - if (selection_wait == Sel_normal && nread == 0 + if (selection_wait == Sel_normal && (win != display->root || prop != XA_CUT_BUFFER0)) // avoid recursion { /* @@ -2745,37 +2790,58 @@ selection_paste (display->root, XA_CUT_BUFFER0, False); } - nread = -1; /* discount any previous stuff */ - break; + goto bailout; } + } + else if (selection_wait == Sel_incr) + { + incr_ev.start (NOW + 10); - nread += ct.nitems; - - char **cl; - int cr; - if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 && cl) + while (incr_buf_fill + ct.nitems > incr_buf_size) { - for (int i = 0; i < cr; i++) - paste ((unsigned char *)cl[i], strlen (cl[i])); - - XFreeStringList (cl); + incr_buf_size = incr_buf_size ? incr_buf_size * 2 : 128*1024; + incr_buf = (char *)realloc (incr_buf, incr_buf_size); } - else - paste (ct.value, ct.nitems); - if (bytes_after == 0) - break; + memcpy (incr_buf + incr_buf_fill, ct.value, ct.nitems); + incr_buf_fill += ct.nitems; - XFree (ct.value); + goto bailout; } - if (ct.value) - XFree (ct.value); + char **cl; + int cr; + +#if ENABLE_FRILLS + // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it + // so recode it manually + if (ct.encoding == xa[XA_UTF8_STRING]) + { + wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems); + char *s = rxvt_wcstombs (w); + free (w); + // TODO: strlen == only the first element will be converted. well... + paste ((unsigned char *)s, strlen (s)); + free (s); + } + else +#endif + if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 + && cl) + { + for (int i = 0; i < cr; i++) + paste ((unsigned char *)cl[i], strlen (cl[i])); + + XFreeStringList (cl); + } + else + paste (ct.value, ct.nitems); // paste raw + +bailout: + XFree (ct.value); if (selection_wait == Sel_normal) selection_wait = Sel_none; - - return (int)nread; } void @@ -2783,25 +2849,19 @@ { selection_wait = Sel_none; + incr_buf_size = 0; + free (incr_buf); + rxvt_warn ("data loss: timeout on INCR selection paste, ignoring.\n"); } -/* - * INCR support originally provided by Paul Sheer - */ void rxvt_term::selection_property (Window win, Atom prop) { if (prop == None || selection_wait != Sel_incr) return; - if (selection_paste (win, prop, 1) > 0) - incr_ev.start (NOW + 10); - else - { - selection_wait = Sel_none; - incr_ev.stop (); - } + selection_paste (win, prop, true); } /* ------------------------------------------------------------------------- */ @@ -2845,12 +2905,11 @@ if (selection_request_other (xa[XA_COMPOUND_TEXT], i)) return; #endif - } } - selection_wait = Sel_none; /* don't loop in rxvt_selection_paste () */ - selection_paste (display->root, XA_CUT_BUFFER0, False); + selection_wait = Sel_none; /* don't loop in selection_paste () */ + selection_paste (display->root, XA_CUT_BUFFER0, false); } int @@ -3016,8 +3075,7 @@ if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) { - XChangeProperty (display->display, display->root, XA_CUT_BUFFER0, XA_STRING, 8, - PropModeReplace, ct.value, ct.nitems); + set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); XFree (ct.value); } #endif @@ -3365,11 +3423,11 @@ else if (selection.clicks == 3) { #if ENABLE_FRILLS - if ((options & Opt_tripleclickwords)) + if (options & Opt_tripleclickwords) { int end_row; - selection_delimit_word (UP, & (selection.beg), & (selection.beg)); + selection_delimit_word (UP, &selection.beg, &selection.beg); end_row = screen.tlen[selection.mark.row + TermWin.saveLines]; for (end_row = selection.mark.row; end_row < TermWin.nrow; end_row++) @@ -3393,6 +3451,15 @@ selection.beg.col = 0; selection.end.col = ncol; + + // select a complete logical line + while (selection.beg.row > -TermWin.saveLines + && screen.tlen[selection.beg.row - 1 + TermWin.saveLines] == -1) + selection.beg.row--; + + while (selection.end.row < TermWin.nrow + && screen.tlen[selection.end.row + TermWin.saveLines] == -1) + selection.end.row++; } } @@ -3475,14 +3542,6 @@ /* ------------------------------------------------------------------------- */ /* - * On some systems, the Atom typedef is 64 bits wide. We need to have a type - * that is exactly 32 bits wide, because a format of 64 is not allowed by - * the X11 protocol. - */ -typedef CARD32 Atom32; - -/* ------------------------------------------------------------------------- */ -/* * Respond to a request for our current selection * EXT: SelectionRequest */ @@ -3490,9 +3549,7 @@ rxvt_term::selection_send (const XSelectionRequestEvent &rq) { XSelectionEvent ev; - XTextProperty ct; - XICCEncodingStyle style; - Atom target; + dDisp; ev.type = SelectionNotify; ev.property = None; @@ -3504,22 +3561,21 @@ if (rq.target == xa[XA_TARGETS]) { - Atom32 target_list[6]; - Atom32 *target = target_list; + Atom target_list[6]; + Atom *target = target_list; - *target++ = (Atom32) xa[XA_TARGETS]; - *target++ = (Atom32) xa[XA_TIMESTAMP]; - *target++ = (Atom32) XA_STRING; - *target++ = (Atom32) xa[XA_TEXT]; - *target++ = (Atom32) xa[XA_COMPOUND_TEXT]; + *target++ = xa[XA_TARGETS]; + *target++ = xa[XA_TIMESTAMP]; + *target++ = XA_STRING; + *target++ = xa[XA_TEXT]; + *target++ = xa[XA_COMPOUND_TEXT]; #if X_HAVE_UTF8_STRING - *target++ = (Atom32) xa[XA_UTF8_STRING]; + *target++ = xa[XA_UTF8_STRING]; #endif - XChangeProperty (display->display, rq.requestor, rq.property, XA_ATOM, - (8 * sizeof (target_list[0])), PropModeReplace, - (unsigned char *)target_list, - target - target_list); + XChangeProperty (disp, rq.requestor, rq.property, XA_ATOM, + 32, PropModeReplace, + (unsigned char *)target_list, target - target_list); ev.property = rq.property; } #if TODO // TODO @@ -3530,9 +3586,8 @@ #endif else if (rq.target == xa[XA_TIMESTAMP] && selection.text) { - XChangeProperty (display->display, rq.requestor, rq.property, XA_INTEGER, - (8 * sizeof (Time)), PropModeReplace, - (unsigned char *)&selection_time, 1); + XChangeProperty (disp, rq.requestor, rq.property, rq.target, + 32, PropModeReplace, (unsigned char *)&selection_time, 1); ev.property = rq.property; } else if (rq.target == XA_STRING @@ -3541,28 +3596,38 @@ || rq.target == xa[XA_UTF8_STRING] ) { + XTextProperty ct; + Atom target = rq.target; short freect = 0; int selectlen; wchar_t *cl; - - target = rq.target; + enum { + enc_string = XStringStyle, + enc_text = XStdICCTextStyle, + enc_compound_text = XCompoundTextStyle, +#ifdef X_HAVE_UTF8_STRING + enc_utf8 = XUTF8StringStyle, +#else + enc_utf8 = -1, +#endif + } style; if (target == XA_STRING) // we actually don't do XA_STRING, but who cares, as i18n clients // will ask for another format anyways. - style = XStringStyle; + style = enc_string; else if (target == xa[XA_TEXT]) - style = XStdICCTextStyle; + style = enc_text; else if (target == xa[XA_COMPOUND_TEXT]) - style = XCompoundTextStyle; -#if X_HAVE_UTF8_STRING + style = enc_compound_text; +#if ENABLE_FRILLS else if (target == xa[XA_UTF8_STRING]) - style = XUTF8StringStyle; + style = enc_utf8; #endif else { target = xa[XA_COMPOUND_TEXT]; - style = XCompoundTextStyle; + style = enc_compound_text; } if (selection.text) @@ -3576,19 +3641,31 @@ selectlen = 0; } - // Xwc doesn't handle iso-10646 in wchar_t gracefully, so maybe recode it - // manually for XUTF8StringStyle. - if (XwcTextListToTextProperty (display->display, &cl, 1, style, &ct) >= 0) +#if ENABLE_FRILLS + // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it + // so recode it manually + if (style == enc_utf8) + { + freect = 1; + ct.encoding = target; + ct.format = 8; + ct.value = (unsigned char *)rxvt_wcstoutf8 (cl, selectlen); + ct.nitems = strlen ((char *)ct.value); + } + else +#endif + if (XwcTextListToTextProperty (disp, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0) freect = 1; else { /* if we failed to convert then send it raw */ ct.value = (unsigned char *)cl; ct.nitems = selectlen; + ct.encoding = target; } - XChangeProperty (display->display, rq.requestor, rq.property, - target, 8, PropModeReplace, + XChangeProperty (disp, rq.requestor, rq.property, + ct.encoding, 8, PropModeReplace, ct.value, (int)ct.nitems); ev.property = rq.property; @@ -3596,7 +3673,7 @@ XFree (ct.value); } - XSendEvent (display->display, rq.requestor, False, 0L, (XEvent *)&ev); + XSendEvent (disp, rq.requestor, False, 0L, (XEvent *)&ev); } /* ------------------------------------------------------------------------- *