ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/screen.C
(Generate patch)

Comparing rxvt-unicode/src/screen.C (file contents):
Revision 1.43 by pcg, Wed Mar 3 02:59:53 2004 UTC vs.
Revision 1.54 by pcg, Thu Mar 11 00:53:19 2004 UTC

764 * Add text given in <str> of length <len> to screen struct 764 * Add text given in <str> of length <len> to screen struct
765 */ 765 */
766void 766void
767rxvt_term::scr_add_lines (const uint32_t *str, int nlines, int len) 767rxvt_term::scr_add_lines (const uint32_t *str, int nlines, int len)
768{ 768{
769 unsigned char checksel, clearsel; 769 unsigned char checksel, clearsel;
770 uint32_t c; 770 uint32_t c;
771 int i, row, last_col; 771 int i, row, last_col;
772 text_t *stp; 772 text_t *stp;
773 rend_t *srp; 773 rend_t *srp;
774 774
775 if (len <= 0) /* sanity */ 775 if (len <= 0) /* sanity */
776 return; 776 return;
777 777
778 want_refresh = 1; 778 want_refresh = 1;
846 && ROWCOL_IS_BEFORE (screen.cur, selection.end)) 846 && ROWCOL_IS_BEFORE (screen.cur, selection.end))
847 { 847 {
848 checksel = 0; 848 checksel = 0;
849 clearsel = 1; 849 clearsel = 1;
850 } 850 }
851
851 if (screen.flags & Screen_WrapNext) 852 if (screen.flags & Screen_WrapNext)
852 { 853 {
853 screen.tlen[row] = -1; 854 screen.tlen[row] = -1;
854 if (screen.cur.row == screen.bscroll) 855 if (screen.cur.row == screen.bscroll)
855 scr_scroll_text (screen.tscroll, screen.bscroll, 1, 0); 856 scr_scroll_text (screen.tscroll, screen.bscroll, 1, 0);
856 else if (screen.cur.row < (TermWin.nrow - 1)) 857 else if (screen.cur.row < (TermWin.nrow - 1))
857 row = (++screen.cur.row) + TermWin.saveLines; 858 row = (++screen.cur.row) + TermWin.saveLines;
859
858 stp = screen.text[row]; /* _must_ refresh */ 860 stp = screen.text[row]; /* _must_ refresh */
859 srp = screen.rend[row]; /* _must_ refresh */ 861 srp = screen.rend[row]; /* _must_ refresh */
860 screen.cur.col = 0; 862 screen.cur.col = 0;
861 screen.flags &= ~Screen_WrapNext; 863 screen.flags &= ~Screen_WrapNext;
862 } 864 }
865
863 if (screen.flags & Screen_Insert) 866 if (screen.flags & Screen_Insert)
864 scr_insdel_chars (1, INSERT); 867 scr_insdel_chars (1, INSERT);
868
869 if (IS_COMPOSE (c))
870 c = REPLACEMENT_CHAR;
871
872 // rely on wcwidth to tell us the character width, at least for non-latin1
873 // do wcwidth before further replacements, as wcwidth says that line-drawing
874 // characters have width -1 (DOH!) on gnu/linux sometimes.
875 int width = c < 256 ? 1 : wcwidth (c);
865 876
866 if (charsets[screen.charset] == '0') // DEC SPECIAL 877 if (charsets[screen.charset] == '0') // DEC SPECIAL
867 switch (c) 878 switch (c)
868 { 879 {
869 // dunno where these come from
870#if 0
871 case '+': c = 0x2192; break; case ',': c = 0x2190; break; case '-': c = 0x2191; break;
872 case '.': c = 0x2193; break; case '0': c = 0x25ae; break;
873#endif
874 // vt100 special graphics and line drawing 880 // vt100 special graphics and line drawing
875 case '`': c = 0x25c6; break; case '_': c = 0x0020; break; 881 case '`': c = 0x25c6; break; case '_': c = 0x0020; break;
876 case 'a': c = 0x2592; break; case 'b': c = 0x2409; break; case 'c': c = 0x240c; break; 882 case 'a': c = 0x2592; break; case 'b': c = 0x2409; break; case 'c': c = 0x240c; break;
877 case 'd': c = 0x240d; break; case 'e': c = 0x240a; break; case 'f': c = 0x00b0; break; 883 case 'd': c = 0x240d; break; case 'e': c = 0x240a; break; case 'f': c = 0x00b0; break;
878 case 'g': c = 0x00b1; break; case 'h': c = 0x2424; break; case 'i': c = 0x240b; break; 884 case 'g': c = 0x00b1; break; case 'h': c = 0x2424; break; case 'i': c = 0x240b; break;
882 case 's': c = 0x23bd; break; case 't': c = 0x251c; break; case 'u': c = 0x2524; break; 888 case 's': c = 0x23bd; break; case 't': c = 0x251c; break; case 'u': c = 0x2524; break;
883 case 'v': c = 0x2534; break; case 'w': c = 0x252c; break; case 'x': c = 0x2502; break; 889 case 'v': c = 0x2534; break; case 'w': c = 0x252c; break; case 'x': c = 0x2502; break;
884 case 'y': c = 0x2264; break; case 'z': c = 0x2265; break; case '{': c = 0x03c0; break; 890 case 'y': c = 0x2264; break; case 'z': c = 0x2265; break; case '{': c = 0x03c0; break;
885 case '|': c = 0x2260; break; case '}': c = 0x00a3; break; case '~': c = 0x00b7; break; 891 case '|': c = 0x2260; break; case '}': c = 0x00a3; break; case '~': c = 0x00b7; break;
886 } 892 }
893
887 894
888 rend_t rend = SET_FONT (rstyle, TermWin.fontset->find_font (c));
889 // rely on wcwidth to tell us the character width, at least for non-ascii
890 int width = c <= 128 ? 1 : wcwidth (c);
891
892 // width -1 characters (e.g. combining chars) are ignored currently.
893 if (width > 0) 895 if (width > 0)
894 { 896 {
897#if !UNICODE_3
898 // trim characters we can't store directly :(
899 if (c >= 0x10000)
900 c = rxvt_composite.compose (c); // map to lower 16 bits
901#endif
902 rend_t rend = SET_FONT (rstyle, TermWin.fontset->find_font (c));
903
895 do 904 do
896 { 905 {
897 stp[screen.cur.col] = c; 906 stp[screen.cur.col] = c;
898 srp[screen.cur.col] = rend; 907 srp[screen.cur.col] = rend;
899 908
910 c = NOCHAR; 919 c = NOCHAR;
911 } 920 }
912 while (--width > 0); 921 while (--width > 0);
913 922
914 // pad with spaces when overwriting wide character with smaller one 923 // pad with spaces when overwriting wide character with smaller one
915 for (int c = screen.cur.col; stp[c] == NOCHAR && c < last_col; c++) 924 for (int c = screen.cur.col; c < last_col && stp[c] == NOCHAR; c++)
916 { 925 {
917 stp[c] = ' '; 926 stp[c] = ' ';
918 srp[c] = rend; 927 srp[c] = rend;
919 } 928 }
920 } 929 }
930 else if (width == 0)
931 {
932#if ENCODING_COMPOSE
933 // handle combining characters
934 // we just tag the accent on the previous on-screen character.
935 // this is arguably not correct, but also arguably not wrong.
936 // we don't handle double-width characters nicely yet.
937
938 text_t *tp;
939 rend_t *rp;
940
941 if (screen.cur.col > 0)
942 {
943 tp = stp + screen.cur.col - 1;
944 rp = srp + screen.cur.col - 1;
945 }
946 else if (screen.cur.row > 0
947 && screen.tlen [screen.cur.row - 1 + TermWin.saveLines] == -1)
948 {
949 tp = screen.text[screen.cur.row - 1 + TermWin.saveLines] + last_col - 1;
950 rp = screen.rend[screen.cur.row - 1 + TermWin.saveLines] + last_col - 1;
951 }
921 else 952 else
922 (void)0; /* handle combining character etc. here. */ 953 continue;
954
955 // handle double-width-chars by making them look extremely ugly
956 if (*tp == NOCHAR)
957 *tp = ' '; // hack //D //TODO //--tp, --rp;
958
959 // first try to find a precomposed character
960 uint32_t n = rxvt_compose (*tp, c);
961 if (n == NOCHAR)
962 n = rxvt_composite.compose (*tp, c);
963
964 *tp = n;
965 *rp = SET_FONT (*rp, TermWin.fontset->find_font (*tp));
966#endif
967 }
923 } 968 }
924 969
925 if (screen.tlen[row] != -1) /* XXX: think about this */ 970 if (screen.tlen[row] != -1) /* XXX: think about this */
926 MAX_IT (screen.tlen[row], screen.cur.col); 971 MAX_IT (screen.tlen[row], screen.cur.col);
927 972
2529 } 2574 }
2530 2575
2531 if (ct.nitems == 0) 2576 if (ct.nitems == 0)
2532 { 2577 {
2533 D_SELECT ((stderr, "rxvt_selection_paste: property empty - also INCR end")); 2578 D_SELECT ((stderr, "rxvt_selection_paste: property empty - also INCR end"));
2579
2534 if (selection_wait == Sel_normal && nread == 0 2580 if (selection_wait == Sel_normal && nread == 0
2535 && (win != display->root || prop != XA_CUT_BUFFER0)) // avoid recursion 2581 && (win != display->root || prop != XA_CUT_BUFFER0)) // avoid recursion
2536 { 2582 {
2537 /* 2583 /*
2538 * pass through again trying CUT_BUFFER0 if we've come from 2584 * pass through again trying CUT_BUFFER0 if we've come from
2593{ 2639{
2594 int reget_time = 0; 2640 int reget_time = 0;
2595 2641
2596 if (prop == None) 2642 if (prop == None)
2597 return; 2643 return;
2644
2598 D_SELECT ((stderr, "rxvt_selection_property (%08lx, %lu)", win, (unsigned long)prop)); 2645 D_SELECT ((stderr, "rxvt_selection_property (%08lx, %lu)", win, (unsigned long)prop));
2599 if (selection_wait == Sel_normal) 2646 if (selection_wait == Sel_normal)
2600 { 2647 {
2601 int a, afmt; 2648 int a, afmt;
2602 Atom atype; 2649 Atom atype;
2603 unsigned long bytes_after, nitems; 2650 unsigned long bytes_after, nitems;
2604 unsigned char *s = NULL; 2651 unsigned char *s = NULL;
2605 2652
2606 a = XGetWindowProperty (display->display, win, prop, 0L, 1L, False, 2653 a = XGetWindowProperty (display->display, win, prop, 0L, 1L, False,
2607 xa[XA_INCR], &atype, &afmt, &nitems, 2654 xa[XA_INCR], &atype, &afmt, &nitems,
2608 &bytes_after, &s); 2655 &bytes_after, &s);
2609 if (s) 2656 if (s)
2610 XFree (s); 2657 XFree (s);
2611 if (a != Success) 2658 if (a != Success)
2612 return; 2659 return;
2660
2613#ifndef __CYGWIN32__ 2661#ifndef __CYGWIN32__
2614 if (atype == xa[XA_INCR]) 2662 if (atype == xa[XA_INCR])
2615 { /* start an INCR transfer */ 2663 { /* start an INCR transfer */
2616 D_SELECT ((stderr, "rxvt_selection_property: INCR: starting transfer")); 2664 D_SELECT ((stderr, "rxvt_selection_property: INCR: starting transfer"));
2617 XDeleteProperty (display->display, win, prop); 2665 XDeleteProperty (display->display, win, prop);
2623 2671
2624 } 2672 }
2625 else if (selection_wait == Sel_incr) 2673 else if (selection_wait == Sel_incr)
2626 { 2674 {
2627 reget_time = 1; 2675 reget_time = 1;
2676
2628 if (selection_paste (win, prop, True) == -1) 2677 if (selection_paste (win, prop, True) == -1)
2629 { 2678 {
2630 D_SELECT ((stderr, "rxvt_selection_property: INCR: clean end")); 2679 D_SELECT ((stderr, "rxvt_selection_property: INCR: clean end"));
2631 selection_wait = Sel_none; 2680 selection_wait = Sel_none;
2632 incr_ev.stop (); 2681 incr_ev.stop ();
2633 } 2682 }
2634 } 2683 }
2635 if (reget_time) /* received more data so reget time */ 2684 if (reget_time) /* received more data so reget time */
2636 incr_ev.start (NOW + 10); 2685 incr_ev.start (NOW + 10);
2637} 2686}
2687
2638/* ------------------------------------------------------------------------- */ 2688/* ------------------------------------------------------------------------- */
2639/* 2689/*
2640 * Request the current selection: 2690 * Request the current selection:
2641 * Order: > internal selection if available 2691 * Order: > internal selection if available
2642 * > PRIMARY, SECONDARY, CLIPBOARD if ownership is claimed (+) 2692 * > PRIMARY, SECONDARY, CLIPBOARD if ownership is claimed (+)
2647 */ 2697 */
2648void 2698void
2649rxvt_term::selection_request (Time tm, int x, int y) 2699rxvt_term::selection_request (Time tm, int x, int y)
2650{ 2700{
2651 D_SELECT ((stderr, "rxvt_selection_request (%lu, %d, %d)", tm, x, y)); 2701 D_SELECT ((stderr, "rxvt_selection_request (%lu, %d, %d)", tm, x, y));
2702
2652 if (x < 0 || x >= TermWin.width || y < 0 || y >= TermWin.height) 2703 if (x < 0 || x >= TermWin.width || y < 0 || y >= TermWin.height)
2653 return; /* outside window */ 2704 return; /* outside window */
2654 2705
2655 if (selection.text != NULL) 2706 if (selection.text)
2656 { /* internal selection */ 2707 { /* internal selection */
2657 D_SELECT ((stderr, "rxvt_selection_request: pasting internal")); 2708 D_SELECT ((stderr, "rxvt_selection_request: pasting internal"));
2658 paste (selection.text, selection.len); 2709 char *str = rxvt_wcstombs (selection.text, selection.len);
2710 paste ((unsigned char *)str, strlen (str));
2711 free (str);
2659 return; 2712 return;
2660 } 2713 }
2661 else 2714 else
2662 { 2715 {
2663 int i; 2716 int i;
2664 2717
2665 selection_request_time = tm; 2718 selection_request_time = tm;
2666 selection_wait = Sel_normal; 2719 selection_wait = Sel_normal;
2667 for (i = Sel_Primary; i <= Sel_Clipboard; i++) 2720 for (i = Sel_Primary; i <= Sel_Clipboard; i++)
2668 { 2721 {
2676 return; 2729 return;
2677#endif 2730#endif
2678 2731
2679 } 2732 }
2680 } 2733 }
2734
2681 selection_wait = Sel_none; /* don't loop in rxvt_selection_paste () */ 2735 selection_wait = Sel_none; /* don't loop in rxvt_selection_paste () */
2682 D_SELECT ((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); 2736 D_SELECT ((stderr, "rxvt_selection_request: pasting CUT_BUFFER0"));
2683 selection_paste (display->root, XA_CUT_BUFFER0, False); 2737 selection_paste (display->root, XA_CUT_BUFFER0, False);
2684} 2738}
2685 2739
2686int 2740int
2687rxvt_term::selection_request_other (Atom target, int selnum) 2741rxvt_term::selection_request_other (Atom target, int selnum)
2688{ 2742{
2689 Atom sel; 2743 Atom sel;
2690#ifdef DEBUG_SELECT 2744#ifdef DEBUG_SELECT
2691 char *debug_xa_names[] = { "PRIMARY", "SECONDARY", "CLIPBOARD" }; 2745 char *debug_xa_names[] = { "PRIMARY", "SECONDARY", "CLIPBOARD" };
2692#endif 2746#endif
2693 2747
2694 selection_type |= selnum; 2748 selection_type |= selnum;
2749
2695 if (selnum == Sel_Primary) 2750 if (selnum == Sel_Primary)
2696 sel = XA_PRIMARY; 2751 sel = XA_PRIMARY;
2697 else if (selnum == Sel_Secondary) 2752 else if (selnum == Sel_Secondary)
2698 sel = XA_SECONDARY; 2753 sel = XA_SECONDARY;
2699 else 2754 else
2700 sel = xa[XA_CLIPBOARD]; 2755 sel = xa[XA_CLIPBOARD];
2756
2701 if (XGetSelectionOwner (display->display, sel) != None) 2757 if (XGetSelectionOwner (display->display, sel) != None)
2702 { 2758 {
2703 D_SELECT ((stderr, "rxvt_selection_request_other: pasting %s", debug_xa_names[selnum])); 2759 D_SELECT ((stderr, "rxvt_selection_request_other: pasting %s", debug_xa_names[selnum]));
2704 XConvertSelection (display->display, sel, target, xa[XA_VT_SELECTION], 2760 XConvertSelection (display->display, sel, target, xa[XA_VT_SELECTION],
2705 TermWin.vt, selection_request_time); 2761 TermWin.vt, selection_request_time);
2706 return 1; 2762 return 1;
2707 } 2763 }
2764
2708 return 0; 2765 return 0;
2709} 2766}
2710 2767
2711/* ------------------------------------------------------------------------- */ 2768/* ------------------------------------------------------------------------- */
2712/* 2769/*
2732 */ 2789 */
2733void 2790void
2734rxvt_term::selection_make (Time tm) 2791rxvt_term::selection_make (Time tm)
2735{ 2792{
2736 int i, col, end_col, row, end_row; 2793 int i, col, end_col, row, end_row;
2737 unsigned char *new_selection_text; 2794 wchar_t *new_selection_text;
2738 char *str;
2739 text_t *t; 2795 text_t *t;
2740 2796
2741 D_SELECT ((stderr, "rxvt_selection_make (): selection.op=%d, selection.clicks=%d", selection.op, selection.clicks)); 2797 D_SELECT ((stderr, "rxvt_selection_make (): selection.op=%d, selection.clicks=%d", selection.op, selection.clicks));
2742 switch (selection.op) 2798 switch (selection.op)
2743 { 2799 {
2756 selection.op = SELECTION_DONE; 2812 selection.op = SELECTION_DONE;
2757 2813
2758 if (selection.clicks == 4) 2814 if (selection.clicks == 4)
2759 return; /* nothing selected, go away */ 2815 return; /* nothing selected, go away */
2760 2816
2761 i = (selection.end.row - selection.beg.row + 1) * (TermWin.ncol + 1) + 1; 2817 i = (selection.end.row - selection.beg.row + 1) * (TermWin.ncol + 1);
2762 str = (char *)rxvt_malloc ((i + 2) * MB_CUR_MAX + 1); 2818 new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t));
2763
2764 new_selection_text = (unsigned char *)str;
2765 2819
2766 col = selection.beg.col; 2820 col = selection.beg.col;
2767 MAX_IT (col, 0); 2821 MAX_IT (col, 0);
2768 row = selection.beg.row + TermWin.saveLines; 2822 row = selection.beg.row + TermWin.saveLines;
2769 end_row = selection.end.row + TermWin.saveLines; 2823 end_row = selection.end.row + TermWin.saveLines;
2770 struct mbstate mbs; 2824 int ofs = 0;
2825 int extra = 0;
2771 2826
2772 for (; row <= end_row; row++, col = 0) 2827 for (; row <= end_row; row++, col = 0)
2773 { 2828 {
2774 t = & (screen.text[row][col]); 2829 t = &(screen.text[row][col]);
2775 2830
2776 end_col = screen.tlen[row]; 2831 end_col = screen.tlen[row];
2777 2832
2778 if (end_col == -1) 2833 if (end_col == -1)
2779 end_col = TermWin.ncol; 2834 end_col = TermWin.ncol;
2780 2835
2781 if (row == end_row) 2836 if (row == end_row)
2782 MIN_IT (end_col, selection.end.col); 2837 MIN_IT (end_col, selection.end.col);
2783 2838
2784 for (; col < end_col; col++) 2839 for (; col < end_col; col++)
2840 {
2785 if (*t == NOCHAR) 2841 if (*t == NOCHAR)
2786 t++; 2842 t++;
2843 else if (IS_COMPOSE (*t))
2844 {
2845 int len = rxvt_composite.expand (*t, 0);
2846
2847 extra -= (len - 1);
2848
2849 if (extra < 0)
2850 {
2851 extra += i;
2852 i += i;
2853 new_selection_text = (wchar_t *)rxvt_realloc (new_selection_text, (i + 4) * sizeof (wchar_t));
2854 }
2855
2856 ofs += rxvt_composite.expand (*t++, new_selection_text + ofs);
2857 }
2787 else 2858 else
2788 { 2859 new_selection_text[ofs++] = *t++;
2789 int len = wcrtomb (str, *t++, mbs);
2790 if (len > 0)
2791 str += len;
2792 } 2860 }
2793 2861
2794 if (screen.tlen[row] != -1 && row != end_row) 2862 if (screen.tlen[row] != -1 && row != end_row)
2795 *str++ = '\n'; 2863 new_selection_text[ofs++] = L'\n';
2796 } 2864 }
2797 2865
2798#ifndef NO_OLD_SELECTION 2866#ifndef NO_OLD_SELECTION
2799 if (selection_style == OLD_SELECT) 2867 if (selection_style == OLD_SELECT)
2800 if (end_col == TermWin.ncol) 2868 if (end_col == TermWin.ncol)
2801 *str++ = '\n'; 2869 new_selection_text[ofs++] = L'\n';
2802#endif 2870#endif
2803#ifndef NO_NEW_SELECTION 2871#ifndef NO_NEW_SELECTION
2804 if (selection_style != OLD_SELECT) 2872 if (selection_style != OLD_SELECT)
2805 if (end_col != selection.end.col) 2873 if (end_col != selection.end.col)
2806 *str++ = '\n'; 2874 new_selection_text[ofs++] = L'\n';
2807#endif 2875#endif
2808 *str = '\0'; 2876 new_selection_text[ofs] = 0;
2809 2877
2810 i = str - (char *)new_selection_text;
2811 if (i == 0) 2878 if (ofs == 0)
2812 { 2879 {
2813 free (new_selection_text); 2880 free (new_selection_text);
2814 return; 2881 return;
2815 } 2882 }
2816 2883
2817 // due to MB_CUR_MAX, selection wastage is usually high, so realloc
2818 if (str - (char *)new_selection_text > 1024)
2819 new_selection_text = (unsigned char *)rxvt_realloc (new_selection_text, i + 1);
2820
2821 selection.len = i;
2822
2823 if (selection.text)
2824 free (selection.text); 2884 free (selection.text);
2825 2885
2826 selection.text = new_selection_text; 2886 // we usually allocate much more than necessary, so realloc it smaller again
2887 selection.len = ofs;
2888 selection.text = (wchar_t *)rxvt_realloc (new_selection_text, (ofs + 1) * sizeof (wchar_t));
2827 2889
2828 XSetSelectionOwner (display->display, XA_PRIMARY, TermWin.vt, tm); 2890 XSetSelectionOwner (display->display, XA_PRIMARY, TermWin.vt, tm);
2829 if (XGetSelectionOwner (display->display, XA_PRIMARY) == TermWin.vt) 2891 if (XGetSelectionOwner (display->display, XA_PRIMARY) == TermWin.vt)
2830 display->set_selection_owner (this); 2892 display->set_selection_owner (this);
2831 else 2893 else
2832 rxvt_print_error ("can't get primary selection"); 2894 rxvt_print_error ("can't get primary selection");
2833 2895
2834 { 2896#if 0
2835 XTextProperty ct; 2897 XTextProperty ct;
2836 char *cl = (char *)selection.text;
2837 2898
2838 if (XmbTextListToTextProperty (display->display, &cl, 1, XStringStyle, &ct) >= 0) 2899 if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0)
2839 { 2900 {
2840 XChangeProperty (display->display, display->root, XA_CUT_BUFFER0, XA_STRING, 8,
2841 PropModeReplace, ct.value, ct.nitems);
2842 XFree (ct.value);
2843 }
2844 else
2845 XChangeProperty (display->display, display->root, XA_CUT_BUFFER0, XA_STRING, 8, 2901 XChangeProperty (display->display, display->root, XA_CUT_BUFFER0, XA_STRING, 8,
2846 PropModeReplace, selection.text, (int)selection.len); 2902 PropModeReplace, ct.value, ct.nitems);
2903 XFree (ct.value);
2847 } 2904 }
2905#endif
2848 2906
2849 selection_time = tm; 2907 selection_time = tm;
2850 D_SELECT ((stderr, "rxvt_selection_make (): selection.len=%d", selection.len)); 2908 D_SELECT ((stderr, "rxvt_selection_make (): selection.len=%d", selection.len));
2851} 2909}
2852 2910
3381 ev.target = rq.target; 3439 ev.target = rq.target;
3382 ev.time = rq.time; 3440 ev.time = rq.time;
3383 3441
3384 if (rq.target == xa[XA_TARGETS]) 3442 if (rq.target == xa[XA_TARGETS])
3385 { 3443 {
3386 Atom32 target_list[5]; 3444 Atom32 target_list[6];
3387 Atom32 *target = target_list; 3445 Atom32 *target = target_list;
3388 3446
3389 *target++ = (Atom32) xa[XA_TARGETS]; 3447 *target++ = (Atom32) xa[XA_TARGETS];
3448 *target++ = (Atom32) xa[XA_TIMESTAMP];
3390 *target++ = (Atom32) XA_STRING; 3449 *target++ = (Atom32) XA_STRING;
3391 *target++ = (Atom32) xa[XA_TEXT]; 3450 *target++ = (Atom32) xa[XA_TEXT];
3392 *target++ = (Atom32) xa[XA_COMPOUND_TEXT]; 3451 *target++ = (Atom32) xa[XA_COMPOUND_TEXT];
3393#if X_HAVE_UTF8_STRING 3452#if X_HAVE_UTF8_STRING
3394 *target++ = (Atom32) xa[XA_UTF8_STRING]; 3453 *target++ = (Atom32) xa[XA_UTF8_STRING];
3395#endif 3454#endif
3455
3396 XChangeProperty (display->display, rq.requestor, rq.property, XA_ATOM, 3456 XChangeProperty (display->display, rq.requestor, rq.property, XA_ATOM,
3397 (8 * sizeof (target_list[0])), PropModeReplace, 3457 (8 * sizeof (target_list[0])), PropModeReplace,
3398 (unsigned char *)target_list, 3458 (unsigned char *)target_list,
3399 target - target_list); 3459 target - target_list);
3400 ev.property = rq.property; 3460 ev.property = rq.property;
3401 } 3461 }
3402 else if (rq.target == xa[XA_MULTIPLE]) 3462 else if (rq.target == xa[XA_MULTIPLE])
3403 { 3463 {
3404 /* TODO: Handle MULTIPLE */ 3464 /* TODO: Handle MULTIPLE */
3416 || rq.target == xa[XA_UTF8_STRING] 3476 || rq.target == xa[XA_UTF8_STRING]
3417 ) 3477 )
3418 { 3478 {
3419 short freect = 0; 3479 short freect = 0;
3420 int selectlen; 3480 int selectlen;
3421 char *cl; 3481 wchar_t *cl;
3422 3482
3423 target = rq.target; 3483 target = rq.target;
3424 3484
3425 if (target == XA_STRING) 3485 if (target == XA_STRING)
3426 // we actually don't do XA_STRING, but who cares, as i18n clients 3486 // we actually don't do XA_STRING, but who cares, as i18n clients
3427 // will ask for another format anyways. 3487 // will ask for another format anyways.
3428 style = XStringStyle; 3488 style = XStringStyle;
3429 else if (target == xa[XA_TEXT]) 3489 else if (target == xa[XA_TEXT])
3430 style = XTextStyle; 3490 style = XStdICCTextStyle;
3431 else if (target == xa[XA_COMPOUND_TEXT]) 3491 else if (target == xa[XA_COMPOUND_TEXT])
3432 style = XCompoundTextStyle; 3492 style = XCompoundTextStyle;
3433#if X_HAVE_UTF8_STRING 3493#if X_HAVE_UTF8_STRING
3434 else if (target == xa[XA_UTF8_STRING]) 3494 else if (target == xa[XA_UTF8_STRING])
3435 style = XUTF8StringStyle; 3495 style = XUTF8StringStyle;
3440 style = XCompoundTextStyle; 3500 style = XCompoundTextStyle;
3441 } 3501 }
3442 3502
3443 if (selection.text) 3503 if (selection.text)
3444 { 3504 {
3445 cl = (char *)selection.text; 3505 cl = selection.text;
3446 selectlen = selection.len; 3506 selectlen = selection.len;
3447 } 3507 }
3448 else 3508 else
3449 { 3509 {
3450 cl = ""; 3510 cl = L"";
3451 selectlen = 0; 3511 selectlen = 0;
3452 } 3512 }
3453 3513
3514 // Xwc doesn't handle iso-10646 in wchar_t gracefully, so maybe recode it
3515 // manually for XUTF8StringStyle.
3454 if (XmbTextListToTextProperty (display->display, &cl, 1, style, &ct) >= 0) 3516 if (XwcTextListToTextProperty (display->display, &cl, 1, style, &ct) >= 0)
3455 freect = 1; 3517 freect = 1;
3456 else 3518 else
3457 { 3519 {
3458 /* if we failed to convert then send it raw */ 3520 /* if we failed to convert then send it raw */
3459 ct.value = (unsigned char *)cl; 3521 ct.value = (unsigned char *)cl;
3466 ev.property = rq.property; 3528 ev.property = rq.property;
3467 3529
3468 if (freect) 3530 if (freect)
3469 XFree (ct.value); 3531 XFree (ct.value);
3470 } 3532 }
3533
3471 XSendEvent (display->display, rq.requestor, False, 0L, (XEvent *)&ev); 3534 XSendEvent (display->display, rq.requestor, False, 0L, (XEvent *)&ev);
3472} 3535}
3473 3536
3474/* ------------------------------------------------------------------------- * 3537/* ------------------------------------------------------------------------- *
3475 * MOUSE ROUTINES * 3538 * MOUSE ROUTINES *

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines