Fix for charset=utf8 selection target

9 views
Skip to first unread message

Scott Schwartz

unread,
Nov 1, 2025, 7:24:03 AM (5 days ago) Nov 1
to plan9port-dev
Hi all,
This is a proposed fix for a small problem with text selections in cmd/devdraw.

    cmd/devdraw: handle X11 selections better
   
    x11-screen.c accepts selection targets with the MIME type
    "text/plain;charset-UTF8", but it should do so case insensitively. The
    current code draws an error when working with xfce4-terminal 1.0.4,
    which sends lower case.  To reproduce, run acme, snarf some text, then
    paste in the terminal.  acme will report:
    acme: cannot handle selection request for 'text/plain;charset=utf-8' (590)

diff --git a/src/cmd/devdraw/x11-screen.c b/src/cmd/devdraw/x11-screen.c
index df7cca46..b36ac064 100644
--- a/src/cmd/devdraw/x11-screen.c
+++ b/src/cmd/devdraw/x11-screen.c
@@ -1589,8 +1589,9 @@ if(0) fprint(2, "xselect target=%d requestor=%d property=%d selection=%d (sizeof
  || xe->target == _x.utf8string
  || xe->target == _x.text
  || xe->target == _x.compoundtext
- || ((name = XGetAtomName(_x.display, xe->target)) && strcmp(name, "text/plain;charset=UTF-8") == 0)){
+ || ((name = XGetAtomName(_x.display, xe->target)) && strcasecmp(name, "text/plain;charset=UTF-8") == 0)){
  /* text/plain;charset=UTF-8 seems nonstandard but is used by Synergy */
+ /* text/plain;charset=utf-8 is used by xfce4-terminal 1.0.4 */
  /* if the target is STRING we're supposed to reply with Latin1 XXX */
  qlock(&clip.lk);
  XChangeProperty(_x.display, xe->requestor, xe->property, xe->target,
Reply all
Reply to author
Forward
0 new messages