From: Enlightenment S. <no-...@en...> - 2010-08-08 23:38:01
|
Log: Sun Aug 8 16:32:44 2010 Michael Jennings (mej) Modified patch from Paolo Ferrario <sk...@ti...> based on input from Kim Woelders <ki...@wo...> to allow Eterm to respond to selection requests in UTF-8, compound text, or string only. Previously, exotic selection request types would receive a string back, but it would claim to be whatever type was requested. Now it claims to be a string, which is probably more correct. This should also eliminate server round-trips when clients ask for UTF-8, get a string, then ask for a string (Opera). ---------------------------------------------------------------------- Author: mej Date: 2010-08-08 16:37:54 -0700 (Sun, 08 Aug 2010) New Revision: 50916 Modified: trunk/eterm/Eterm/ChangeLog trunk/eterm/Eterm/src/screen.c Modified: trunk/eterm/Eterm/ChangeLog =================================================================== --- trunk/eterm/Eterm/ChangeLog 2010-08-08 23:06:34 UTC (rev 50915) +++ trunk/eterm/Eterm/ChangeLog 2010-08-08 23:37:54 UTC (rev 50916) @@ -5642,3 +5642,14 @@ Additional debugging and proper bracing. ---------------------------------------------------------------------- +Sun Aug 8 16:32:44 2010 Michael Jennings (mej) + +Modified patch from Paolo Ferrario <sk...@ti...> based on input +from Kim Woelders <ki...@wo...> to allow Eterm to respond to +selection requests in UTF-8, compound text, or string only. +Previously, exotic selection request types would receive a string +back, but it would claim to be whatever type was requested. Now it +claims to be a string, which is probably more correct. This should +also eliminate server round-trips when clients ask for UTF-8, get a +string, then ask for a string (Opera). +---------------------------------------------------------------------- Modified: trunk/eterm/Eterm/src/screen.c =================================================================== --- trunk/eterm/Eterm/src/screen.c 2010-08-08 23:06:34 UTC (rev 50915) +++ trunk/eterm/Eterm/src/screen.c 2010-08-08 23:37:54 UTC (rev 50916) @@ -3344,7 +3344,25 @@ 32, PropModeReplace, (unsigned char *) target_list, (sizeof(target_list) / sizeof(target_list[0]))); ev.xselection.property = rq->property; -#if defined(MULTI_CHARSET) && defined(HAVE_X11_XMU_ATOMS_H) +#ifdef MULTI_CHARSET +# ifdef X_HAVE_UTF8_STRING + } else if (rq->target == XA_UTF8_STRING(Xdisplay)) { + XTextProperty xtextp; + char *l[1]; + + *l = selection.text; + xtextp.value = NULL; + xtextp.nitems = 0; + if (XmbTextListToTextProperty(Xdisplay, l, 1, XUTF8StringStyle, &xtextp) == Success) { + if (xtextp.nitems > 0 && xtextp.value != NULL) { + XChangeProperty(Xdisplay, rq->requestor, rq->property, + rq->target, 8, PropModeReplace, xtextp.value, xtextp.nitems); + ev.xselection.property = rq->property; + XFree(xtextp.value); + } + } +# endif /* X_HAVE_UTF8_STRING */ +# ifdef HAVE_X11_XMU_ATOMS_H } else if (rq->target == XA_TEXT(Xdisplay) || rq->target == XA_COMPOUND_TEXT(Xdisplay)) { XTextProperty xtextp; char *l[1]; @@ -3357,11 +3375,13 @@ XChangeProperty(Xdisplay, rq->requestor, rq->property, XA_COMPOUND_TEXT(Xdisplay), 8, PropModeReplace, xtextp.value, xtextp.nitems); ev.xselection.property = rq->property; + XFree(xtextp.value); } } -#endif - } else if (rq->target == XA_STRING) { - XChangeProperty(Xdisplay, rq->requestor, rq->property, rq->target, 8, PropModeReplace, selection.text, selection.len); +# endif /* HAVE_X11_XMU_ATOMS_H */ +#endif /* MULTI_CHARSET */ + } else { + XChangeProperty(Xdisplay, rq->requestor, rq->property, XA_STRING, 8, PropModeReplace, selection.text, selection.len); ev.xselection.property = rq->property; } XSendEvent(Xdisplay, rq->requestor, False, 0, &ev); |