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
This commit is contained in:
parent
5ca2671de8
commit
e931f660ca
24
src/Fl_x.cxx
24
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;
|
||||
|
@ -43,6 +43,7 @@ extern Atom fl_XdndActionCopy;
|
||||
extern Atom fl_XdndFinished;
|
||||
//extern Atom fl_XdndProxy;
|
||||
extern Atom fl_XdndURIList;
|
||||
extern Atom fl_XaUtf8String;
|
||||
|
||||
extern char fl_i_own_selection[2];
|
||||
extern char *fl_selection_buffer[2];
|
||||
@ -149,7 +150,7 @@ int Fl::dnd() {
|
||||
} else {
|
||||
// Send plain text...
|
||||
fl_sendClientMessage(target_window, fl_XdndEnter, source_window,
|
||||
dndversion<<24, XA_STRING, 0, 0);
|
||||
dndversion<<24, fl_XaUtf8String, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user