[Xquartz-dev] Suggested patch for 64-bit pbproxy in SL
Martin Otte
otte at duke.edu
Fri Sep 4 07:41:27 PDT 2009
Hi,
After upgrading to SL, when using X11 I kept seeing "Atom list is not
a multiple of the size of an atom!" in my system logs, and also
noticed that copying between OSX and X11 was sometimes not working
(especially when "Update Pasteboard immediately" was checked).
The problem is with the following lines in x-selection.m:
Atom a = None;
if (pdata->length % sizeof (a))
{
fprintf(stderr, "Atom list is not a multiple of the size of an
atom!\n");
return None;
}
On i386, sizeof(a)=4, but on x86_64, sizeof(a)=8. However, it looks
like pdata->length is always a multiple of an int (4 bytes) even on
x86_64, so about half the time this check gets flagged and the code to
check the clipboard type is not run.
My suggestion is just to use sizeof(int) instead of sizeof(a). Looking
through the server code, it looks like Atoms are always 32-bit anyway
when compiling the rest of the server, and are sizeof(long) outside of
the server.
Here's a copy of the patch I used to fix pbproxy:
--- xorg-server-1.4.2-apple47/hw/xquartz/pbproxy/x-selection.m.orig
+++ xorg-server-1.4.2-apple47/hw/xquartz/pbproxy/x-selection.m
@@ -228,16 +228,16 @@ get_property(Window win, Atom property,
TRACE ();
- if (pdata->length % sizeof (a))
+ if (pdata->length % sizeof (int))
{
fprintf(stderr, "Atom list is not a multiple of the size of
an atom!\n");
return None;
}
- for (i = 0; i < pdata->length; i += sizeof (a))
+ for (i = 0; i < pdata->length; i += sizeof (int))
{
a = None;
- memcpy (&a, pdata->data + i, sizeof (a));
+ memcpy (&a, pdata->data + i, sizeof (int));
if (a == atoms->image_png)
{
@@ -440,10 +440,6 @@ get_property(Window win, Atom property,
[self x_copy_request_targets];
}
}
- else
- {
- XBell (xpbproxy_dpy, 0);
- }
}
/* Set pbproxy as owner of the SELECTION_MANAGER selection.
With this patch, I was able to copy an image from the OSX clipboard to
an X11 application (gnumeric), and later select this image in X11 and
copy it back to OSX properly.
I also removed a call to XBell in x-selection.m. For some reason, when
I selected some text in an xterm (or other Xaw applications), whenever
I clicked anywhere to un-highlight the selection the system would
beep. This only seems to be happening in Xaw-based apps with "Update
Pasteboard immediately" checked. The bell ringing was driving me
crazy, so I removed the call to XBell which is probably not needed
anyway.
I hope this is useful,
Martin
More information about the Xquartz-dev
mailing list