summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--configure.in3
-rw-r--r--src/async-getprop.c44
3 files changed, 48 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 6fd653c..2934106 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
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.
+
+2003-09-29 Havoc Pennington <hp@redhat.com>
+
* src/xprops.c (cvtINT16toInt): fix the 64-bit check not to use
macros from the X tree that don't get set
diff --git a/configure.in b/configure.in
index fbe7ad1..77000da 100644
--- a/configure.in
+++ b/configure.in
@@ -33,6 +33,9 @@ AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(long long)
AC_CHECK_SIZEOF(__int64)
+## byte order
+AC_C_BIGENDIAN
+
#### Warnings
changequote(,)dnl
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;