summaryrefslogtreecommitdiff
path: root/src/Fl_x.cxx
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2010-12-09 21:52:07 +0000
committerManolo Gouy <Manolo>2010-12-09 21:52:07 +0000
commite931f660caea5257841103196a389fd5eae6be07 (patch)
tree9a94e9b21c18c013e4e59483bea7648f6f45d9e3 /src/Fl_x.cxx
parent5ca2671de8b1460f25d2c725d457c0fec5cb153e (diff)
STR #2472: X11 only: fixes DnD between FLTK and other apps for non-ASCII text.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7992 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_x.cxx')
-rw-r--r--src/Fl_x.cxx24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx
index be4a88026..12fd89e61 100644
--- a/src/Fl_x.cxx
+++ b/src/Fl_x.cxx
@@ -278,6 +278,20 @@ int fl_ready() {
# endif
}
+// replace \r\n by \n
+static void convert_crlf(unsigned char *string, long& len)
+{
+ unsigned char *p = string, *q = p + len;
+ while (p < q) {
+ if (*p == '\r' && *(p + 1) == '\n' && p + 1 < q) {
+ memmove(p, p + 1, q - p - 1);
+ q--;
+ len--;
+ }
+ p++;
+ }
+}
+
////////////////////////////////////////////////////////////////
Display *fl_display;
@@ -955,23 +969,15 @@ int fl_handle(const XEvent& thisevent)
text_prop.encoding=actual;
text_prop.nitems=count;
char **text_list;
-#ifndef X_HAVE_UTF8_STRING
text_list = (char**)&portion;
-#else
- int list_count = 0;
- Xutf8TextPropertyToTextList(fl_display, (const XTextProperty*)&text_prop, &text_list, &list_count);
- if (list_count == 0) text_list = (char**)&portion;
-#endif
int bytesnew = strlen(*text_list)+1;
buffer = (unsigned char*)realloc(buffer, bytesread+bytesnew+remaining);
memcpy(buffer+bytesread, *text_list, bytesnew);
XFree(portion);
-#ifdef X_HAVE_UTF8_STRING
- if (list_count > 0) XFreeStringList(text_list);
-#endif
bytesread += bytesnew - 1;
if (!remaining) break;
}
+ convert_crlf(buffer, bytesread);
Fl::e_text = buffer ? (char*)buffer : (char *)"";
Fl::e_length = bytesread;
int old_event = Fl::e_number;