From c63fcd27994875e31878619875ad3324232bf90d Mon Sep 17 00:00:00 2001 From: Diego Borghetti Date: Fri, 30 Jan 2009 21:01:18 +0000 Subject: 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. --- intern/ghost/intern/GHOST_SystemX11.cpp | 45 +++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 10 deletions(-) (limited to 'intern') diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index 9950ef88879..02dfdc2e25c 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -981,11 +981,11 @@ getClipboard(int flag ) const { //Flag //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; Window m_window, owner; unsigned char *data, *tmp_data; - int bits; + int bits, count; unsigned long len, bytes; XEvent xevent; @@ -996,6 +996,8 @@ getClipboard(int flag clip_String = XInternAtom(m_display, "_BLENDER_STRING", 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 if(flag == 0) { @@ -1029,23 +1031,46 @@ getClipboard(int flag XFlush(m_display); //This needs to change so we do not wait for ever or check owner first + count= 1; while(1) { XNextEvent(m_display, &xevent); - if(xevent.type == SelectionNotify) { - if (xevent.xselection.property ) { /* eric4 on linux gives zero Atom xevent.xselection.property value, closes blender instantly */ + if(xevent.type == SelectionNotify) { + 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 (data) { - tmp_data = (unsigned char*) malloc(strlen((char*)data)+1); - strcpy((char*)tmp_data, (char*)data); + if (bits == 8 && (rtype == compound_text || rtype == a_text || rtype == a_string)) { + tmp_data = (unsigned char*) malloc(strlen((char*)data)+1); + strcpy((char*)tmp_data, (char*)data); + } + else + tmp_data= NULL; + XFree(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; } } } -- cgit v1.2.3