[patch] fix for BadAtom in X_ChangeProperty when pasting to some client
Marcin Cieslak
saper at saper.info
Wed Apr 20 00:44:08 CEST 2011
Hello,
When testing syncterm (http://syncterm.bbsdev.net/) I noticed
that syncterm crashes and (after some fixes) causes crash
in rxvt and the following warning in rxvt-unicode when
pasting some text from rxvt-unicode to syncterm:
X Error occurred, trying to continue after report.
urxvt: X Error of failed request: BadAtom (invalid Atom parameter)
urxvt: Major opcode of failed request: 18
urxvt: (which is X_ChangeProperty)
urxvt: Atom id in failed request: 0x0
urxvt: Serial number of failed request: 657
The same thing works fine with xterm. This is because
this client sends None property with ConvertRequest.
This is discouradged by ICCCM but nethertheless I think
it should not cause any problems with the terminal
emulator.
Here are some more sample programs that work the
same way:
http://michael.toren.net/mirrors/doc/X-copy+paste.txt
Below is a patch to rxvt-unicode-9.10 (it applies
also to the CVS trunk):
------------8<----------------------
--- src/screen.C.orig 2011-04-19 23:53:53.000000000 +0200
+++ src/screen.C 2011-04-19 23:57:02.000000000 +0200
@@ -3619,6 +3619,7 @@
rxvt_term::selection_send (const XSelectionRequestEvent &rq) NOTHROW
{
XSelectionEvent ev;
+ Atom property;
ev.type = SelectionNotify;
ev.property = None;
@@ -3628,6 +3629,16 @@
ev.target = rq.target;
ev.time = rq.time;
+ /* ICCCM: 2.2. Responsibilities of the Selection Owner
+ * SelectionRequest:
+ * If the specified property is None , the requestor
+ * an obsolete client. Owners are encouraged
+ * to support these clients by using the specified
+ * target atom as the property name to be used for
+ * the reply.
+ */
+ property = (rq.property == 0) ? rq.target : rq.property;
+
if (rq.target == xa[XA_TARGETS])
{
Atom target_list[6];
@@ -3642,10 +3653,10 @@
*target++ = xa[XA_UTF8_STRING];
#endif
- XChangeProperty (dpy, rq.requestor, rq.property, XA_ATOM,
+ XChangeProperty (dpy, rq.requestor, property, XA_ATOM,
32, PropModeReplace,
(unsigned char *)target_list, target - target_list);
- ev.property = rq.property;
+ ev.property = property;
}
#if TODO // TODO
else if (rq.target == xa[XA_MULTIPLE])
@@ -3655,15 +3666,15 @@
#endif
else if (rq.target == xa[XA_TIMESTAMP] && rq.selection == XA_PRIMARY && selection.text)
{
- XChangeProperty (dpy, rq.requestor, rq.property, rq.target,
+ XChangeProperty (dpy, rq.requestor, property, rq.target,
32, PropModeReplace, (unsigned char *)&selection_time, 1);
- ev.property = rq.property;
+ ev.property = property;
}
else if (rq.target == xa[XA_TIMESTAMP] && rq.selection == xa[XA_CLIPBOARD] && selection.clip_text)
{
- XChangeProperty (dpy, rq.requestor, rq.property, rq.target,
+ XChangeProperty (dpy, rq.requestor, property, rq.target,
32, PropModeReplace, (unsigned char *)&clipboard_time, 1);
- ev.property = rq.property;
+ ev.property = property;
}
else if (rq.target == XA_STRING
|| rq.target == xa[XA_TEXT]
@@ -3744,10 +3755,10 @@
ct.encoding = target;
}
- XChangeProperty (dpy, rq.requestor, rq.property,
+ XChangeProperty (dpy, rq.requestor, property,
ct.encoding, 8, PropModeReplace,
ct.value, (int)ct.nitems);
- ev.property = rq.property;
+ ev.property = property;
if (freect)
XFree (ct.value);
------------8<----------------------
//Marcin
More information about the rxvt-unicode
mailing list