On Sat, 31 Jul 2010, Kim Woelders wrote:

>     It looks like many programs request UTF8_STRING and not STRING.
> 
>     I'm no expert on selections but if I'm not mistaken this change would 
>     make us give a STRING regardless of what we were asked for.
>     It would then be up to the requestor to convert that to utf8. I guess 
>     that's ok.
> 
>     The alternative would be to test for UTF8_STRING and do a conversion, but 
>     IMO that might as well wait for Eterm to actually become utf8-aware.
> 
>     Michael?
> 
>     /Kim



I'm not expert on selections at all, too..

And you're right, after some investigations, I've found these behaviours, as 
examples:


1]Opera: it asks first for UTF8.
If we force, as target response, a XA_STRING type,
Opera then makes a subsequent request for XA_STRING.
Eterm then answers, all ok.
[on a side note: If we answer with ev.xselection.property = None,
then Opera stops making other requests, so, no good.]


2] Firefox: it asks first for UTF8.
If we force XA_STRING, he's happy with it, all done.
[side note: If we answer with ev.xselection.property = None,
Firefox makes a subsequent request for XA_COMPOUND_TEXT(Xdisplay),
Eterm answers, all ok.]


[my ooffice, qterm, qtm, emacs, xterm, never ask for UTF8]


So, it would be nice to have the UTF8 conversion.
Not a big hassle, here it is
[I've simply used the existing XmbTextListToTextProperty, with
style = XUTF8StringStyle],
but I'd keep the last, non-conditional, XA_STRING forcing block..
[my vim e.g. requests something that is not in group of
XA_COMPOUND_TEXT XA_TEXT XA_STRING XA_UTF8_STRING]



here is the UTF8-converting patch:

[tried of course with --enable-multi-charset]


--- screen.c    2010-07-29 22:54:14.000000000 +0200
+++ screen.c    2010-07-31 21:07:36.000000000 +0200
@@ -3345,23 +3345,30 @@
                          (sizeof(target_list) / sizeof(target_list[0])));
          ev.xselection.property = rq->property;
  #if defined(MULTI_CHARSET) && defined(HAVE_X11_XMU_ATOMS_H)
-    } else if (rq->target == XA_TEXT(Xdisplay) ||
-     rq->target == XA_COMPOUND_TEXT(Xdisplay)) {
+    } else if (rq->target == XA_TEXT(Xdisplay) ||
+     rq->target == XA_COMPOUND_TEXT(Xdisplay)  ||
+     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,
-        XCompoundTextStyle, &xtextp) == Success) {
+        int style = XCompoundTextStyle;
+        Atom working_target = XA_COMPOUND_TEXT(Xdisplay);
+        if(rq->target == XA_UTF8_STRING(Xdisplay)) {
+        style = XUTF8StringStyle;
+        working_target = rq->target;
+        }
+        if (XmbTextListToTextProperty(Xdisplay, l, 1,
+        style, &xtextp) == Success) {
              if (xtextp.nitems > 0 && xtextp.value != NULL) {
-                XChangeProperty(Xdisplay, rq->requestor, rq->property,
-                XA_COMPOUND_TEXT(Xdisplay),
+                XChangeProperty(Xdisplay, rq->requestor, rq->property,
+                working_target,
                    8, PropModeReplace, xtextp.value, xtextp.nitems);
                    ev.xselection.property = rq->property;
              }
          }
  #endif
-    } else if (rq->target == XA_STRING) {
-        XChangeProperty(Xdisplay, rq->requestor, rq->property, rq->target, 8,
-        PropModeReplace, selection.text, selection.len);
+    } 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);



------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to