Fix revision: 18690, bug #17850

The problem was that Qt convert the text to the type
STRING or UTF8, that is why Blender can't get the text,
now should be work fine.
This commit is contained in:
Diego Borghetti 2009-01-30 21:01:18 +00:00
parent 0409977aa8
commit c63fcd2799

@ -981,11 +981,11 @@ getClipboard(int flag
) const { ) const {
//Flag //Flag
//0 = Regular clipboard 1 = selection //0 = Regular clipboard 1 = selection
static Atom Primary_atom, clip_String, compound_text; static Atom Primary_atom, clip_String, compound_text, a_text, a_string;
Atom rtype; Atom rtype;
Window m_window, owner; Window m_window, owner;
unsigned char *data, *tmp_data; unsigned char *data, *tmp_data;
int bits; int bits, count;
unsigned long len, bytes; unsigned long len, bytes;
XEvent xevent; XEvent xevent;
@ -996,6 +996,8 @@ getClipboard(int flag
clip_String = XInternAtom(m_display, "_BLENDER_STRING", False); clip_String = XInternAtom(m_display, "_BLENDER_STRING", False);
compound_text = XInternAtom(m_display, "COMPOUND_TEXT", False); compound_text = XInternAtom(m_display, "COMPOUND_TEXT", False);
a_text= XInternAtom(m_display, "TEXT", False);
a_string= XInternAtom(m_display, "STRING", False);
//lets check the owner and if it is us then return the static buffer //lets check the owner and if it is us then return the static buffer
if(flag == 0) { if(flag == 0) {
@ -1029,23 +1031,46 @@ getClipboard(int flag
XFlush(m_display); XFlush(m_display);
//This needs to change so we do not wait for ever or check owner first //This needs to change so we do not wait for ever or check owner first
count= 1;
while(1) { while(1) {
XNextEvent(m_display, &xevent); XNextEvent(m_display, &xevent);
if(xevent.type == SelectionNotify) { if(xevent.type == SelectionNotify) {
if (xevent.xselection.property ) { /* eric4 on linux gives zero Atom xevent.xselection.property value, closes blender instantly */ if (xevent.xselection.property == None) {
/* Ok, the client can't convert the property
* to some that we can handle, try other types..
*/
if (count == 1) {
XConvertSelection(m_display, Primary_atom, a_text, clip_String, m_window, CurrentTime);
count++;
}
else if (count == 2) {
XConvertSelection(m_display, Primary_atom, a_string, clip_String, m_window, CurrentTime);
count++;
}
else {
/* Ok, the owner of the selection can't
* convert the data to something that we can
* handle.
*/
return(NULL);
}
}
else {
if(XGetWindowProperty(m_display, m_window, xevent.xselection.property , 0L, 4096L, False, AnyPropertyType, &rtype, &bits, &len, &bytes, &data) == Success) { if(XGetWindowProperty(m_display, m_window, xevent.xselection.property , 0L, 4096L, False, AnyPropertyType, &rtype, &bits, &len, &bytes, &data) == Success) {
if (data) { if (data) {
if (bits == 8 && (rtype == compound_text || rtype == a_text || rtype == a_string)) {
tmp_data = (unsigned char*) malloc(strlen((char*)data)+1); tmp_data = (unsigned char*) malloc(strlen((char*)data)+1);
strcpy((char*)tmp_data, (char*)data); strcpy((char*)tmp_data, (char*)data);
}
else
tmp_data= NULL;
XFree(data); XFree(data);
return (GHOST_TUns8*)tmp_data; return (GHOST_TUns8*)tmp_data;
} }
} }
return(NULL);
} }
else {
fprintf(stderr, "error: cut buffer had a zero xevent.xselection.property, FIXME\n"); // XXX fix this problem!
}
return NULL;
} }
} }
} }