Mercurial > hg > xemacs-beta
comparison src/xselect.c @ 272:c5d627a313b1 r21-0b34
Import from CVS: tag r21-0b34
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:28:48 +0200 |
parents | acd284d43ca1 |
children | 7df0dd720c89 |
comparison
equal
deleted
inserted
replaced
271:c7b7086b0a39 | 272:c5d627a313b1 |
---|---|
30 #include "objects-x.h" | 30 #include "objects-x.h" |
31 | 31 |
32 #include "frame.h" | 32 #include "frame.h" |
33 #include "opaque.h" | 33 #include "opaque.h" |
34 #include "systime.h" | 34 #include "systime.h" |
35 | |
36 int lisp_to_time (Lisp_Object, time_t *); | |
37 Lisp_Object time_to_lisp (time_t); | |
35 | 38 |
36 #ifdef LWLIB_USES_MOTIF | 39 #ifdef LWLIB_USES_MOTIF |
37 # define MOTIF_CLIPBOARDS | 40 # define MOTIF_CLIPBOARDS |
38 #endif | 41 #endif |
39 | 42 |
49 #define CUT_BUFFER_SUPPORT | 52 #define CUT_BUFFER_SUPPORT |
50 | 53 |
51 Lisp_Object QPRIMARY, QSECONDARY, QSTRING, QINTEGER, QCLIPBOARD, QTIMESTAMP, | 54 Lisp_Object QPRIMARY, QSECONDARY, QSTRING, QINTEGER, QCLIPBOARD, QTIMESTAMP, |
52 QTEXT, QDELETE, QMULTIPLE, QINCR, QEMACS_TMP, QTARGETS, QATOM, QNULL, | 55 QTEXT, QDELETE, QMULTIPLE, QINCR, QEMACS_TMP, QTARGETS, QATOM, QNULL, |
53 QATOM_PAIR, QCOMPOUND_TEXT; | 56 QATOM_PAIR, QCOMPOUND_TEXT; |
54 | |
55 #ifdef EPOCH | |
56 Lisp_Object QARC, QBITMAP, QCARDINAL, QCURSOR, QDRAWABLE, QFONT, QINTEGER, | |
57 QPIXMAP, QPOINT, QRECTANGLE, QWINDOW, QWM_HINTS, QWM_SIZE_HINTS; | |
58 #endif /* EPOCH */ | |
59 | 57 |
60 #ifdef CUT_BUFFER_SUPPORT | 58 #ifdef CUT_BUFFER_SUPPORT |
61 Lisp_Object QCUT_BUFFER0, QCUT_BUFFER1, QCUT_BUFFER2, QCUT_BUFFER3, | 59 Lisp_Object QCUT_BUFFER0, QCUT_BUFFER1, QCUT_BUFFER2, QCUT_BUFFER3, |
62 QCUT_BUFFER4, QCUT_BUFFER5, QCUT_BUFFER6, QCUT_BUFFER7; | 60 QCUT_BUFFER4, QCUT_BUFFER5, QCUT_BUFFER6, QCUT_BUFFER7; |
63 #endif | 61 #endif |
115 Atom *type_ret, | 113 Atom *type_ret, |
116 unsigned int *size_ret, | 114 unsigned int *size_ret, |
117 int *format_ret); | 115 int *format_ret); |
118 static Lisp_Object selection_data_to_lisp_data (struct device *, | 116 static Lisp_Object selection_data_to_lisp_data (struct device *, |
119 unsigned char *data, | 117 unsigned char *data, |
120 int size, | 118 size_t size, |
121 Atom type, | 119 Atom type, |
122 int format); | 120 int format); |
123 static Lisp_Object x_get_window_property_as_lisp_data (Display *, | 121 static Lisp_Object x_get_window_property_as_lisp_data (Display *, |
124 Window, | 122 Window, |
125 Atom property, | 123 Atom property, |
132 static int waiting_for_other_props_on_window (Display *, Window); | 130 static int waiting_for_other_props_on_window (Display *, Window); |
133 | 131 |
134 /* This converts a Lisp symbol to a server Atom, avoiding a server | 132 /* This converts a Lisp symbol to a server Atom, avoiding a server |
135 roundtrip whenever possible. | 133 roundtrip whenever possible. |
136 */ | 134 */ |
137 Atom | 135 static Atom |
138 symbol_to_x_atom (struct device *d, Lisp_Object sym, int only_if_exists) | 136 symbol_to_x_atom (struct device *d, Lisp_Object sym, int only_if_exists) |
139 { | 137 { |
140 Display *display = DEVICE_X_DISPLAY (d); | 138 Display *display = DEVICE_X_DISPLAY (d); |
141 | 139 |
142 if (NILP (sym)) return XA_PRIMARY; | 140 if (NILP (sym)) return XA_PRIMARY; |
143 if (EQ (sym, Qt)) return XA_SECONDARY; | 141 if (EQ (sym, Qt)) return XA_SECONDARY; |
144 if (EQ (sym, QPRIMARY)) return XA_PRIMARY; | 142 if (EQ (sym, QPRIMARY)) return XA_PRIMARY; |
145 if (EQ (sym, QSECONDARY)) return XA_SECONDARY; | 143 if (EQ (sym, QSECONDARY)) return XA_SECONDARY; |
146 if (EQ (sym, QSTRING)) return XA_STRING; | 144 if (EQ (sym, QSTRING)) return XA_STRING; |
147 if (EQ (sym, QINTEGER)) return XA_INTEGER; | 145 if (EQ (sym, QINTEGER)) return XA_INTEGER; |
148 if (EQ (sym, QATOM)) return XA_ATOM; | 146 if (EQ (sym, QATOM)) return XA_ATOM; |
149 if (EQ (sym, QCLIPBOARD)) return DEVICE_XATOM_CLIPBOARD (d); | 147 if (EQ (sym, QCLIPBOARD)) return DEVICE_XATOM_CLIPBOARD (d); |
150 if (EQ (sym, QTIMESTAMP)) return DEVICE_XATOM_TIMESTAMP (d); | 148 if (EQ (sym, QTIMESTAMP)) return DEVICE_XATOM_TIMESTAMP (d); |
151 if (EQ (sym, QTEXT)) return DEVICE_XATOM_TEXT (d); | 149 if (EQ (sym, QTEXT)) return DEVICE_XATOM_TEXT (d); |
152 if (EQ (sym, QDELETE)) return DEVICE_XATOM_DELETE (d); | 150 if (EQ (sym, QDELETE)) return DEVICE_XATOM_DELETE (d); |
153 if (EQ (sym, QMULTIPLE)) return DEVICE_XATOM_MULTIPLE (d); | 151 if (EQ (sym, QMULTIPLE)) return DEVICE_XATOM_MULTIPLE (d); |
154 if (EQ (sym, QINCR)) return DEVICE_XATOM_INCR (d); | 152 if (EQ (sym, QINCR)) return DEVICE_XATOM_INCR (d); |
155 if (EQ (sym, QEMACS_TMP)) return DEVICE_XATOM_EMACS_TMP (d); | 153 if (EQ (sym, QEMACS_TMP)) return DEVICE_XATOM_EMACS_TMP (d); |
156 if (EQ (sym, QTARGETS)) return DEVICE_XATOM_TARGETS (d); | 154 if (EQ (sym, QTARGETS)) return DEVICE_XATOM_TARGETS (d); |
157 if (EQ (sym, QNULL)) return DEVICE_XATOM_NULL (d); | 155 if (EQ (sym, QNULL)) return DEVICE_XATOM_NULL (d); |
158 if (EQ (sym, QATOM_PAIR)) return DEVICE_XATOM_ATOM_PAIR (d); | 156 if (EQ (sym, QATOM_PAIR)) return DEVICE_XATOM_ATOM_PAIR (d); |
159 if (EQ (sym, QCOMPOUND_TEXT)) return DEVICE_XATOM_COMPOUND_TEXT (d); | 157 if (EQ (sym, QCOMPOUND_TEXT)) return DEVICE_XATOM_COMPOUND_TEXT (d); |
160 #ifdef EPOCH | |
161 if (EQ (sym, QARC)) return XA_ARC; | |
162 if (EQ (sym, QBITMAP)) return XA_BITMAP; | |
163 if (EQ (sym, QCARDINAL)) return XA_CARDINAL; | |
164 if (EQ (sym, QCURSOR)) return XA_CURSOR; | |
165 if (EQ (sym, QDRAWABLE)) return XA_DRAWABLE; | |
166 if (EQ (sym, QFONT)) return XA_FONT; | |
167 if (EQ (sym, QINTEGER)) return XA_INTEGER; | |
168 if (EQ (sym, QPIXMAP)) return XA_PIXMAP; | |
169 if (EQ (sym, QPOINT)) return XA_POINT; | |
170 if (EQ (sym, QRECTANGLE)) return XA_RECTANGLE; | |
171 if (EQ (sym, QWINDOW)) return XA_WINDOW; | |
172 if (EQ (sym, QWM_HINTS)) return XA_WM_HINTS; | |
173 if (EQ (sym, QWM_SIZE_HINTS)) return XA_WM_SIZE_HINTS; | |
174 #endif /* EPOCH */ | |
175 | 158 |
176 #ifdef CUT_BUFFER_SUPPORT | 159 #ifdef CUT_BUFFER_SUPPORT |
177 if (EQ (sym, QCUT_BUFFER0)) return XA_CUT_BUFFER0; | 160 if (EQ (sym, QCUT_BUFFER0)) return XA_CUT_BUFFER0; |
178 if (EQ (sym, QCUT_BUFFER1)) return XA_CUT_BUFFER1; | 161 if (EQ (sym, QCUT_BUFFER1)) return XA_CUT_BUFFER1; |
179 if (EQ (sym, QCUT_BUFFER2)) return XA_CUT_BUFFER2; | 162 if (EQ (sym, QCUT_BUFFER2)) return XA_CUT_BUFFER2; |
180 if (EQ (sym, QCUT_BUFFER3)) return XA_CUT_BUFFER3; | 163 if (EQ (sym, QCUT_BUFFER3)) return XA_CUT_BUFFER3; |
181 if (EQ (sym, QCUT_BUFFER4)) return XA_CUT_BUFFER4; | 164 if (EQ (sym, QCUT_BUFFER4)) return XA_CUT_BUFFER4; |
182 if (EQ (sym, QCUT_BUFFER5)) return XA_CUT_BUFFER5; | 165 if (EQ (sym, QCUT_BUFFER5)) return XA_CUT_BUFFER5; |
183 if (EQ (sym, QCUT_BUFFER6)) return XA_CUT_BUFFER6; | 166 if (EQ (sym, QCUT_BUFFER6)) return XA_CUT_BUFFER6; |
184 if (EQ (sym, QCUT_BUFFER7)) return XA_CUT_BUFFER7; | 167 if (EQ (sym, QCUT_BUFFER7)) return XA_CUT_BUFFER7; |
185 #endif /* CUT_BUFFER_SUPPORT */ | 168 #endif /* CUT_BUFFER_SUPPORT */ |
186 | 169 |
187 { | 170 { |
188 CONST char *nameext; | 171 CONST char *nameext; |
189 Lisp_Object namesym; | 172 GET_C_STRING_CTEXT_DATA_ALLOCA (Fsymbol_name (sym), nameext); |
190 XSETSTRING (namesym, XSYMBOL (sym)->name); | |
191 GET_C_STRING_CTEXT_DATA_ALLOCA (namesym, nameext); | |
192 return XInternAtom (display, nameext, only_if_exists ? True : False); | 173 return XInternAtom (display, nameext, only_if_exists ? True : False); |
193 } | 174 } |
194 } | 175 } |
195 | 176 |
196 | 177 |
197 /* This converts a server Atom to a Lisp symbol, avoiding server roundtrips | 178 /* This converts a server Atom to a Lisp symbol, avoiding server roundtrips |
198 and calls to intern whenever possible. | 179 and calls to intern whenever possible. |
199 */ | 180 */ |
200 Lisp_Object | 181 static Lisp_Object |
201 x_atom_to_symbol (struct device *d, Atom atom) | 182 x_atom_to_symbol (struct device *d, Atom atom) |
202 { | 183 { |
203 Display *display = DEVICE_X_DISPLAY (d); | 184 Display *display = DEVICE_X_DISPLAY (d); |
204 | 185 |
205 if (! atom) return Qnil; | 186 if (! atom) return Qnil; |
206 if (atom == XA_PRIMARY) return QPRIMARY; | 187 if (atom == XA_PRIMARY) return QPRIMARY; |
207 if (atom == XA_SECONDARY) return QSECONDARY; | 188 if (atom == XA_SECONDARY) return QSECONDARY; |
208 if (atom == XA_STRING) return QSTRING; | 189 if (atom == XA_STRING) return QSTRING; |
209 if (atom == XA_INTEGER) return QINTEGER; | 190 if (atom == XA_INTEGER) return QINTEGER; |
210 if (atom == XA_ATOM) return QATOM; | 191 if (atom == XA_ATOM) return QATOM; |
211 if (atom == DEVICE_XATOM_CLIPBOARD (d)) return QCLIPBOARD; | 192 if (atom == DEVICE_XATOM_CLIPBOARD (d)) return QCLIPBOARD; |
212 if (atom == DEVICE_XATOM_TIMESTAMP (d)) return QTIMESTAMP; | 193 if (atom == DEVICE_XATOM_TIMESTAMP (d)) return QTIMESTAMP; |
213 if (atom == DEVICE_XATOM_TEXT (d)) return QTEXT; | 194 if (atom == DEVICE_XATOM_TEXT (d)) return QTEXT; |
214 if (atom == DEVICE_XATOM_DELETE (d)) return QDELETE; | 195 if (atom == DEVICE_XATOM_DELETE (d)) return QDELETE; |
215 if (atom == DEVICE_XATOM_MULTIPLE (d)) return QMULTIPLE; | 196 if (atom == DEVICE_XATOM_MULTIPLE (d)) return QMULTIPLE; |
218 if (atom == DEVICE_XATOM_TARGETS (d)) return QTARGETS; | 199 if (atom == DEVICE_XATOM_TARGETS (d)) return QTARGETS; |
219 if (atom == DEVICE_XATOM_NULL (d)) return QNULL; | 200 if (atom == DEVICE_XATOM_NULL (d)) return QNULL; |
220 if (atom == DEVICE_XATOM_ATOM_PAIR (d)) return QATOM_PAIR; | 201 if (atom == DEVICE_XATOM_ATOM_PAIR (d)) return QATOM_PAIR; |
221 if (atom == DEVICE_XATOM_COMPOUND_TEXT (d)) return QCOMPOUND_TEXT; | 202 if (atom == DEVICE_XATOM_COMPOUND_TEXT (d)) return QCOMPOUND_TEXT; |
222 | 203 |
223 #ifdef EPOCH | |
224 if (atom == XA_ARC) return QARC; | |
225 if (atom == XA_BITMAP) return QBITMAP; | |
226 if (atom == XA_CARDINAL) return QCARDINAL; | |
227 if (atom == XA_CURSOR) return QCURSOR; | |
228 if (atom == XA_DRAWABLE) return QDRAWABLE; | |
229 if (atom == XA_FONT) return QFONT; | |
230 if (atom == XA_INTEGER) return QINTEGER; | |
231 if (atom == XA_PIXMAP) return QPIXMAP; | |
232 if (atom == XA_POINT) return QPOINT; | |
233 if (atom == XA_RECTANGLE) return QRECTANGLE; | |
234 if (atom == XA_WINDOW) return QWINDOW; | |
235 if (atom == XA_WM_HINTS) return QWM_HINTS; | |
236 if (atom == XA_WM_SIZE_HINTS) return QWM_SIZE_HINTS; | |
237 #endif /* EPOCH */ | |
238 #ifdef CUT_BUFFER_SUPPORT | 204 #ifdef CUT_BUFFER_SUPPORT |
239 if (atom == XA_CUT_BUFFER0) return QCUT_BUFFER0; | 205 if (atom == XA_CUT_BUFFER0) return QCUT_BUFFER0; |
240 if (atom == XA_CUT_BUFFER1) return QCUT_BUFFER1; | 206 if (atom == XA_CUT_BUFFER1) return QCUT_BUFFER1; |
241 if (atom == XA_CUT_BUFFER2) return QCUT_BUFFER2; | 207 if (atom == XA_CUT_BUFFER2) return QCUT_BUFFER2; |
242 if (atom == XA_CUT_BUFFER3) return QCUT_BUFFER3; | 208 if (atom == XA_CUT_BUFFER3) return QCUT_BUFFER3; |
243 if (atom == XA_CUT_BUFFER4) return QCUT_BUFFER4; | 209 if (atom == XA_CUT_BUFFER4) return QCUT_BUFFER4; |
244 if (atom == XA_CUT_BUFFER5) return QCUT_BUFFER5; | 210 if (atom == XA_CUT_BUFFER5) return QCUT_BUFFER5; |
245 if (atom == XA_CUT_BUFFER6) return QCUT_BUFFER6; | 211 if (atom == XA_CUT_BUFFER6) return QCUT_BUFFER6; |
246 if (atom == XA_CUT_BUFFER7) return QCUT_BUFFER7; | 212 if (atom == XA_CUT_BUFFER7) return QCUT_BUFFER7; |
247 #endif | 213 #endif |
248 | 214 |
249 { | 215 { |
250 Lisp_Object newsym; | 216 Lisp_Object newsym; |
251 CONST char *intstr; | 217 CONST Bufbyte *intstr; |
252 char *str = XGetAtomName (display, atom); | 218 char *str = XGetAtomName (display, atom); |
253 | 219 |
254 if (! str) return Qnil; | 220 if (! str) return Qnil; |
255 | 221 |
256 GET_C_CHARPTR_INT_CTEXT_DATA_ALLOCA (str, intstr); | 222 GET_C_CHARPTR_INT_CTEXT_DATA_ALLOCA (str, intstr); |
257 newsym = intern (intstr); | 223 newsym = intern ((char *) intstr); |
258 XFree (str); | 224 XFree (str); |
259 return newsym; | 225 return newsym; |
260 } | 226 } |
261 } | 227 } |
262 | 228 |
294 Time is a 64-bit quantity and time_t is a 32-bit quantity). | 260 Time is a 64-bit quantity and time_t is a 32-bit quantity). |
295 | 261 |
296 Opaque pointers are the clean way to go here. | 262 Opaque pointers are the clean way to go here. |
297 */ | 263 */ |
298 Lisp_Object selection_time = make_opaque (sizeof (thyme), (void *) &thyme); | 264 Lisp_Object selection_time = make_opaque (sizeof (thyme), (void *) &thyme); |
299 Lisp_Object selection_data = Fcons (selection_name, | 265 Lisp_Object selection_data = list3 (selection_name, |
300 Fcons (selection_value, | 266 selection_value, |
301 Fcons (selection_time, Qnil))); | 267 selection_time); |
302 Lisp_Object prev_value = assq_no_quit (selection_name, Vselection_alist); | 268 Lisp_Object prev_value = assq_no_quit (selection_name, Vselection_alist); |
303 Vselection_alist = Fcons (selection_data, Vselection_alist); | 269 Vselection_alist = Fcons (selection_data, Vselection_alist); |
304 | 270 |
305 /* If we already owned the selection, remove the old selection data. | 271 /* If we already owned the selection, remove the old selection data. |
306 Perhaps we should destructively modify it instead. | 272 Perhaps we should destructively modify it instead. |
369 #else | 335 #else |
370 int dataid; /* 1.2 wants long, but 1.1.5 wants int... */ | 336 int dataid; /* 1.2 wants long, but 1.1.5 wants int... */ |
371 #endif | 337 #endif |
372 XmString fmh; | 338 XmString fmh; |
373 String encoding = "STRING"; | 339 String encoding = "STRING"; |
374 Extbyte *data = XSTRING_DATA (selection_value); | 340 CONST Extbyte *data = XSTRING_DATA (selection_value); |
375 Extcount bytes = XSTRING_LENGTH (selection_value); | 341 Extcount bytes = XSTRING_LENGTH (selection_value); |
376 | 342 |
377 #ifdef MULE | 343 #ifdef MULE |
378 { | 344 { |
379 enum { ASCII, LATIN_1, WORLD } chartypes = ASCII; | 345 enum { ASCII, LATIN_1, WORLD } chartypes = ASCII; |
1066 XVECTOR_DATA (XVECTOR_DATA (vec) [i]) [1] = XVECTOR_DATA (vec2) [1]; | 1032 XVECTOR_DATA (XVECTOR_DATA (vec) [i]) [1] = XVECTOR_DATA (vec2) [1]; |
1067 } | 1033 } |
1068 return vec; | 1034 return vec; |
1069 } | 1035 } |
1070 | 1036 |
1071 #endif | 1037 #endif /* 0 */ |
1072 | 1038 |
1073 | 1039 |
1074 static int reading_selection_reply; | 1040 static Window reading_selection_reply; |
1075 static Atom reading_which_selection; | 1041 static Atom reading_which_selection; |
1076 static int selection_reply_timed_out; | 1042 static int selection_reply_timed_out; |
1077 | 1043 |
1078 static int | 1044 static int |
1079 selection_reply_done (void *ignore) | 1045 selection_reply_done (void *ignore) |
1115 | 1081 |
1116 XConvertSelection (display, selection_atom, type_atom, target_property, | 1082 XConvertSelection (display, selection_atom, type_atom, target_property, |
1117 requestor_window, requestor_time); | 1083 requestor_window, requestor_time); |
1118 | 1084 |
1119 /* Block until the reply has been read. */ | 1085 /* Block until the reply has been read. */ |
1120 reading_selection_reply = (int) requestor_window; | 1086 reading_selection_reply = requestor_window; |
1121 reading_which_selection = selection_atom; | 1087 reading_which_selection = selection_atom; |
1122 selection_reply_timed_out = 0; | 1088 selection_reply_timed_out = 0; |
1123 | 1089 |
1124 speccount = specpdl_depth (); | 1090 speccount = specpdl_depth (); |
1125 | 1091 |
1377 | 1343 |
1378 | 1344 |
1379 static Lisp_Object | 1345 static Lisp_Object |
1380 selection_data_to_lisp_data (struct device *d, | 1346 selection_data_to_lisp_data (struct device *d, |
1381 unsigned char *data, | 1347 unsigned char *data, |
1382 int size, | 1348 size_t size, |
1383 Atom type, | 1349 Atom type, |
1384 int format) | 1350 int format) |
1385 { | 1351 { |
1386 if (type == DEVICE_XATOM_NULL (d)) | 1352 if (type == DEVICE_XATOM_NULL (d)) |
1387 return QNULL; | 1353 return QNULL; |
1396 /* Convert a single atom to a Lisp Symbol. Convert a set of atoms to | 1362 /* Convert a single atom to a Lisp Symbol. Convert a set of atoms to |
1397 a vector of symbols. | 1363 a vector of symbols. |
1398 */ | 1364 */ |
1399 else if (type == XA_ATOM) | 1365 else if (type == XA_ATOM) |
1400 { | 1366 { |
1401 int i; | |
1402 if (size == sizeof (Atom)) | 1367 if (size == sizeof (Atom)) |
1403 return x_atom_to_symbol (d, *((Atom *) data)); | 1368 return x_atom_to_symbol (d, *((Atom *) data)); |
1404 else | 1369 else |
1405 { | 1370 { |
1406 Lisp_Object v = Fmake_vector (make_int (size / sizeof (Atom)), | 1371 int i; |
1407 Qzero); | 1372 int len = size / sizeof (Atom); |
1408 for (i = 0; i < size / sizeof (Atom); i++) | 1373 Lisp_Object v = Fmake_vector (make_int (len), Qzero); |
1409 Faset (v, make_int (i), | 1374 for (i = 0; i < len; i++) |
1410 x_atom_to_symbol (d, ((Atom *) data) [i])); | 1375 Faset (v, make_int (i), x_atom_to_symbol (d, ((Atom *) data) [i])); |
1411 return v; | 1376 return v; |
1412 } | 1377 } |
1413 } | 1378 } |
1414 | 1379 |
1415 /* Convert a single 16 or small 32 bit number to a Lisp Int. | 1380 /* Convert a single 16 or small 32 bit number to a Lisp Int. |
1439 */ | 1404 */ |
1440 else if (format == 16) | 1405 else if (format == 16) |
1441 { | 1406 { |
1442 int i; | 1407 int i; |
1443 Lisp_Object v = make_vector (size / 4, Qzero); | 1408 Lisp_Object v = make_vector (size / 4, Qzero); |
1444 for (i = 0; i < size / 4; i++) | 1409 for (i = 0; i < (int) size / 4; i++) |
1445 { | 1410 { |
1446 int j = (int) ((unsigned short *) data) [i]; | 1411 int j = (int) ((unsigned short *) data) [i]; |
1447 Faset (v, make_int (i), make_int (j)); | 1412 Faset (v, make_int (i), make_int (j)); |
1448 } | 1413 } |
1449 return v; | 1414 return v; |
1450 } | 1415 } |
1451 else | 1416 else |
1452 { | 1417 { |
1453 int i; | 1418 int i; |
1454 Lisp_Object v = make_vector (size / 4, Qzero); | 1419 Lisp_Object v = make_vector (size / 4, Qzero); |
1455 for (i = 0; i < size / 4; i++) | 1420 for (i = 0; i < (int) size / 4; i++) |
1456 { | 1421 { |
1457 unsigned long j = ((unsigned long *) data) [i]; | 1422 unsigned long j = ((unsigned long *) data) [i]; |
1458 Faset (v, make_int (i), word_to_lisp (j)); | 1423 Faset (v, make_int (i), word_to_lisp (j)); |
1459 } | 1424 } |
1460 return v; | 1425 return v; |
1487 *data_ret = 0; | 1452 *data_ret = 0; |
1488 type = QNULL; | 1453 type = QNULL; |
1489 } | 1454 } |
1490 else if (STRINGP (obj)) | 1455 else if (STRINGP (obj)) |
1491 { | 1456 { |
1492 Extbyte *extval; | 1457 CONST Extbyte *extval; |
1493 Extcount extvallen; | 1458 Extcount extvallen; |
1494 | 1459 |
1495 if (NILP (type)) | 1460 if (NILP (type)) |
1496 GET_STRING_CTEXT_DATA_ALLOCA (obj, extval, extvallen); | 1461 GET_STRING_CTEXT_DATA_ALLOCA (obj, extval, extvallen); |
1497 else | 1462 else |
1567 { | 1532 { |
1568 if (NILP (type)) type = QATOM; | 1533 if (NILP (type)) type = QATOM; |
1569 *size_ret = XVECTOR_LENGTH (obj); | 1534 *size_ret = XVECTOR_LENGTH (obj); |
1570 *format_ret = 32; | 1535 *format_ret = 32; |
1571 *data_ret = (unsigned char *) xmalloc ((*size_ret) * sizeof (Atom)); | 1536 *data_ret = (unsigned char *) xmalloc ((*size_ret) * sizeof (Atom)); |
1572 for (i = 0; i < *size_ret; i++) | 1537 for (i = 0; i < (int) (*size_ret); i++) |
1573 if (SYMBOLP (XVECTOR_DATA (obj) [i])) | 1538 if (SYMBOLP (XVECTOR_DATA (obj) [i])) |
1574 (*(Atom **) data_ret) [i] = | 1539 (*(Atom **) data_ret) [i] = |
1575 symbol_to_x_atom (d, XVECTOR_DATA (obj) [i], 0); | 1540 symbol_to_x_atom (d, XVECTOR_DATA (obj) [i], 0); |
1576 else | 1541 else |
1577 signal_error (Qerror, /* Qselection_error */ | 1542 signal_error (Qerror, /* Qselection_error */ |
1614 /* This vector is an INTEGER set, or something like it */ | 1579 /* This vector is an INTEGER set, or something like it */ |
1615 { | 1580 { |
1616 *size_ret = XVECTOR_LENGTH (obj); | 1581 *size_ret = XVECTOR_LENGTH (obj); |
1617 if (NILP (type)) type = QINTEGER; | 1582 if (NILP (type)) type = QINTEGER; |
1618 *format_ret = 16; | 1583 *format_ret = 16; |
1619 for (i = 0; i < *size_ret; i++) | 1584 for (i = 0; i < (int) (*size_ret); i++) |
1620 if (CONSP (XVECTOR_DATA (obj) [i])) | 1585 if (CONSP (XVECTOR_DATA (obj) [i])) |
1621 *format_ret = 32; | 1586 *format_ret = 32; |
1622 else if (!INTP (XVECTOR_DATA (obj) [i])) | 1587 else if (!INTP (XVECTOR_DATA (obj) [i])) |
1623 signal_error (Qerror, /* Qselection_error */ | 1588 signal_error (Qerror, /* Qselection_error */ |
1624 list2 (build_string | 1589 list2 (build_string |
1625 ("all elements of the vector must be integers or conses of integers"), | 1590 ("all elements of the vector must be integers or conses of integers"), |
1626 obj)); | 1591 obj)); |
1627 | 1592 |
1628 *data_ret = (unsigned char *) xmalloc (*size_ret * (*format_ret/8)); | 1593 *data_ret = (unsigned char *) xmalloc (*size_ret * (*format_ret/8)); |
1629 for (i = 0; i < *size_ret; i++) | 1594 for (i = 0; i < (int) (*size_ret); i++) |
1630 if (*format_ret == 32) | 1595 if (*format_ret == 32) |
1631 (*((unsigned long **) data_ret)) [i] = | 1596 (*((unsigned long **) data_ret)) [i] = |
1632 lisp_to_word (XVECTOR_DATA (obj) [i]); | 1597 lisp_to_word (XVECTOR_DATA (obj) [i]); |
1633 else | 1598 else |
1634 (*((unsigned short **) data_ret)) [i] = | 1599 (*((unsigned short **) data_ret)) [i] = |
1808 return Qt; | 1773 return Qt; |
1809 } | 1774 } |
1810 | 1775 |
1811 | 1776 |
1812 DEFUN ("x-selection-owner-p", Fx_selection_owner_p, 0, 1, 0, /* | 1777 DEFUN ("x-selection-owner-p", Fx_selection_owner_p, 0, 1, 0, /* |
1813 Whether the current emacs process owns the given X Selection. | 1778 Return t if current emacs process owns the given X Selection. |
1814 The arg should be the name of the selection in question, typically one of | 1779 The arg should be the name of the selection in question, typically one of |
1815 the symbols PRIMARY, SECONDARY, or CLIPBOARD. (For convenience, the symbol | 1780 the symbols PRIMARY, SECONDARY, or CLIPBOARD. (For convenience, the symbol |
1816 nil is the same as PRIMARY, and t is the same as SECONDARY.) | 1781 nil is the same as PRIMARY, and t is the same as SECONDARY.) |
1817 */ | 1782 */ |
1818 (selection)) | 1783 (selection)) |
1819 { | 1784 { |
1820 CHECK_SYMBOL (selection); | 1785 CHECK_SYMBOL (selection); |
1821 if (EQ (selection, Qnil)) selection = QPRIMARY; | 1786 if (EQ (selection, Qnil)) selection = QPRIMARY; |
1822 if (EQ (selection, Qt)) selection = QSECONDARY; | 1787 else if (EQ (selection, Qt)) selection = QSECONDARY; |
1823 | 1788 |
1824 return NILP (Fassq (selection, Vselection_alist)) ? Qnil: Qt; | 1789 return NILP (Fassq (selection, Vselection_alist)) ? Qnil : Qt; |
1825 } | 1790 } |
1826 | 1791 |
1827 DEFUN ("x-selection-exists-p", Fx_selection_exists_p, 0, 1, 0, /* | 1792 DEFUN ("x-selection-exists-p", Fx_selection_exists_p, 0, 1, 0, /* |
1828 Whether there is an owner for the given X Selection. | 1793 Whether there is an owner for the given X Selection. |
1829 The arg should be the name of the selection in question, typically one of | 1794 The arg should be the name of the selection in question, typically one of |
1924 { | 1889 { |
1925 struct device *d = decode_x_device (Qnil); | 1890 struct device *d = decode_x_device (Qnil); |
1926 Display *display = DEVICE_X_DISPLAY (d); | 1891 Display *display = DEVICE_X_DISPLAY (d); |
1927 Window window = RootWindow (display, 0); /* Cutbuffers are on frame 0 */ | 1892 Window window = RootWindow (display, 0); /* Cutbuffers are on frame 0 */ |
1928 Atom cut_buffer_atom; | 1893 Atom cut_buffer_atom; |
1929 Extbyte *data = XSTRING_DATA (string); | 1894 CONST Extbyte *data = XSTRING_DATA (string); |
1930 Extcount bytes = XSTRING_LENGTH (string); | 1895 Extcount bytes = XSTRING_LENGTH (string); |
1931 Extcount bytes_remaining; | 1896 Extcount bytes_remaining; |
1932 int max_bytes = SELECTION_QUANTUM (display); | 1897 int max_bytes = SELECTION_QUANTUM (display); |
1933 #ifdef MULE | 1898 #ifdef MULE |
1934 CONST Bufbyte *ptr, *end; | 1899 CONST Bufbyte *ptr, *end; |
2055 defsymbol (&QSTRING, "STRING"); | 2020 defsymbol (&QSTRING, "STRING"); |
2056 defsymbol (&QINTEGER, "INTEGER"); | 2021 defsymbol (&QINTEGER, "INTEGER"); |
2057 defsymbol (&QCLIPBOARD, "CLIPBOARD"); | 2022 defsymbol (&QCLIPBOARD, "CLIPBOARD"); |
2058 defsymbol (&QTIMESTAMP, "TIMESTAMP"); | 2023 defsymbol (&QTIMESTAMP, "TIMESTAMP"); |
2059 defsymbol (&QTEXT, "TEXT"); | 2024 defsymbol (&QTEXT, "TEXT"); |
2060 defsymbol (&QTIMESTAMP, "TIMESTAMP"); | |
2061 defsymbol (&QDELETE, "DELETE"); | 2025 defsymbol (&QDELETE, "DELETE"); |
2062 defsymbol (&QMULTIPLE, "MULTIPLE"); | 2026 defsymbol (&QMULTIPLE, "MULTIPLE"); |
2063 defsymbol (&QINCR, "INCR"); | 2027 defsymbol (&QINCR, "INCR"); |
2064 defsymbol (&QEMACS_TMP, "_EMACS_TMP_"); | 2028 defsymbol (&QEMACS_TMP, "_EMACS_TMP_"); |
2065 defsymbol (&QTARGETS, "TARGETS"); | 2029 defsymbol (&QTARGETS, "TARGETS"); |
2066 defsymbol (&QATOM, "ATOM"); | 2030 defsymbol (&QATOM, "ATOM"); |
2067 defsymbol (&QATOM_PAIR, "ATOM_PAIR"); | 2031 defsymbol (&QATOM_PAIR, "ATOM_PAIR"); |
2068 defsymbol (&QCOMPOUND_TEXT, "COMPOUND_TEXT"); | 2032 defsymbol (&QCOMPOUND_TEXT, "COMPOUND_TEXT"); |
2069 defsymbol (&QNULL, "NULL"); | 2033 defsymbol (&QNULL, "NULL"); |
2070 | |
2071 #ifdef EPOCH | |
2072 defsymbol (&QARC, "ARC"); | |
2073 defsymbol (&QBITMAP, "BITMAP"); | |
2074 defsymbol (&QCARDINAL, "CARDINAL"); | |
2075 defsymbol (&QCURSOR, "CURSOR"); | |
2076 defsymbol (&QDRAWABLE, "DRAWABLE"); | |
2077 defsymbol (&QFONT, "FONT"); | |
2078 defsymbol (&QINTEGER, "INTEGER"); | |
2079 defsymbol (&QPIXMAP, "PIXMAP"); | |
2080 defsymbol (&QPOINT, "POINT"); | |
2081 defsymbol (&QRECTANGLE, "RECTANGLE"); | |
2082 defsymbol (&QWINDOW, "WINDOW"); | |
2083 defsymbol (&QWM_HINTS, "WM_HINTS"); | |
2084 defsymbol (&QWM_SIZE_HINTS, "WM_SIZE_HINTS"); | |
2085 #endif /* EPOCH */ | |
2086 | 2034 |
2087 #ifdef CUT_BUFFER_SUPPORT | 2035 #ifdef CUT_BUFFER_SUPPORT |
2088 defsymbol (&QCUT_BUFFER0, "CUT_BUFFER0"); | 2036 defsymbol (&QCUT_BUFFER0, "CUT_BUFFER0"); |
2089 defsymbol (&QCUT_BUFFER1, "CUT_BUFFER1"); | 2037 defsymbol (&QCUT_BUFFER1, "CUT_BUFFER1"); |
2090 defsymbol (&QCUT_BUFFER2, "CUT_BUFFER2"); | 2038 defsymbol (&QCUT_BUFFER2, "CUT_BUFFER2"); |