summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Djärv <jan.h.d@swipnet.se>2005-02-07 20:00:07 +0000
committerJan Djärv <jan.h.d@swipnet.se>2005-02-07 20:00:07 +0000
commitfede04ef9f8e5625d353b38ea067706e446ea1a5 (patch)
tree3d48951cd549cc042cbfb6563878b1e9fe7188d0 /src
parente22cf39c6670462a155f8535075a5e5bc937065a (diff)
downloademacs-fede04ef9f8e5625d353b38ea067706e446ea1a5.tar.gz
* xfns.c (Fx_change_window_property): Use long array when format is 32.
(Fx_window_property): If format is 32 and long is bigger than 32 bits, convert long array returned from XGetWindowProperty to an int array.
Diffstat (limited to 'src')
-rw-r--r--src/xfns.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/xfns.c b/src/xfns.c
index bc9b4a5c993..bf1b0273a0f 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -4067,8 +4067,13 @@ Value is VALUE. */)
data = (unsigned char *) xmalloc (nelements);
else if (element_format == 16)
data = (unsigned char *) xmalloc (nelements*2);
- else
- data = (unsigned char *) xmalloc (nelements*4);
+ else /* format == 32 */
+ /* The man page for XChangeProperty:
+ "If the specified format is 32, the property data must be a
+ long array."
+ This applies even if long is more than 64 bits. The X library
+ converts to 32 bits before sending to the X server. */
+ data = (unsigned char *) xmalloc (nelements * sizeof(long));
x_fill_property_data (FRAME_X_DISPLAY (f), value, data, element_format);
}
@@ -4203,6 +4208,30 @@ no value of TYPE. */)
(unsigned char **) &tmp_data);
if (rc == Success && tmp_data)
{
+ /* The man page for XGetWindowProperty says:
+ "If the returned format is 32, the returned data is represented
+ as a long array and should be cast to that type to obtain the
+ elements."
+ This applies even if long is more than 32 bits, the X library
+ converts from 32 bit elements received from the X server to long
+ and passes the long array to us. Thus, for that case bcopy can not
+ be used. We convert to a 32 bit type here, because so much code
+ assume on that.
+
+ The bytes and offsets passed to XGetWindowProperty refers to the
+ property and those are indeed in 32 bit quantities if format is
+ 32. */
+
+ if (actual_format == 32 && actual_format < BITS_PER_LONG)
+ {
+ unsigned long i;
+ int *idata = (int *) tmp_data;
+ long *ldata = (long *) tmp_data;
+
+ for (i = 0; i < actual_size; ++i)
+ idata[i]= (int) ldata[i];
+ }
+
if (NILP (vector_ret_p))
prop_value = make_string (tmp_data, size);
else