comparison src/xfns.c @ 60133:cfda6afe9273

(hack_wm_protocols): Use correct type for last parameter of XGetWindowProperty to avoid aliasing issues. (Fx_window_property): Likewise.
author Andreas Schwab <schwab@suse.de>
date Thu, 17 Feb 2005 12:49:34 +0000
parents 7f8e4c715b72
children 2895b0a63b0e 9684495d72bc 7e3f621f1dd4
comparison
equal deleted inserted replaced
60132:8a072d12b41a 60133:cfda6afe9273
1878 int need_focus = 1; 1878 int need_focus = 1;
1879 int need_save = 1; 1879 int need_save = 1;
1880 1880
1881 BLOCK_INPUT; 1881 BLOCK_INPUT;
1882 { 1882 {
1883 Atom type, *atoms = 0; 1883 Atom type;
1884 unsigned char *catoms;
1884 int format = 0; 1885 int format = 0;
1885 unsigned long nitems = 0; 1886 unsigned long nitems = 0;
1886 unsigned long bytes_after; 1887 unsigned long bytes_after;
1887 1888
1888 if ((XGetWindowProperty (dpy, w, 1889 if ((XGetWindowProperty (dpy, w,
1889 FRAME_X_DISPLAY_INFO (f)->Xatom_wm_protocols, 1890 FRAME_X_DISPLAY_INFO (f)->Xatom_wm_protocols,
1890 (long)0, (long)100, False, XA_ATOM, 1891 (long)0, (long)100, False, XA_ATOM,
1891 &type, &format, &nitems, &bytes_after, 1892 &type, &format, &nitems, &bytes_after,
1892 (unsigned char **) &atoms) 1893 &catoms)
1893 == Success) 1894 == Success)
1894 && format == 32 && type == XA_ATOM) 1895 && format == 32 && type == XA_ATOM)
1895 while (nitems > 0) 1896 {
1896 { 1897 Atom *atoms = (Atom *) catoms;
1897 nitems--; 1898 while (nitems > 0)
1898 if (atoms[nitems] == FRAME_X_DISPLAY_INFO (f)->Xatom_wm_delete_window) 1899 {
1899 need_delete = 0; 1900 nitems--;
1900 else if (atoms[nitems] == FRAME_X_DISPLAY_INFO (f)->Xatom_wm_take_focus) 1901 if (atoms[nitems]
1901 need_focus = 0; 1902 == FRAME_X_DISPLAY_INFO (f)->Xatom_wm_delete_window)
1902 else if (atoms[nitems] == FRAME_X_DISPLAY_INFO (f)->Xatom_wm_save_yourself) 1903 need_delete = 0;
1903 need_save = 0; 1904 else if (atoms[nitems]
1904 } 1905 == FRAME_X_DISPLAY_INFO (f)->Xatom_wm_take_focus)
1905 if (atoms) XFree ((char *) atoms); 1906 need_focus = 0;
1907 else if (atoms[nitems]
1908 == FRAME_X_DISPLAY_INFO (f)->Xatom_wm_save_yourself)
1909 need_save = 0;
1910 }
1911 }
1912 if (catoms)
1913 XFree (catoms);
1906 } 1914 }
1907 { 1915 {
1908 Atom props [10]; 1916 Atom props [10];
1909 int count = 0; 1917 int count = 0;
1910 if (need_delete) 1918 if (need_delete)
4154 { 4162 {
4155 struct frame *f = check_x_frame (frame); 4163 struct frame *f = check_x_frame (frame);
4156 Atom prop_atom; 4164 Atom prop_atom;
4157 int rc; 4165 int rc;
4158 Lisp_Object prop_value = Qnil; 4166 Lisp_Object prop_value = Qnil;
4159 char *tmp_data = NULL; 4167 unsigned char *tmp_data = NULL;
4160 Atom actual_type; 4168 Atom actual_type;
4161 Atom target_type = XA_STRING; 4169 Atom target_type = XA_STRING;
4162 int actual_format; 4170 int actual_format;
4163 unsigned long actual_size, bytes_remaining; 4171 unsigned long actual_size, bytes_remaining;
4164 Window target_window = FRAME_X_WINDOW (f); 4172 Window target_window = FRAME_X_WINDOW (f);
4194 4202
4195 prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SDATA (prop), False); 4203 prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SDATA (prop), False);
4196 rc = XGetWindowProperty (FRAME_X_DISPLAY (f), target_window, 4204 rc = XGetWindowProperty (FRAME_X_DISPLAY (f), target_window,
4197 prop_atom, 0, 0, False, target_type, 4205 prop_atom, 0, 0, False, target_type,
4198 &actual_type, &actual_format, &actual_size, 4206 &actual_type, &actual_format, &actual_size,
4199 &bytes_remaining, (unsigned char **) &tmp_data); 4207 &bytes_remaining, &tmp_data);
4200 if (rc == Success) 4208 if (rc == Success)
4201 { 4209 {
4202 int size = bytes_remaining; 4210 int size = bytes_remaining;
4203 4211
4204 XFree (tmp_data); 4212 XFree (tmp_data);
4207 rc = XGetWindowProperty (FRAME_X_DISPLAY (f), target_window, 4215 rc = XGetWindowProperty (FRAME_X_DISPLAY (f), target_window,
4208 prop_atom, 0, bytes_remaining, 4216 prop_atom, 0, bytes_remaining,
4209 ! NILP (delete_p), target_type, 4217 ! NILP (delete_p), target_type,
4210 &actual_type, &actual_format, 4218 &actual_type, &actual_format,
4211 &actual_size, &bytes_remaining, 4219 &actual_size, &bytes_remaining,
4212 (unsigned char **) &tmp_data); 4220 &tmp_data);
4213 if (rc == Success && tmp_data) 4221 if (rc == Success && tmp_data)
4214 { 4222 {
4215 /* The man page for XGetWindowProperty says: 4223 /* The man page for XGetWindowProperty says:
4216 "If the returned format is 32, the returned data is represented 4224 "If the returned format is 32, the returned data is represented
4217 as a long array and should be cast to that type to obtain the 4225 as a long array and should be cast to that type to obtain the
4231 unsigned long i; 4239 unsigned long i;
4232 int *idata = (int *) tmp_data; 4240 int *idata = (int *) tmp_data;
4233 long *ldata = (long *) tmp_data; 4241 long *ldata = (long *) tmp_data;
4234 4242
4235 for (i = 0; i < actual_size; ++i) 4243 for (i = 0; i < actual_size; ++i)
4236 idata[i]= (int) ldata[i]; 4244 idata[i] = (int) ldata[i];
4237 } 4245 }
4238 4246
4239 if (NILP (vector_ret_p)) 4247 if (NILP (vector_ret_p))
4240 prop_value = make_string (tmp_data, size); 4248 prop_value = make_string (tmp_data, size);
4241 else 4249 else
4242 prop_value = x_property_data_to_lisp (f, 4250 prop_value = x_property_data_to_lisp (f,
4243 (unsigned char *) tmp_data, 4251 tmp_data,
4244 actual_type, 4252 actual_type,
4245 actual_format, 4253 actual_format,
4246 actual_size); 4254 actual_size);
4247 } 4255 }
4248 4256