From 8f2dd859a637a7d222ae15d8edc286497a14c686 Mon Sep 17 00:00:00 2001 From: Michael Jennings Date: Sun, 8 Aug 2010 23:37:54 +0000 Subject: Sun Aug 8 16:32:44 2010 Michael Jennings (mej) Modified patch from Paolo Ferrario based on input from Kim Woelders 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). ---------------------------------------------------------------------- SVN revision: 50916 --- ChangeLog | 11 +++++++++++ src/screen.c | 28 ++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1cde766..5fce52a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5642,3 +5642,14 @@ Thu Nov 12 22:11:49 2009 Michael Jennings (mej) Additional debugging and proper bracing. ---------------------------------------------------------------------- +Sun Aug 8 16:32:44 2010 Michael Jennings (mej) + +Modified patch from Paolo Ferrario based on input +from Kim Woelders 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). +---------------------------------------------------------------------- diff --git a/src/screen.c b/src/screen.c index 6a6c579..b4d6255 100644 --- a/src/screen.c +++ b/src/screen.c @@ -3344,7 +3344,25 @@ selection_send(XSelectionRequestEvent * rq) 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 @@ selection_send(XSelectionRequestEvent * rq) 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); -- cgit v1.2.1