… | |
… | |
1649 | /* ------------------------------------------------------------------------- * |
1649 | /* ------------------------------------------------------------------------- * |
1650 | * MAJOR SCREEN MANIPULATION * |
1650 | * MAJOR SCREEN MANIPULATION * |
1651 | * ------------------------------------------------------------------------- */ |
1651 | * ------------------------------------------------------------------------- */ |
1652 | |
1652 | |
1653 | /* |
1653 | /* |
|
|
1654 | * refresh matching text. |
|
|
1655 | */ |
|
|
1656 | bool |
|
|
1657 | rxvt_term::scr_refresh_rend (rend_t mask, rend_t value) |
|
|
1658 | { |
|
|
1659 | bool found = false; |
|
|
1660 | |
|
|
1661 | for (int i = 0; i < TermWin.nrow; i++) |
|
|
1662 | { |
|
|
1663 | int col = 0; |
|
|
1664 | rend_t *drp = drawn_rend [i]; |
|
|
1665 | |
|
|
1666 | for (; col < TermWin.ncol; col++, drp++) |
|
|
1667 | if ((*drp & mask) == value) |
|
|
1668 | { |
|
|
1669 | found = true; |
|
|
1670 | *drp = ~value; |
|
|
1671 | } |
|
|
1672 | } |
|
|
1673 | |
|
|
1674 | return found; |
|
|
1675 | } |
|
|
1676 | |
|
|
1677 | /* |
1654 | * Refresh an area |
1678 | * Refresh an area |
1655 | */ |
1679 | */ |
1656 | enum { |
1680 | enum { |
1657 | PART_BEG = 0, |
1681 | PART_BEG = 0, |
1658 | PART_END, |
1682 | PART_END, |
… | |
… | |
1870 | /* |
1894 | /* |
1871 | * A: set up vars |
1895 | * A: set up vars |
1872 | */ |
1896 | */ |
1873 | clearfirst = clearlast = must_clear = 0; |
1897 | clearfirst = clearlast = must_clear = 0; |
1874 | |
1898 | |
1875 | if (currmaxcol < TermWin.ncol) |
|
|
1876 | { |
|
|
1877 | currmaxcol = TermWin.ncol; |
|
|
1878 | buffer = (char *)rxvt_realloc (buffer, |
|
|
1879 | sizeof(char) * (currmaxcol + 1) * MB_CUR_MAX); |
|
|
1880 | } |
|
|
1881 | |
|
|
1882 | refresh_count = 0; |
1899 | refresh_count = 0; |
1883 | |
1900 | |
1884 | row_offset = TermWin.saveLines - TermWin.view_start; |
1901 | row_offset = TermWin.saveLines - TermWin.view_start; |
1885 | |
1902 | |
1886 | if ((refresh_type & REFRESH_BOUNDS)) |
1903 | if ((refresh_type & REFRESH_BOUNDS)) |
… | |
… | |
1929 | if (showcursor && TermWin.focus) |
1946 | if (showcursor && TermWin.focus) |
1930 | { |
1947 | { |
1931 | *srp ^= RS_RVid; |
1948 | *srp ^= RS_RVid; |
1932 | #ifndef NO_CURSORCOLOR |
1949 | #ifndef NO_CURSORCOLOR |
1933 | cc1 = *srp & (RS_fgMask | RS_bgMask); |
1950 | cc1 = *srp & (RS_fgMask | RS_bgMask); |
1934 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor)) |
1951 | if (ISSET_PIXCOLOR (this, Color_cursor)) |
1935 | ccol1 = Color_cursor; |
1952 | ccol1 = Color_cursor; |
1936 | else |
1953 | else |
1937 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1954 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1938 | ccol1 = GET_FGCOLOR(rstyle); |
1955 | ccol1 = GET_FGCOLOR(rstyle); |
1939 | #else |
1956 | #else |
1940 | ccol1 = Color_fg; |
1957 | ccol1 = Color_fg; |
1941 | #endif |
1958 | #endif |
1942 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor2)) |
1959 | if (ISSET_PIXCOLOR (this, Color_cursor2)) |
1943 | ccol2 = Color_cursor2; |
1960 | ccol2 = Color_cursor2; |
1944 | else |
1961 | else |
1945 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1962 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1946 | ccol2 = GET_BGCOLOR(rstyle); |
1963 | ccol2 = GET_BGCOLOR(rstyle); |
1947 | #else |
1964 | #else |
… | |
… | |
2133 | int back = GET_BGCOLOR (rend); // desired background |
2150 | int back = GET_BGCOLOR (rend); // desired background |
2134 | |
2151 | |
2135 | rend = GET_ATTR (rend); |
2152 | rend = GET_ATTR (rend); |
2136 | |
2153 | |
2137 | rvid = !!(rend & RS_RVid); |
2154 | rvid = !!(rend & RS_RVid); |
2138 | #ifdef OPTION_HC |
2155 | #ifdef TEXT_BLINK |
2139 | if (!rvid && (rend & RS_Blink)) |
2156 | if (rend & RS_Blink) |
2140 | { |
2157 | { |
2141 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_HC)) |
2158 | if (!text_blink_ev.active) |
2142 | back = Color_HC; |
|
|
2143 | else |
2159 | { |
2144 | rvid = !rvid; /* fall back */ |
2160 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
2161 | hidden_text = 0; |
|
|
2162 | } |
|
|
2163 | else if (hidden_text) |
|
|
2164 | fore = back; |
2145 | } |
2165 | } |
2146 | #endif |
2166 | #endif |
2147 | if (rvid) |
2167 | if (rvid) |
2148 | { |
2168 | { |
2149 | SWAP_IT(fore, back, int); |
2169 | SWAP_IT(fore, back, int); |
2150 | |
2170 | |
2151 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2171 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2152 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_RV) |
2172 | if (ISSET_PIXCOLOR (this, Color_RV) |
2153 | # ifndef NO_CURSORCOLOR |
2173 | # ifndef NO_CURSORCOLOR |
2154 | && !ISSET_PIXCOLOR (this, Color_cursor) |
2174 | && !ISSET_PIXCOLOR (this, Color_cursor) |
2155 | # endif |
2175 | # endif |
2156 | ) |
2176 | ) |
2157 | back = Color_RV; |
2177 | back = Color_RV; |
2158 | #endif |
2178 | #endif |
2159 | } |
2179 | } |
2160 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2180 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2161 | else if (rend & RS_Bold) |
2181 | else if (rend & RS_Bold) |
2162 | { |
2182 | { |
2163 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_BD)) |
2183 | if (ISSET_PIXCOLOR (this, Color_BD)) |
2164 | fore = Color_BD; |
2184 | fore = Color_BD; |
|
|
2185 | else if (fore == Color_fg) |
|
|
2186 | fore = Color_White; |
2165 | } |
2187 | } |
2166 | else if (rend & RS_Uline) |
2188 | else if (rend & RS_Uline) |
2167 | { |
2189 | { |
2168 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_UL)) |
2190 | if (ISSET_PIXCOLOR (this, Color_UL)) |
2169 | fore = Color_UL; |
2191 | fore = Color_UL; |
2170 | } |
2192 | } |
2171 | #endif |
2193 | #endif |
2172 | |
2194 | |
2173 | /* |
2195 | /* |
… | |
… | |
2215 | #endif |
2237 | #endif |
2216 | } else if (oldcursor.row >= 0) { |
2238 | } else if (oldcursor.row >= 0) { |
2217 | #ifndef NO_CURSORCOLOR |
2239 | #ifndef NO_CURSORCOLOR |
2218 | unsigned long gcmask; /* Graphics Context mask */ |
2240 | unsigned long gcmask; /* Graphics Context mask */ |
2219 | |
2241 | |
2220 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor)) |
2242 | if (ISSET_PIXCOLOR (this, Color_cursor)) |
2221 | XSetForeground (Xdisplay, TermWin.gc, PixColors[Color_cursor]); |
2243 | XSetForeground (Xdisplay, TermWin.gc, PixColors[Color_cursor]); |
2222 | #endif |
2244 | #endif |
2223 | XDrawRectangle(Xdisplay, drawBuffer, TermWin.gc, |
2245 | XDrawRectangle(Xdisplay, drawBuffer, TermWin.gc, |
2224 | Col2Pixel(oldcursor.col), |
2246 | Col2Pixel(oldcursor.col), |
2225 | Row2Pixel(oldcursor.row), |
2247 | Row2Pixel(oldcursor.row), |
… | |
… | |
2308 | i = end_row; |
2330 | i = end_row; |
2309 | } |
2331 | } |
2310 | end_row += R->TermWin.nrow; |
2332 | end_row += R->TermWin.nrow; |
2311 | for (; i < row && i < end_row; i++, col = 0) |
2333 | for (; i < row && i < end_row; i++, col = 0) |
2312 | for (srp = R->screen.rend[i]; col < R->TermWin.ncol; col++) |
2334 | for (srp = R->screen.rend[i]; col < R->TermWin.ncol; col++) |
2313 | #ifndef OPTION_HC |
|
|
2314 | srp[col] ^= RS_RVid; |
2335 | srp[col] ^= RS_RVid; |
2315 | #else |
|
|
2316 | srp[col] ^= RS_Blink; |
|
|
2317 | #endif |
|
|
2318 | if (i == row && i < end_row) |
2336 | if (i == row && i < end_row) |
2319 | for (srp = R->screen.rend[i]; col < R->selection.end.col; col++) |
2337 | for (srp = R->screen.rend[i]; col < R->selection.end.col; col++) |
2320 | #ifndef OPTION_HC |
|
|
2321 | srp[col] ^= RS_RVid; |
2338 | srp[col] ^= RS_RVid; |
2322 | #else |
|
|
2323 | srp[col] ^= RS_Blink; |
|
|
2324 | #endif |
|
|
2325 | } |
2339 | } |
2326 | } |
2340 | } |
2327 | |
2341 | |
2328 | /* ------------------------------------------------------------------------- */ |
2342 | /* ------------------------------------------------------------------------- */ |
2329 | /* |
2343 | /* |
… | |
… | |
2435 | rxvt_selection_paste(pR_ Window win, Atom prop, Bool delete_prop) |
2449 | rxvt_selection_paste(pR_ Window win, Atom prop, Bool delete_prop) |
2436 | { |
2450 | { |
2437 | long nread = 0; |
2451 | long nread = 0; |
2438 | unsigned long bytes_after; |
2452 | unsigned long bytes_after; |
2439 | XTextProperty ct; |
2453 | XTextProperty ct; |
2440 | int dummy_count; |
|
|
2441 | char **cl; |
|
|
2442 | |
2454 | |
2443 | D_SELECT((stderr, "rxvt_selection_paste(%08lx, %lu, %d), wait=%2x", win, (unsigned long)prop, (int)delete_prop, R->selection_wait)); |
2455 | D_SELECT((stderr, "rxvt_selection_paste(%08lx, %lu, %d), wait=%2x", win, (unsigned long)prop, (int)delete_prop, R->selection_wait)); |
2444 | |
2456 | |
2445 | if (prop == None) /* check for failed XConvertSelection */ |
2457 | if (prop == None) /* check for failed XConvertSelection */ |
2446 | { |
2458 | { |
… | |
… | |
2449 | int selnum = R->selection_type & Sel_whereMask; |
2461 | int selnum = R->selection_type & Sel_whereMask; |
2450 | |
2462 | |
2451 | R->selection_type = 0; |
2463 | R->selection_type = 0; |
2452 | if (selnum != Sel_direct) |
2464 | if (selnum != Sel_direct) |
2453 | rxvt_selection_request_other(aR_ XA_STRING, selnum); |
2465 | rxvt_selection_request_other(aR_ XA_STRING, selnum); |
|
|
2466 | } |
|
|
2467 | |
|
|
2468 | if ((R->selection_type & Sel_UTF8String)) |
|
|
2469 | { |
|
|
2470 | int selnum = R->selection_type & Sel_whereMask; |
|
|
2471 | |
|
|
2472 | R->selection_type = Sel_CompoundText; |
|
|
2473 | if (selnum != Sel_direct) |
|
|
2474 | rxvt_selection_request_other(aR_ R->xa[XA_COMPOUND_TEXT], selnum); |
|
|
2475 | else |
|
|
2476 | R->selection_type = 0; |
2454 | } |
2477 | } |
2455 | |
2478 | |
2456 | return 0; |
2479 | return 0; |
2457 | } |
2480 | } |
2458 | |
2481 | |
… | |
… | |
2493 | nread = -1; /* discount any previous stuff */ |
2516 | nread = -1; /* discount any previous stuff */ |
2494 | break; |
2517 | break; |
2495 | } |
2518 | } |
2496 | |
2519 | |
2497 | nread += ct.nitems; |
2520 | nread += ct.nitems; |
|
|
2521 | |
|
|
2522 | char **cl; |
|
|
2523 | int cr; |
2498 | if (XmbTextPropertyToTextList (R->Xdisplay, &ct, &cl, |
2524 | if (XmbTextPropertyToTextList (R->Xdisplay, &ct, &cl, |
2499 | &dummy_count) == Success && cl) |
2525 | &cr) >= 0 && cl) |
2500 | { |
2526 | { |
|
|
2527 | for (int i = 0; i < cr; i++) |
2501 | R->paste ((unsigned char *)cl[0], STRLEN (cl[0])); |
2528 | R->paste ((unsigned char *)cl[i], STRLEN (cl[i])); |
|
|
2529 | |
2502 | XFreeStringList (cl); |
2530 | XFreeStringList (cl); |
2503 | } |
2531 | } |
2504 | else |
2532 | else |
2505 | R->paste (ct.value, ct.nitems); |
2533 | R->paste (ct.value, ct.nitems); |
2506 | |
2534 | |
… | |
… | |
2599 | int i; |
2627 | int i; |
2600 | |
2628 | |
2601 | R->selection_request_time = tm; |
2629 | R->selection_request_time = tm; |
2602 | R->selection_wait = Sel_normal; |
2630 | R->selection_wait = Sel_normal; |
2603 | for (i = Sel_Primary; i <= Sel_Clipboard; i++) { |
2631 | for (i = Sel_Primary; i <= Sel_Clipboard; i++) { |
|
|
2632 | #if X_HAVE_UTF8_STRING |
|
|
2633 | R->selection_type = Sel_UTF8String; |
|
|
2634 | if (rxvt_selection_request_other(aR_ R->xa[XA_UTF8_STRING], i)) |
|
|
2635 | return; |
|
|
2636 | #else |
2604 | R->selection_type = Sel_CompoundText; |
2637 | R->selection_type = Sel_CompoundText; |
2605 | if (rxvt_selection_request_other(aR_ R->xa[XA_COMPOUND_TEXT], i)) |
2638 | if (rxvt_selection_request_other(aR_ R->xa[XA_COMPOUND_TEXT], i)) |
2606 | return; |
2639 | return; |
|
|
2640 | #endif |
2607 | } |
2641 | } |
2608 | } |
2642 | } |
2609 | R->selection_wait = Sel_none; /* don't loop in rxvt_selection_paste() */ |
2643 | R->selection_wait = Sel_none; /* don't loop in rxvt_selection_paste() */ |
2610 | D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); |
2644 | D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); |
2611 | rxvt_selection_paste(aR_ Xroot, XA_CUT_BUFFER0, False); |
2645 | rxvt_selection_paste(aR_ Xroot, XA_CUT_BUFFER0, False); |
… | |
… | |
2743 | { |
2777 | { |
2744 | free (new_selection_text); |
2778 | free (new_selection_text); |
2745 | return; |
2779 | return; |
2746 | } |
2780 | } |
2747 | |
2781 | |
2748 | // due to MB_MAX_CUR, selection wastage is usually high |
2782 | // due to MB_MAX_CUR, selection wastage is usually high, so realloc |
2749 | if (str - (char *)new_selection_text > 1024) |
2783 | if (str - (char *)new_selection_text > 1024) |
2750 | new_selection_text = (unsigned char *)rxvt_realloc (new_selection_text, i + 1); |
2784 | new_selection_text = (unsigned char *)rxvt_realloc (new_selection_text, i + 1); |
2751 | |
2785 | |
2752 | R->selection.len = i; |
2786 | R->selection.len = i; |
|
|
2787 | |
2753 | if (R->selection.text) |
2788 | if (R->selection.text) |
2754 | free (R->selection.text); |
2789 | free (R->selection.text); |
2755 | |
2790 | |
2756 | R->selection.text = new_selection_text; |
2791 | R->selection.text = new_selection_text; |
2757 | |
2792 | |
2758 | XSetSelectionOwner(R->Xdisplay, XA_PRIMARY, R->TermWin.vt, tm); |
2793 | XSetSelectionOwner(R->Xdisplay, XA_PRIMARY, R->TermWin.vt, tm); |
2759 | if (XGetSelectionOwner(R->Xdisplay, XA_PRIMARY) != R->TermWin.vt) |
2794 | if (XGetSelectionOwner(R->Xdisplay, XA_PRIMARY) != R->TermWin.vt) |
2760 | rxvt_print_error("can't get primary selection"); |
2795 | rxvt_print_error("can't get primary selection"); |
|
|
2796 | |
|
|
2797 | |
|
|
2798 | { |
|
|
2799 | XTextProperty ct; |
|
|
2800 | char *cl = (char *)R->selection.text; |
|
|
2801 | |
|
|
2802 | if (XmbTextListToTextProperty(R->Xdisplay, &cl, 1, XStringStyle, &ct) >= 0) |
|
|
2803 | { |
|
|
2804 | XChangeProperty(R->Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, |
|
|
2805 | PropModeReplace, ct.value, ct.nitems); |
|
|
2806 | XFree (ct.value); |
|
|
2807 | } |
|
|
2808 | else |
2761 | XChangeProperty(R->Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, |
2809 | XChangeProperty(R->Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, |
2762 | PropModeReplace, R->selection.text, (int)R->selection.len); |
2810 | PropModeReplace, R->selection.text, (int)R->selection.len); |
|
|
2811 | } |
|
|
2812 | |
2763 | R->selection_time = tm; |
2813 | R->selection_time = tm; |
2764 | D_SELECT((stderr, "rxvt_selection_make(): R->selection.len=%d", R->selection.len)); |
2814 | D_SELECT((stderr, "rxvt_selection_make(): R->selection.len=%d", R->selection.len)); |
2765 | } |
2815 | } |
2766 | |
2816 | |
2767 | /* ------------------------------------------------------------------------- */ |
2817 | /* ------------------------------------------------------------------------- */ |
… | |
… | |
3219 | /* |
3269 | /* |
3220 | * On some systems, the Atom typedef is 64 bits wide. We need to have a type |
3270 | * On some systems, the Atom typedef is 64 bits wide. We need to have a type |
3221 | * that is exactly 32 bits wide, because a format of 64 is not allowed by |
3271 | * that is exactly 32 bits wide, because a format of 64 is not allowed by |
3222 | * the X11 protocol. |
3272 | * the X11 protocol. |
3223 | */ |
3273 | */ |
3224 | typedef CARD32 Atom32; |
3274 | typedef CARD32 Atom32; |
3225 | |
3275 | |
3226 | /* ------------------------------------------------------------------------- */ |
3276 | /* ------------------------------------------------------------------------- */ |
3227 | /* |
3277 | /* |
3228 | * Respond to a request for our current selection |
3278 | * Respond to a request for our current selection |
3229 | * EXT: SelectionRequest |
3279 | * EXT: SelectionRequest |
… | |
… | |
3231 | /* EXTPROTO */ |
3281 | /* EXTPROTO */ |
3232 | void |
3282 | void |
3233 | rxvt_selection_send(pR_ const XSelectionRequestEvent *rq) |
3283 | rxvt_selection_send(pR_ const XSelectionRequestEvent *rq) |
3234 | { |
3284 | { |
3235 | XSelectionEvent ev; |
3285 | XSelectionEvent ev; |
3236 | #ifdef USE_XIM |
|
|
3237 | Atom32 target_list[4]; |
|
|
3238 | #else |
|
|
3239 | Atom32 target_list[3]; |
|
|
3240 | #endif |
|
|
3241 | Atom target; |
|
|
3242 | XTextProperty ct; |
3286 | XTextProperty ct; |
3243 | XICCEncodingStyle style; |
3287 | XICCEncodingStyle style; |
3244 | char *cl[2], dummy[1]; |
3288 | Atom target; |
3245 | |
3289 | |
3246 | ev.type = SelectionNotify; |
3290 | ev.type = SelectionNotify; |
3247 | ev.property = None; |
3291 | ev.property = None; |
3248 | ev.display = rq->display; |
3292 | ev.display = rq->display; |
3249 | ev.requestor = rq->requestor; |
3293 | ev.requestor = rq->requestor; |
3250 | ev.selection = rq->selection; |
3294 | ev.selection = rq->selection; |
3251 | ev.target = rq->target; |
3295 | ev.target = rq->target; |
3252 | ev.time = rq->time; |
3296 | ev.time = rq->time; |
3253 | |
3297 | |
3254 | if (rq->target == R->xa[XA_TARGETS]) { |
3298 | if (rq->target == R->xa[XA_TARGETS]) { |
|
|
3299 | Atom32 target_list[5]; |
|
|
3300 | Atom32 *target = target_list; |
|
|
3301 | |
3255 | target_list[0] = (Atom32) R->xa[XA_TARGETS]; |
3302 | *target++ = (Atom32) R->xa[XA_TARGETS]; |
3256 | target_list[1] = (Atom32) XA_STRING; |
3303 | *target++ = (Atom32) XA_STRING; |
3257 | target_list[2] = (Atom32) R->xa[XA_TEXT]; |
3304 | *target++ = (Atom32) R->xa[XA_TEXT]; |
3258 | #ifdef USE_XIM |
|
|
3259 | target_list[3] = (Atom32) R->xa[XA_COMPOUND_TEXT]; |
3305 | *target++ = (Atom32) R->xa[XA_COMPOUND_TEXT]; |
|
|
3306 | #if X_HAVE_UTF8_STRING |
|
|
3307 | *target++ = (Atom32) R->xa[XA_UTF8_STRING]; |
3260 | #endif |
3308 | #endif |
3261 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_ATOM, |
3309 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_ATOM, |
3262 | (8 * sizeof(target_list[0])), PropModeReplace, |
3310 | (8 * sizeof(target_list[0])), PropModeReplace, |
3263 | (unsigned char *)target_list, |
3311 | (unsigned char *)target_list, |
3264 | (sizeof(target_list) / sizeof(target_list[0]))); |
3312 | target - target_list); |
3265 | ev.property = rq->property; |
3313 | ev.property = rq->property; |
3266 | } else if (rq->target == R->xa[XA_MULTIPLE]) { |
3314 | } else if (rq->target == R->xa[XA_MULTIPLE]) { |
3267 | /* TODO: Handle MULTIPLE */ |
3315 | /* TODO: Handle MULTIPLE */ |
3268 | } else if (rq->target == R->xa[XA_TIMESTAMP] && R->selection.text) { |
3316 | } else if (rq->target == R->xa[XA_TIMESTAMP] && R->selection.text) { |
3269 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_INTEGER, |
3317 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_INTEGER, |
3270 | (8 * sizeof(Time)), PropModeReplace, |
3318 | (8 * sizeof(Time)), PropModeReplace, |
3271 | (unsigned char *)&R->selection_time, 1); |
3319 | (unsigned char *)&R->selection_time, 1); |
3272 | ev.property = rq->property; |
3320 | ev.property = rq->property; |
3273 | } else if (rq->target == XA_STRING |
3321 | } else if (rq->target == XA_STRING |
|
|
3322 | || rq->target == R->xa[XA_TEXT] |
3274 | || rq->target == R->xa[XA_COMPOUND_TEXT] |
3323 | || rq->target == R->xa[XA_COMPOUND_TEXT] |
3275 | || rq->target == R->xa[XA_TEXT]) { |
3324 | || rq->target == R->xa[XA_UTF8_STRING] |
3276 | #ifdef USE_XIM |
3325 | ) { |
3277 | short freect = 0; |
3326 | short freect = 0; |
3278 | #endif |
|
|
3279 | int selectlen; |
3327 | int selectlen; |
|
|
3328 | char *cl; |
3280 | |
3329 | |
3281 | #ifdef USE_XIM |
3330 | target = rq->target; |
|
|
3331 | |
3282 | if (rq->target != XA_STRING) { |
3332 | if (target == XA_STRING) |
|
|
3333 | // we actually don't do XA_STRING, but who cares, as i18n clients |
|
|
3334 | // will ask for another format anyways. |
|
|
3335 | style = XStringStyle; |
|
|
3336 | else if (target == R->xa[XA_TEXT]) |
|
|
3337 | style = XTextStyle; |
|
|
3338 | else if (target == R->xa[XA_COMPOUND_TEXT]) |
|
|
3339 | style = XCompoundTextStyle; |
|
|
3340 | #if X_HAVE_UTF8_STRING |
|
|
3341 | else if (target == R->xa[XA_UTF8_STRING]) |
|
|
3342 | style = XUTF8StringStyle; |
|
|
3343 | #endif |
|
|
3344 | else |
|
|
3345 | { |
3283 | target = R->xa[XA_COMPOUND_TEXT]; |
3346 | target = R->xa[XA_COMPOUND_TEXT]; |
3284 | style = (rq->target == R->xa[XA_COMPOUND_TEXT]) |
|
|
3285 | ? XCompoundTextStyle : XStdICCTextStyle; |
|
|
3286 | } else |
|
|
3287 | #endif |
|
|
3288 | { |
|
|
3289 | target = XA_STRING; |
|
|
3290 | style = XStringStyle; |
3347 | style = XCompoundTextStyle; |
3291 | } |
3348 | } |
|
|
3349 | |
3292 | if (R->selection.text) { |
3350 | if (R->selection.text) { |
3293 | cl[0] = (char *)R->selection.text; |
3351 | cl = (char *)R->selection.text; |
3294 | selectlen = R->selection.len; |
3352 | selectlen = R->selection.len; |
3295 | } else { |
3353 | } else { |
3296 | cl[0] = dummy; |
3354 | cl = ""; |
3297 | *dummy = '\0'; |
|
|
3298 | selectlen = 0; |
3355 | selectlen = 0; |
3299 | } |
3356 | } |
3300 | #ifdef USE_XIM |
3357 | |
3301 | if (XmbTextListToTextProperty(R->Xdisplay, cl, 1, style, &ct) |
3358 | if (XmbTextListToTextProperty(R->Xdisplay, &cl, 1, style, &ct) >= 0) |
3302 | == Success) /* if we failed to convert then send it raw */ |
|
|
3303 | freect = 1; |
3359 | freect = 1; |
3304 | else |
3360 | else |
3305 | #endif |
|
|
3306 | { |
3361 | { |
|
|
3362 | /* if we failed to convert then send it raw */ |
3307 | ct.value = (unsigned char *)cl[0]; |
3363 | ct.value = (unsigned char *)cl; |
3308 | ct.nitems = selectlen; |
3364 | ct.nitems = selectlen; |
3309 | } |
3365 | } |
|
|
3366 | |
3310 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, |
3367 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, |
3311 | target, 8, PropModeReplace, |
3368 | target, 8, PropModeReplace, |
3312 | ct.value, (int)ct.nitems); |
3369 | ct.value, (int)ct.nitems); |
3313 | ev.property = rq->property; |
3370 | ev.property = rq->property; |
3314 | #ifdef USE_XIM |
3371 | |
3315 | if (freect) |
3372 | if (freect) |
3316 | XFree(ct.value); |
3373 | XFree (ct.value); |
3317 | #endif |
|
|
3318 | } |
3374 | } |
3319 | XSendEvent(R->Xdisplay, rq->requestor, False, 0L, (XEvent *)&ev); |
3375 | XSendEvent(R->Xdisplay, rq->requestor, False, 0L, (XEvent *)&ev); |
3320 | } |
3376 | } |
3321 | |
3377 | |
3322 | /* ------------------------------------------------------------------------- * |
3378 | /* ------------------------------------------------------------------------- * |