summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-09-29 22:17:16 +0000
committerHavoc Pennington <hp@src.gnome.org>2003-09-29 22:17:16 +0000
commita4dc0d581a91303f821653cb038e56a9220cbac8 (patch)
tree924443a4e502ca5d69dd7244bf9448c8c6996b02 /src
parenta889ff346907763f3e2a284bcfb9b1f89f603ad1 (diff)
downloadmetacity-a4dc0d581a91303f821653cb038e56a9220cbac8.tar.gz
metacity-a4dc0d581a91303f821653cb038e56a9220cbac8.tar.bz2
attempt to fix this to return the data as an array of long even on 64-bit
2003-09-29 Havoc Pennington <hp@redhat.com> * src/async-getprop.c (async_get_property_handler): attempt to fix this to return the data as an array of long even on 64-bit as with XGetWindowProperty() breakage, bug #114035, credit to Gwenole Beauchesne for tracking down.
Diffstat (limited to 'src')
-rw-r--r--src/async-getprop.c44
1 files changed, 38 insertions, 6 deletions
diff --git a/src/async-getprop.c b/src/async-getprop.c
index 3b95f13..f34ea0c 100644
--- a/src/async-getprop.c
+++ b/src/async-getprop.c
@@ -347,8 +347,9 @@ async_get_property_handler (Display *dpy,
break;
case 32:
- nbytes = reply->nItems * sizeof (CARD32);
- netbytes = reply->nItems << 2;
+ /* NOTE buffer is in longs to match XGetWindowProperty() */
+ nbytes = reply->nItems * sizeof (long);
+ netbytes = reply->nItems << 2; /* wire size is always 32 bits though */
if (nbytes + 1 > 0 &&
(task->data = (unsigned char *) Xmalloc ((unsigned)nbytes + 1)))
{
@@ -356,10 +357,41 @@ async_get_property_handler (Display *dpy,
printf ("%s: already read %d bytes using %ld more, eating %ld more\n",
__FUNCTION__, bytes_read, nbytes, netbytes);
#endif
- /* _XRead32 (dpy, (long *) task->data, netbytes); */
- _XGetAsyncData (dpy, task->data, buf, len,
- bytes_read, nbytes,
- netbytes);
+
+ /* We have to copy the XGetWindowProperty() crackrock
+ * and get format 32 as long even on 64-bit platforms.
+ */
+ if (sizeof (long) == 8)
+ {
+ unsigned char *netdata;
+ unsigned char *lptr;
+ unsigned char *end_lptr;
+
+ /* Store the 32-bit values in the end of the array */
+ netdata = task->data + nbytes / 2;
+
+ _XGetAsyncData (dpy, netdata, buf, len,
+ bytes_read, netbytes,
+ netbytes);
+
+ /* Now move the 32-bit values to the front */
+
+ lptr = task->data;
+ end_lptr = task->data + nbytes;
+ while (lptr != end_lptr)
+ {
+ *(long*) lptr = *(CARD32*) netdata;
+ lptr += sizeof (long);
+ netdata += sizeof (CARD32);
+ }
+ }
+ else
+ {
+ /* Here the wire format matches our actual format */
+ _XGetAsyncData (dpy, task->data, buf, len,
+ bytes_read, netbytes,
+ netbytes);
+ }
}
break;