diff options
| author | Jan Djärv | 2005-02-07 20:00:07 +0000 |
|---|---|---|
| committer | Jan Djärv | 2005-02-07 20:00:07 +0000 |
| commit | fede04ef9f8e5625d353b38ea067706e446ea1a5 (patch) | |
| tree | 3d48951cd549cc042cbfb6563878b1e9fe7188d0 | |
| parent | e22cf39c6670462a155f8535075a5e5bc937065a (diff) | |
| download | emacs-fede04ef9f8e5625d353b38ea067706e446ea1a5.tar.gz emacs-fede04ef9f8e5625d353b38ea067706e446ea1a5.zip | |
* 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.
| -rw-r--r-- | src/xfns.c | 33 |
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. */) | |||
| 4067 | data = (unsigned char *) xmalloc (nelements); | 4067 | data = (unsigned char *) xmalloc (nelements); |
| 4068 | else if (element_format == 16) | 4068 | else if (element_format == 16) |
| 4069 | data = (unsigned char *) xmalloc (nelements*2); | 4069 | data = (unsigned char *) xmalloc (nelements*2); |
| 4070 | else | 4070 | else /* format == 32 */ |
| 4071 | data = (unsigned char *) xmalloc (nelements*4); | 4071 | /* The man page for XChangeProperty: |
| 4072 | "If the specified format is 32, the property data must be a | ||
| 4073 | long array." | ||
| 4074 | This applies even if long is more than 64 bits. The X library | ||
| 4075 | converts to 32 bits before sending to the X server. */ | ||
| 4076 | data = (unsigned char *) xmalloc (nelements * sizeof(long)); | ||
| 4072 | 4077 | ||
| 4073 | x_fill_property_data (FRAME_X_DISPLAY (f), value, data, element_format); | 4078 | x_fill_property_data (FRAME_X_DISPLAY (f), value, data, element_format); |
| 4074 | } | 4079 | } |
| @@ -4203,6 +4208,30 @@ no value of TYPE. */) | |||
| 4203 | (unsigned char **) &tmp_data); | 4208 | (unsigned char **) &tmp_data); |
| 4204 | if (rc == Success && tmp_data) | 4209 | if (rc == Success && tmp_data) |
| 4205 | { | 4210 | { |
| 4211 | /* The man page for XGetWindowProperty says: | ||
| 4212 | "If the returned format is 32, the returned data is represented | ||
| 4213 | as a long array and should be cast to that type to obtain the | ||
| 4214 | elements." | ||
| 4215 | This applies even if long is more than 32 bits, the X library | ||
| 4216 | converts from 32 bit elements received from the X server to long | ||
| 4217 | and passes the long array to us. Thus, for that case bcopy can not | ||
| 4218 | be used. We convert to a 32 bit type here, because so much code | ||
| 4219 | assume on that. | ||
| 4220 | |||
| 4221 | The bytes and offsets passed to XGetWindowProperty refers to the | ||
| 4222 | property and those are indeed in 32 bit quantities if format is | ||
| 4223 | 32. */ | ||
| 4224 | |||
| 4225 | if (actual_format == 32 && actual_format < BITS_PER_LONG) | ||
| 4226 | { | ||
| 4227 | unsigned long i; | ||
| 4228 | int *idata = (int *) tmp_data; | ||
| 4229 | long *ldata = (long *) tmp_data; | ||
| 4230 | |||
| 4231 | for (i = 0; i < actual_size; ++i) | ||
| 4232 | idata[i]= (int) ldata[i]; | ||
| 4233 | } | ||
| 4234 | |||
| 4206 | if (NILP (vector_ret_p)) | 4235 | if (NILP (vector_ret_p)) |
| 4207 | prop_value = make_string (tmp_data, size); | 4236 | prop_value = make_string (tmp_data, size); |
| 4208 | else | 4237 | else |