428
|
1 /* X Selection processing for XEmacs
|
|
2 Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
793
|
3 Copyright (C) 2001, 2002 Ben Wing.
|
428
|
4
|
|
5 This file is part of XEmacs.
|
|
6
|
|
7 XEmacs is free software; you can redistribute it and/or modify it
|
|
8 under the terms of the GNU General Public License as published by the
|
|
9 Free Software Foundation; either version 2, or (at your option) any
|
|
10 later version.
|
|
11
|
|
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
15 for more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License
|
|
18 along with XEmacs; see the file COPYING. If not, write to
|
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
20 Boston, MA 02111-1307, USA. */
|
|
21
|
|
22 /* Synched up with: Not synched with FSF. */
|
|
23
|
|
24 /* Rewritten by jwz */
|
|
25
|
|
26 #include <config.h>
|
|
27 #include "lisp.h"
|
|
28
|
771
|
29 #include "charset.h"
|
872
|
30 #include "device-impl.h"
|
|
31 #include "frame-impl.h"
|
800
|
32 #include "opaque.h"
|
|
33 #include "select.h"
|
|
34
|
872
|
35 #include "console-x-impl.h"
|
428
|
36 #include "objects-x.h"
|
|
37
|
|
38 #include "systime.h"
|
|
39
|
|
40 int lisp_to_time (Lisp_Object, time_t *);
|
|
41 Lisp_Object time_to_lisp (time_t);
|
|
42
|
|
43 #ifdef LWLIB_USES_MOTIF
|
|
44 # define MOTIF_CLIPBOARDS
|
|
45 #endif
|
|
46
|
|
47 #ifdef MOTIF_CLIPBOARDS
|
1315
|
48 # include "xmotif.h"
|
|
49 /* Kludge around shadowing warnings */
|
|
50 # define index index_
|
428
|
51 # include <Xm/CutPaste.h>
|
1315
|
52 # undef index
|
428
|
53 static void hack_motif_clipboard_selection (Atom selection_atom,
|
|
54 Lisp_Object selection_value,
|
|
55 Time thyme, Display *display,
|
456
|
56 Window selecting_window,
|
|
57 int owned_p);
|
428
|
58 #endif
|
|
59
|
|
60 #define CUT_BUFFER_SUPPORT
|
|
61
|
|
62 #ifdef CUT_BUFFER_SUPPORT
|
|
63 Lisp_Object QCUT_BUFFER0, QCUT_BUFFER1, QCUT_BUFFER2, QCUT_BUFFER3,
|
|
64 QCUT_BUFFER4, QCUT_BUFFER5, QCUT_BUFFER6, QCUT_BUFFER7;
|
|
65 #endif
|
|
66
|
|
67 Lisp_Object Vx_sent_selection_hooks;
|
|
68
|
|
69 /* If this is a smaller number than the max-request-size of the display,
|
|
70 emacs will use INCR selection transfer when the selection is larger
|
|
71 than this. The max-request-size is usually around 64k, so if you want
|
|
72 emacs to use incremental selection transfers when the selection is
|
|
73 smaller than that, set this. I added this mostly for debugging the
|
|
74 incremental transfer stuff, but it might improve server performance.
|
|
75 */
|
|
76 #define MAX_SELECTION_QUANTUM 0xFFFFFF
|
|
77
|
|
78 #define SELECTION_QUANTUM(dpy) ((XMaxRequestSize (dpy) << 2) - 100)
|
|
79
|
|
80 /* If the selection owner takes too long to reply to a selection request,
|
|
81 we give up on it. This is in seconds (0 = no timeout).
|
|
82 */
|
458
|
83 Fixnum x_selection_timeout;
|
428
|
84
|
456
|
85 /* Enable motif selection optimizations. */
|
|
86 int x_selection_strict_motif_ownership;
|
|
87
|
428
|
88
|
|
89 /* Utility functions */
|
|
90
|
|
91 static Lisp_Object x_get_window_property_as_lisp_data (Display *,
|
|
92 Window,
|
|
93 Atom property,
|
|
94 Lisp_Object target_type,
|
|
95 Atom selection_atom);
|
|
96
|
|
97 static int expect_property_change (Display *, Window, Atom prop, int state);
|
|
98 static void wait_for_property_change (long);
|
|
99 static void unexpect_property_change (int);
|
|
100 static int waiting_for_other_props_on_window (Display *, Window);
|
|
101
|
|
102 /* This converts a Lisp symbol to a server Atom, avoiding a server
|
|
103 roundtrip whenever possible.
|
|
104 */
|
|
105 static Atom
|
|
106 symbol_to_x_atom (struct device *d, Lisp_Object sym, int only_if_exists)
|
|
107 {
|
|
108 Display *display = DEVICE_X_DISPLAY (d);
|
|
109
|
|
110 if (NILP (sym)) return XA_PRIMARY;
|
|
111 if (EQ (sym, Qt)) return XA_SECONDARY;
|
|
112 if (EQ (sym, QPRIMARY)) return XA_PRIMARY;
|
|
113 if (EQ (sym, QSECONDARY)) return XA_SECONDARY;
|
|
114 if (EQ (sym, QSTRING)) return XA_STRING;
|
|
115 if (EQ (sym, QINTEGER)) return XA_INTEGER;
|
|
116 if (EQ (sym, QATOM)) return XA_ATOM;
|
|
117 if (EQ (sym, QCLIPBOARD)) return DEVICE_XATOM_CLIPBOARD (d);
|
|
118 if (EQ (sym, QTIMESTAMP)) return DEVICE_XATOM_TIMESTAMP (d);
|
|
119 if (EQ (sym, QTEXT)) return DEVICE_XATOM_TEXT (d);
|
|
120 if (EQ (sym, QDELETE)) return DEVICE_XATOM_DELETE (d);
|
|
121 if (EQ (sym, QMULTIPLE)) return DEVICE_XATOM_MULTIPLE (d);
|
|
122 if (EQ (sym, QINCR)) return DEVICE_XATOM_INCR (d);
|
|
123 if (EQ (sym, QEMACS_TMP)) return DEVICE_XATOM_EMACS_TMP (d);
|
|
124 if (EQ (sym, QTARGETS)) return DEVICE_XATOM_TARGETS (d);
|
|
125 if (EQ (sym, QNULL)) return DEVICE_XATOM_NULL (d);
|
|
126 if (EQ (sym, QATOM_PAIR)) return DEVICE_XATOM_ATOM_PAIR (d);
|
|
127 if (EQ (sym, QCOMPOUND_TEXT)) return DEVICE_XATOM_COMPOUND_TEXT (d);
|
|
128
|
|
129 #ifdef CUT_BUFFER_SUPPORT
|
|
130 if (EQ (sym, QCUT_BUFFER0)) return XA_CUT_BUFFER0;
|
|
131 if (EQ (sym, QCUT_BUFFER1)) return XA_CUT_BUFFER1;
|
|
132 if (EQ (sym, QCUT_BUFFER2)) return XA_CUT_BUFFER2;
|
|
133 if (EQ (sym, QCUT_BUFFER3)) return XA_CUT_BUFFER3;
|
|
134 if (EQ (sym, QCUT_BUFFER4)) return XA_CUT_BUFFER4;
|
|
135 if (EQ (sym, QCUT_BUFFER5)) return XA_CUT_BUFFER5;
|
|
136 if (EQ (sym, QCUT_BUFFER6)) return XA_CUT_BUFFER6;
|
|
137 if (EQ (sym, QCUT_BUFFER7)) return XA_CUT_BUFFER7;
|
|
138 #endif /* CUT_BUFFER_SUPPORT */
|
|
139
|
|
140 {
|
647
|
141 const Extbyte *nameext;
|
442
|
142 LISP_STRING_TO_EXTERNAL (Fsymbol_name (sym), nameext, Qctext);
|
428
|
143 return XInternAtom (display, nameext, only_if_exists ? True : False);
|
|
144 }
|
|
145 }
|
|
146
|
|
147
|
|
148 /* This converts a server Atom to a Lisp symbol, avoiding server roundtrips
|
|
149 and calls to intern whenever possible.
|
|
150 */
|
|
151 static Lisp_Object
|
|
152 x_atom_to_symbol (struct device *d, Atom atom)
|
|
153 {
|
|
154 Display *display = DEVICE_X_DISPLAY (d);
|
|
155
|
|
156 if (! atom) return Qnil;
|
|
157 if (atom == XA_PRIMARY) return QPRIMARY;
|
|
158 if (atom == XA_SECONDARY) return QSECONDARY;
|
|
159 if (atom == XA_STRING) return QSTRING;
|
|
160 if (atom == XA_INTEGER) return QINTEGER;
|
|
161 if (atom == XA_ATOM) return QATOM;
|
|
162 if (atom == DEVICE_XATOM_CLIPBOARD (d)) return QCLIPBOARD;
|
|
163 if (atom == DEVICE_XATOM_TIMESTAMP (d)) return QTIMESTAMP;
|
|
164 if (atom == DEVICE_XATOM_TEXT (d)) return QTEXT;
|
|
165 if (atom == DEVICE_XATOM_DELETE (d)) return QDELETE;
|
|
166 if (atom == DEVICE_XATOM_MULTIPLE (d)) return QMULTIPLE;
|
|
167 if (atom == DEVICE_XATOM_INCR (d)) return QINCR;
|
|
168 if (atom == DEVICE_XATOM_EMACS_TMP (d)) return QEMACS_TMP;
|
|
169 if (atom == DEVICE_XATOM_TARGETS (d)) return QTARGETS;
|
|
170 if (atom == DEVICE_XATOM_NULL (d)) return QNULL;
|
|
171 if (atom == DEVICE_XATOM_ATOM_PAIR (d)) return QATOM_PAIR;
|
|
172 if (atom == DEVICE_XATOM_COMPOUND_TEXT (d)) return QCOMPOUND_TEXT;
|
|
173
|
|
174 #ifdef CUT_BUFFER_SUPPORT
|
|
175 if (atom == XA_CUT_BUFFER0) return QCUT_BUFFER0;
|
|
176 if (atom == XA_CUT_BUFFER1) return QCUT_BUFFER1;
|
|
177 if (atom == XA_CUT_BUFFER2) return QCUT_BUFFER2;
|
|
178 if (atom == XA_CUT_BUFFER3) return QCUT_BUFFER3;
|
|
179 if (atom == XA_CUT_BUFFER4) return QCUT_BUFFER4;
|
|
180 if (atom == XA_CUT_BUFFER5) return QCUT_BUFFER5;
|
|
181 if (atom == XA_CUT_BUFFER6) return QCUT_BUFFER6;
|
|
182 if (atom == XA_CUT_BUFFER7) return QCUT_BUFFER7;
|
|
183 #endif
|
|
184
|
|
185 {
|
867
|
186 Ibyte *intstr;
|
771
|
187 Extbyte *str = XGetAtomName (display, atom);
|
428
|
188
|
|
189 if (! str) return Qnil;
|
|
190
|
440
|
191 TO_INTERNAL_FORMAT (C_STRING, str,
|
|
192 C_STRING_ALLOCA, intstr,
|
|
193 Qctext);
|
428
|
194 XFree (str);
|
771
|
195 return intern_int (intstr);
|
428
|
196 }
|
|
197 }
|
|
198
|
647
|
199 #define PROCESSING_X_CODE
|
|
200 #include "select-common.h"
|
|
201 #undef PROCESSING_X_CODE
|
428
|
202
|
|
203 /* Do protocol to assert ourself as a selection owner.
|
|
204 */
|
|
205 static Lisp_Object
|
2286
|
206 x_own_selection (Lisp_Object selection_name,
|
|
207 #ifdef MOTIF_CLIPBOARDS
|
|
208 Lisp_Object selection_value,
|
|
209 #else
|
|
210 Lisp_Object UNUSED (selection_value),
|
|
211 #endif
|
|
212 Lisp_Object UNUSED (how_to_add),
|
|
213 Lisp_Object UNUSED (selection_type),
|
|
214 #ifdef MOTIF_CLIPBOARDS
|
|
215 int owned_p
|
|
216 #else
|
|
217 int UNUSED (owned_p)
|
|
218 #endif
|
|
219 )
|
428
|
220 {
|
|
221 struct device *d = decode_x_device (Qnil);
|
|
222 Display *display = DEVICE_X_DISPLAY (d);
|
|
223 struct frame *sel_frame = selected_frame ();
|
|
224 Window selecting_window = XtWindow (FRAME_X_TEXT_WIDGET (sel_frame));
|
|
225 Lisp_Object selection_time;
|
|
226 /* Use the time of the last-read mouse or keyboard event.
|
|
227 For selection purposes, we use this as a sleazy way of knowing what the
|
|
228 current time is in server-time. This assumes that the most recently read
|
|
229 mouse or keyboard event has something to do with the assertion of the
|
|
230 selection, which is probably true.
|
|
231 */
|
|
232 Time thyme = DEVICE_X_MOUSE_TIMESTAMP (d);
|
|
233 Atom selection_atom;
|
|
234
|
|
235 CHECK_SYMBOL (selection_name);
|
|
236 selection_atom = symbol_to_x_atom (d, selection_name, 0);
|
|
237
|
|
238 XSetSelectionOwner (display, selection_atom, selecting_window, thyme);
|
|
239
|
2620
|
240 /* [[ We do NOT use time_to_lisp() here any more, like we used to.
|
428
|
241 That assumed equivalence of time_t and Time, which is not
|
|
242 necessarily the case (e.g. under OSF on the Alphas, where
|
2620
|
243 Time is a 64-bit quantity and time_t is a 32-bit quantity).]]
|
|
244
|
|
245 This is wrong--on Digital Unix, time_t is a sixty-four-bit quantity,
|
|
246 and Time is, as the X protocol dictates, a thirty-two-bit quantity.
|
442
|
247
|
2620
|
248 [[ Opaque pointers are the clean way to go here. ]]
|
|
249
|
|
250 Again, I disagree--the Lisp selection infrastructure needs to be
|
|
251 able to manipulate the selection timestamps if it is, as we want
|
|
252 it to, to be able to do most of the work. Though I have moved the
|
|
253 conversion to lisp to get-xemacs-selection-timestamp. -- Aidan. */
|
|
254
|
440
|
255 selection_time = make_opaque (&thyme, sizeof (thyme));
|
428
|
256
|
|
257 #ifdef MOTIF_CLIPBOARDS
|
|
258 hack_motif_clipboard_selection (selection_atom, selection_value,
|
456
|
259 thyme, display, selecting_window, owned_p);
|
428
|
260 #endif
|
|
261 return selection_time;
|
|
262 }
|
|
263
|
|
264 #ifdef MOTIF_CLIPBOARDS /* Bend over baby. Take it and like it. */
|
|
265
|
|
266 # ifdef MOTIF_INCREMENTAL_CLIPBOARDS_WORK
|
|
267 static void motif_clipboard_cb ();
|
|
268 # endif
|
|
269
|
|
270 static void
|
|
271 hack_motif_clipboard_selection (Atom selection_atom,
|
|
272 Lisp_Object selection_value,
|
|
273 Time thyme,
|
|
274 Display *display,
|
456
|
275 Window selecting_window,
|
|
276 int owned_p)
|
428
|
277 {
|
|
278 struct device *d = get_device_from_display (display);
|
|
279 /* Those Motif wankers can't be bothered to follow the ICCCM, and do
|
|
280 their own non-Xlib non-Xt clipboard processing. So we have to do
|
|
281 this so that linked-in Motif widgets don't get themselves wedged.
|
|
282 */
|
|
283 if (selection_atom == DEVICE_XATOM_CLIPBOARD (d)
|
|
284 && STRINGP (selection_value)
|
|
285
|
|
286 /* If we already own the clipboard, don't own it again in the Motif
|
|
287 way. This might lose in some subtle way, since the timestamp won't
|
|
288 be current, but owning the selection on the Motif way does a
|
|
289 SHITLOAD of X protocol, and it makes killing text be incredibly
|
|
290 slow when using an X terminal. ARRRRGGGHHH!!!!
|
|
291 */
|
|
292 /* No, this is no good, because then Motif text fields don't bother
|
|
293 to look up the new value, and you can't Copy from a buffer, Paste
|
|
294 into a text field, then Copy something else from the buffer and
|
|
295 paste it into the text field -- it pastes the first thing again. */
|
456
|
296 && (!owned_p
|
|
297 /* Selectively re-enable this because for most users its
|
|
298 just too painful - especially over a remote link. */
|
|
299 || x_selection_strict_motif_ownership)
|
428
|
300 )
|
|
301 {
|
|
302 #ifdef MOTIF_INCREMENTAL_CLIPBOARDS_WORK
|
|
303 Widget widget = FRAME_X_TEXT_WIDGET (selected_frame());
|
|
304 #endif
|
|
305 long itemid;
|
|
306 #if XmVersion >= 1002
|
|
307 long dataid;
|
|
308 #else
|
|
309 int dataid; /* 1.2 wants long, but 1.1.5 wants int... */
|
|
310 #endif
|
|
311 XmString fmh;
|
|
312 String encoding = "STRING";
|
867
|
313 const Ibyte *data = XSTRING_DATA (selection_value);
|
444
|
314 Bytecount bytes = XSTRING_LENGTH (selection_value);
|
428
|
315
|
|
316 #ifdef MULE
|
|
317 {
|
|
318 enum { ASCII, LATIN_1, WORLD } chartypes = ASCII;
|
867
|
319 const Ibyte *ptr = data, *end = ptr + bytes;
|
428
|
320 /* Optimize for the common ASCII case */
|
|
321 while (ptr <= end)
|
|
322 {
|
826
|
323 if (byte_ascii_p (*ptr))
|
428
|
324 {
|
|
325 ptr++;
|
|
326 continue;
|
|
327 }
|
|
328
|
|
329 if ((*ptr) == LEADING_BYTE_LATIN_ISO8859_1 ||
|
|
330 (*ptr) == LEADING_BYTE_CONTROL_1)
|
|
331 {
|
|
332 chartypes = LATIN_1;
|
|
333 ptr += 2;
|
|
334 continue;
|
|
335 }
|
|
336
|
|
337 chartypes = WORLD;
|
|
338 break;
|
|
339 }
|
|
340
|
|
341 if (chartypes == LATIN_1)
|
440
|
342 TO_EXTERNAL_FORMAT (LISP_STRING, selection_value,
|
|
343 ALLOCA, (data, bytes),
|
|
344 Qbinary);
|
428
|
345 else if (chartypes == WORLD)
|
|
346 {
|
440
|
347 TO_EXTERNAL_FORMAT (LISP_STRING, selection_value,
|
|
348 ALLOCA, (data, bytes),
|
|
349 Qctext);
|
428
|
350 encoding = "COMPOUND_TEXT";
|
|
351 }
|
|
352 }
|
|
353 #endif /* MULE */
|
|
354
|
|
355 fmh = XmStringCreateLtoR ("Clipboard", XmSTRING_DEFAULT_CHARSET);
|
|
356 while (ClipboardSuccess !=
|
|
357 XmClipboardStartCopy (display, selecting_window, fmh, thyme,
|
|
358 #ifdef MOTIF_INCREMENTAL_CLIPBOARDS_WORK
|
|
359 widget, motif_clipboard_cb,
|
|
360 #else
|
|
361 0, NULL,
|
|
362 #endif
|
|
363 &itemid))
|
|
364 ;
|
|
365 XmStringFree (fmh);
|
|
366 while (ClipboardSuccess !=
|
|
367 XmClipboardCopy (display, selecting_window, itemid, encoding,
|
|
368 #ifdef MOTIF_INCREMENTAL_CLIPBOARDS_WORK
|
|
369 /* O'Reilly examples say size can be 0,
|
|
370 but this clearly is not the case. */
|
|
371 0, bytes, (int) selecting_window, /* private id */
|
|
372 #else /* !MOTIF_INCREMENTAL_CLIPBOARDS_WORK */
|
|
373 (XtPointer) data, bytes, 0,
|
|
374 #endif /* !MOTIF_INCREMENTAL_CLIPBOARDS_WORK */
|
|
375 &dataid))
|
|
376 ;
|
|
377 while (ClipboardSuccess !=
|
|
378 XmClipboardEndCopy (display, selecting_window, itemid))
|
|
379 ;
|
|
380 }
|
|
381 }
|
|
382
|
|
383 # ifdef MOTIF_INCREMENTAL_CLIPBOARDS_WORK
|
|
384 /* I tried to treat the clipboard like a real selection, and not send
|
|
385 the data until it was requested, but it looks like that just doesn't
|
|
386 work at all unless the selection owner and requestor are in different
|
|
387 processes. From reading the Motif source, it looks like they never
|
|
388 even considered having two widgets in the same application transfer
|
|
389 data between each other using "by-name" clipboard values. What a
|
|
390 bunch of fuckups.
|
|
391 */
|
|
392 static void
|
|
393 motif_clipboard_cb (Widget widget, int *data_id, int *private_id, int *reason)
|
|
394 {
|
|
395 switch (*reason)
|
|
396 {
|
|
397 case XmCR_CLIPBOARD_DATA_REQUEST:
|
|
398 {
|
|
399 Display *dpy = XtDisplay (widget);
|
|
400 Window window = (Window) *private_id;
|
442
|
401 Lisp_Object selection = select_convert_out (QCLIPBOARD, Qnil, Qnil);
|
|
402
|
2500
|
403 /* Whichever lazy git wrote this originally just called ABORT()
|
442
|
404 when anything didn't go their way... */
|
|
405
|
|
406 /* Try some other text types */
|
|
407 if (NILP (selection))
|
|
408 selection = select_convert_out (QCLIPBOARD, QSTRING, Qnil);
|
|
409 if (NILP (selection))
|
|
410 selection = select_convert_out (QCLIPBOARD, QTEXT, Qnil);
|
|
411 if (NILP (selection))
|
|
412 selection = select_convert_out (QCLIPBOARD, QCOMPOUND_TEXT, Qnil);
|
|
413
|
|
414 if (CONSP (selection) && SYMBOLP (XCAR (selection))
|
|
415 && (EQ (XCAR (selection), QSTRING)
|
|
416 || EQ (XCAR (selection), QTEXT)
|
|
417 || EQ (XCAR (selection), QCOMPOUND_TEXT)))
|
|
418 selection = XCDR (selection);
|
|
419
|
|
420 if (NILP (selection))
|
563
|
421 signal_error (Qselection_conversion_error, "no selection",
|
|
422 Qunbound);
|
442
|
423
|
|
424 if (!STRINGP (selection))
|
|
425 signal_error (Qselection_conversion_error,
|
563
|
426 "couldn't convert selection to string", Qunbound);
|
442
|
427
|
|
428
|
428
|
429 XmClipboardCopyByName (dpy, window, *data_id,
|
|
430 (char *) XSTRING_DATA (selection),
|
|
431 XSTRING_LENGTH (selection) + 1,
|
|
432 0);
|
|
433 }
|
|
434 break;
|
|
435 case XmCR_CLIPBOARD_DATA_DELETE:
|
|
436 default:
|
|
437 /* don't need to free anything */
|
|
438 break;
|
|
439 }
|
|
440 }
|
|
441 # endif /* MOTIF_INCREMENTAL_CLIPBOARDS_WORK */
|
|
442 #endif /* MOTIF_CLIPBOARDS */
|
|
443
|
|
444
|
|
445
|
|
446
|
|
447 /* Send a SelectionNotify event to the requestor with property=None, meaning
|
|
448 we were unable to do what they wanted.
|
|
449 */
|
|
450 static void
|
|
451 x_decline_selection_request (XSelectionRequestEvent *event)
|
|
452 {
|
|
453 XSelectionEvent reply;
|
|
454 reply.type = SelectionNotify;
|
|
455 reply.display = event->display;
|
|
456 reply.requestor = event->requestor;
|
|
457 reply.selection = event->selection;
|
|
458 reply.time = event->time;
|
|
459 reply.target = event->target;
|
|
460 reply.property = None;
|
|
461
|
|
462 XSendEvent (reply.display, reply.requestor, False, 0L, (XEvent *) &reply);
|
|
463 XFlush (reply.display);
|
|
464 }
|
|
465
|
|
466
|
|
467 /* Used as an unwind-protect clause so that, if a selection-converter signals
|
|
468 an error, we tell the requestor that we were unable to do what they wanted
|
|
469 before we throw to top-level or go into the debugger or whatever.
|
|
470 */
|
|
471 static Lisp_Object
|
|
472 x_selection_request_lisp_error (Lisp_Object closure)
|
|
473 {
|
|
474 XSelectionRequestEvent *event = (XSelectionRequestEvent *)
|
|
475 get_opaque_ptr (closure);
|
|
476
|
|
477 free_opaque_ptr (closure);
|
|
478 if (event->type == 0) /* we set this to mean "completed normally" */
|
|
479 return Qnil;
|
|
480 x_decline_selection_request (event);
|
|
481 return Qnil;
|
|
482 }
|
|
483
|
|
484
|
|
485 /* Convert our selection to the requested type, and put that data where the
|
|
486 requestor wants it. Then tell them whether we've succeeded.
|
|
487 */
|
|
488 static void
|
|
489 x_reply_selection_request (XSelectionRequestEvent *event, int format,
|
2367
|
490 Rawbyte *data, Bytecount size, Atom type)
|
428
|
491 {
|
|
492 /* This function can GC */
|
|
493 XSelectionEvent reply;
|
|
494 Display *display = event->display;
|
|
495 struct device *d = get_device_from_display (display);
|
|
496 Window window = event->requestor;
|
665
|
497 Bytecount bytes_remaining;
|
428
|
498 int format_bytes = format/8;
|
665
|
499 Bytecount max_bytes = SELECTION_QUANTUM (display);
|
428
|
500 if (max_bytes > MAX_SELECTION_QUANTUM) max_bytes = MAX_SELECTION_QUANTUM;
|
|
501
|
|
502 reply.type = SelectionNotify;
|
|
503 reply.display = display;
|
|
504 reply.requestor = window;
|
|
505 reply.selection = event->selection;
|
|
506 reply.time = event->time;
|
|
507 reply.target = event->target;
|
|
508 reply.property = (event->property == None ? event->target : event->property);
|
|
509
|
|
510 /* #### XChangeProperty can generate BadAlloc, and we must handle it! */
|
|
511
|
|
512 /* Store the data on the requested property.
|
|
513 If the selection is large, only store the first N bytes of it.
|
|
514 */
|
|
515 bytes_remaining = size * format_bytes;
|
|
516 if (bytes_remaining <= max_bytes)
|
|
517 {
|
|
518 /* Send all the data at once, with minimal handshaking. */
|
|
519 #if 0
|
|
520 stderr_out ("\nStoring all %d\n", bytes_remaining);
|
|
521 #endif
|
|
522 XChangeProperty (display, window, reply.property, type, format,
|
|
523 PropModeReplace, data, size);
|
|
524 /* At this point, the selection was successfully stored; ack it. */
|
|
525 XSendEvent (display, window, False, 0L, (XEvent *) &reply);
|
|
526 XFlush (display);
|
|
527 }
|
|
528 else
|
|
529 {
|
|
530 /* Send an INCR selection. */
|
|
531 int prop_id;
|
2619
|
532 Widget widget = FRAME_X_TEXT_WIDGET (DEVICE_SELECTED_FRAME(d));
|
428
|
533
|
|
534 if (x_window_to_frame (d, window)) /* #### debug */
|
2619
|
535 invalid_operation ("attempt to transfer an INCR to ourself!",
|
|
536 Qunbound);
|
428
|
537 #if 0
|
|
538 stderr_out ("\nINCR %d\n", bytes_remaining);
|
|
539 #endif
|
2619
|
540
|
|
541 /* Tell Xt not to drop PropertyNotify events that arrive for the
|
|
542 target window, rather, pass them to us. This would be a hack, but
|
|
543 the Xt selection routines are broken for our purposes--we can't
|
|
544 pass them callbacks from Lisp, for example. Let's call it a
|
|
545 workaround. */
|
|
546 XtRegisterDrawable(display, (Drawable)window, widget);
|
|
547
|
428
|
548 prop_id = expect_property_change (display, window, reply.property,
|
|
549 PropertyDelete);
|
|
550
|
|
551 XChangeProperty (display, window, reply.property, DEVICE_XATOM_INCR (d),
|
2367
|
552 32, PropModeReplace, (Rawbyte *)
|
428
|
553 &bytes_remaining, 1);
|
|
554 XSelectInput (display, window, PropertyChangeMask);
|
|
555 /* Tell 'em the INCR data is there... */
|
|
556 XSendEvent (display, window, False, 0L, (XEvent *) &reply);
|
|
557 XFlush (display);
|
|
558
|
|
559 /* First, wait for the requestor to ack by deleting the property.
|
|
560 This can run random lisp code (process handlers) or signal.
|
|
561 */
|
|
562 wait_for_property_change (prop_id);
|
|
563
|
|
564 while (bytes_remaining)
|
|
565 {
|
665
|
566 Bytecount i = ((bytes_remaining < max_bytes)
|
428
|
567 ? bytes_remaining
|
|
568 : max_bytes);
|
|
569 prop_id = expect_property_change (display, window, reply.property,
|
|
570 PropertyDelete);
|
|
571 #if 0
|
|
572 stderr_out (" INCR adding %d\n", i);
|
|
573 #endif
|
|
574 /* Append the next chunk of data to the property. */
|
|
575 XChangeProperty (display, window, reply.property, type, format,
|
|
576 PropModeAppend, data, i / format_bytes);
|
|
577 bytes_remaining -= i;
|
|
578 data += i;
|
|
579
|
|
580 /* Now wait for the requestor to ack this chunk by deleting the
|
|
581 property. This can run random lisp code or signal.
|
|
582 */
|
|
583 wait_for_property_change (prop_id);
|
|
584 }
|
|
585 /* Now write a zero-length chunk to the property to tell the requestor
|
|
586 that we're done. */
|
|
587 #if 0
|
|
588 stderr_out (" INCR done\n");
|
|
589 #endif
|
|
590 if (! waiting_for_other_props_on_window (display, window))
|
2619
|
591 {
|
428
|
592 XSelectInput (display, window, 0L);
|
2619
|
593 XtUnregisterDrawable(display, (Drawable)window);
|
|
594 }
|
428
|
595 XChangeProperty (display, window, reply.property, type, format,
|
|
596 PropModeReplace, data, 0);
|
|
597 }
|
|
598 }
|
|
599
|
|
600
|
|
601
|
|
602 /* Called from the event-loop in response to a SelectionRequest event.
|
|
603 */
|
|
604 void
|
|
605 x_handle_selection_request (XSelectionRequestEvent *event)
|
|
606 {
|
|
607 /* This function can GC */
|
442
|
608 struct gcpro gcpro1, gcpro2;
|
|
609 Lisp_Object temp_obj;
|
428
|
610 Lisp_Object selection_symbol;
|
|
611 Lisp_Object target_symbol = Qnil;
|
|
612 Lisp_Object converted_selection = Qnil;
|
|
613 Time local_selection_time;
|
|
614 Lisp_Object successful_p = Qnil;
|
|
615 int count;
|
|
616 struct device *d = get_device_from_display (event->display);
|
|
617
|
442
|
618 GCPRO2 (converted_selection, target_symbol);
|
428
|
619
|
|
620 selection_symbol = x_atom_to_symbol (d, event->selection);
|
442
|
621 target_symbol = x_atom_to_symbol (d, event->target);
|
428
|
622
|
442
|
623 #if 0 /* #### MULTIPLE doesn't work yet */
|
|
624 if (EQ (target_symbol, QMULTIPLE))
|
|
625 target_symbol = fetch_multiple_target (event);
|
428
|
626 #endif
|
|
627
|
2620
|
628 temp_obj = get_selection_raw_time (selection_symbol);
|
442
|
629
|
|
630 if (NILP (temp_obj))
|
428
|
631 {
|
442
|
632 /* We don't appear to have the selection. */
|
428
|
633 x_decline_selection_request (event);
|
442
|
634
|
428
|
635 goto DONE_LABEL;
|
|
636 }
|
|
637
|
442
|
638 local_selection_time = * (Time *) XOPAQUE_DATA (temp_obj);
|
428
|
639
|
|
640 if (event->time != CurrentTime &&
|
|
641 local_selection_time > event->time)
|
|
642 {
|
|
643 /* Someone asked for the selection, and we have one, but not the one
|
|
644 they're looking for. */
|
|
645 x_decline_selection_request (event);
|
|
646 goto DONE_LABEL;
|
|
647 }
|
|
648
|
442
|
649 converted_selection = select_convert_out (selection_symbol,
|
|
650 target_symbol, Qnil);
|
|
651
|
|
652 /* #### Is this the right thing to do? I'm no X expert. -- ajh */
|
|
653 if (NILP (converted_selection))
|
|
654 {
|
|
655 /* We don't appear to have a selection in that data type. */
|
|
656 x_decline_selection_request (event);
|
|
657 goto DONE_LABEL;
|
|
658 }
|
|
659
|
428
|
660 count = specpdl_depth ();
|
|
661 record_unwind_protect (x_selection_request_lisp_error,
|
|
662 make_opaque_ptr (event));
|
|
663
|
442
|
664 {
|
2367
|
665 Rawbyte *data;
|
665
|
666 Bytecount size;
|
442
|
667 int format;
|
|
668 Atom type;
|
|
669 lisp_data_to_selection_data (d, converted_selection,
|
|
670 &data, &type, &size, &format);
|
428
|
671
|
442
|
672 x_reply_selection_request (event, format, data, size, type);
|
|
673 successful_p = Qt;
|
|
674 /* Tell x_selection_request_lisp_error() it's cool. */
|
|
675 event->type = 0;
|
2620
|
676 /* Data need not have been allocated; cf. select-convert-to-delete in
|
|
677 lisp/select.el . */
|
|
678 if ((Rawbyte *)0 != data)
|
|
679 {
|
|
680 xfree (data, Rawbyte *);
|
|
681 }
|
442
|
682 }
|
|
683
|
771
|
684 unbind_to (count);
|
428
|
685
|
|
686 DONE_LABEL:
|
|
687
|
|
688 UNGCPRO;
|
|
689
|
|
690 /* Let random lisp code notice that the selection has been asked for. */
|
|
691 {
|
|
692 Lisp_Object val = Vx_sent_selection_hooks;
|
|
693 if (!UNBOUNDP (val) && !NILP (val))
|
|
694 {
|
442
|
695 Lisp_Object rest;
|
428
|
696 if (CONSP (val) && !EQ (XCAR (val), Qlambda))
|
|
697 for (rest = val; !NILP (rest); rest = Fcdr (rest))
|
442
|
698 call3 (Fcar (rest), selection_symbol, target_symbol, successful_p);
|
428
|
699 else
|
442
|
700 call3 (val, selection_symbol, target_symbol, successful_p);
|
428
|
701 }
|
|
702 }
|
|
703 }
|
|
704
|
|
705
|
|
706 /* Called from the event-loop in response to a SelectionClear event.
|
|
707 */
|
|
708 void
|
|
709 x_handle_selection_clear (XSelectionClearEvent *event)
|
|
710 {
|
|
711 Display *display = event->display;
|
|
712 struct device *d = get_device_from_display (display);
|
|
713 Atom selection = event->selection;
|
|
714 Time changed_owner_time = event->time;
|
|
715
|
442
|
716 Lisp_Object selection_symbol, local_selection_time_lisp;
|
428
|
717 Time local_selection_time;
|
|
718
|
|
719 selection_symbol = x_atom_to_symbol (d, selection);
|
|
720
|
2620
|
721 local_selection_time_lisp = get_selection_raw_time (selection_symbol);
|
428
|
722
|
442
|
723 /* We don't own the selection, so that's fine. */
|
|
724 if (NILP (local_selection_time_lisp))
|
|
725 return;
|
428
|
726
|
442
|
727 local_selection_time = * (Time *) XOPAQUE_DATA (local_selection_time_lisp);
|
428
|
728
|
|
729 /* This SelectionClear is for a selection that we no longer own, so we can
|
|
730 disregard it. (That is, we have reasserted the selection since this
|
|
731 request was generated.)
|
|
732 */
|
|
733 if (changed_owner_time != CurrentTime &&
|
|
734 local_selection_time > changed_owner_time)
|
|
735 return;
|
442
|
736
|
428
|
737 handle_selection_clear (selection_symbol);
|
|
738 }
|
|
739
|
|
740
|
|
741 /* This stuff is so that INCR selections are reentrant (that is, so we can
|
|
742 be servicing multiple INCR selection requests simultaneously). I haven't
|
|
743 actually tested that yet.
|
|
744 */
|
|
745
|
|
746 static int prop_location_tick;
|
|
747
|
|
748 static struct prop_location {
|
|
749 int tick;
|
|
750 Display *display;
|
|
751 Window window;
|
|
752 Atom property;
|
|
753 int desired_state;
|
|
754 struct prop_location *next;
|
|
755 } *for_whom_the_bell_tolls;
|
|
756
|
|
757
|
|
758 static int
|
|
759 property_deleted_p (void *tick)
|
|
760 {
|
|
761 struct prop_location *rest = for_whom_the_bell_tolls;
|
|
762 while (rest)
|
|
763 if (rest->tick == (long) tick)
|
|
764 return 0;
|
|
765 else
|
|
766 rest = rest->next;
|
|
767 return 1;
|
|
768 }
|
|
769
|
|
770 static int
|
|
771 waiting_for_other_props_on_window (Display *display, Window window)
|
|
772 {
|
|
773 struct prop_location *rest = for_whom_the_bell_tolls;
|
|
774 while (rest)
|
|
775 if (rest->display == display && rest->window == window)
|
|
776 return 1;
|
|
777 else
|
|
778 rest = rest->next;
|
|
779 return 0;
|
|
780 }
|
|
781
|
|
782
|
|
783 static int
|
|
784 expect_property_change (Display *display, Window window,
|
|
785 Atom property, int state)
|
|
786 {
|
|
787 struct prop_location *pl = xnew (struct prop_location);
|
|
788 pl->tick = ++prop_location_tick;
|
|
789 pl->display = display;
|
|
790 pl->window = window;
|
|
791 pl->property = property;
|
|
792 pl->desired_state = state;
|
|
793 pl->next = for_whom_the_bell_tolls;
|
|
794 for_whom_the_bell_tolls = pl;
|
|
795 return pl->tick;
|
|
796 }
|
|
797
|
|
798 static void
|
|
799 unexpect_property_change (int tick)
|
|
800 {
|
|
801 struct prop_location *prev = 0, *rest = for_whom_the_bell_tolls;
|
|
802 while (rest)
|
|
803 {
|
|
804 if (rest->tick == tick)
|
|
805 {
|
|
806 if (prev)
|
|
807 prev->next = rest->next;
|
|
808 else
|
|
809 for_whom_the_bell_tolls = rest->next;
|
1726
|
810 xfree (rest, struct prop_location *);
|
428
|
811 return;
|
|
812 }
|
|
813 prev = rest;
|
|
814 rest = rest->next;
|
|
815 }
|
|
816 }
|
|
817
|
|
818 static void
|
|
819 wait_for_property_change (long tick)
|
|
820 {
|
|
821 /* This function can GC */
|
|
822 wait_delaying_user_input (property_deleted_p, (void *) tick);
|
|
823 }
|
|
824
|
|
825
|
|
826 /* Called from the event-loop in response to a PropertyNotify event.
|
|
827 */
|
|
828 void
|
|
829 x_handle_property_notify (XPropertyEvent *event)
|
|
830 {
|
|
831 struct prop_location *prev = 0, *rest = for_whom_the_bell_tolls;
|
|
832 while (rest)
|
|
833 {
|
|
834 if (rest->property == event->atom &&
|
|
835 rest->window == event->window &&
|
|
836 rest->display == event->display &&
|
|
837 rest->desired_state == event->state)
|
|
838 {
|
|
839 #if 0
|
|
840 stderr_out ("Saw expected prop-%s on %s\n",
|
793
|
841 (event->state == PropertyDelete ? "delete" : "change"),
|
|
842 XSTRING_DATA
|
|
843 (XSYMBOL (x_atom_to_symbol
|
|
844 (get_device_from_display (event->display),
|
1726
|
845 event->atom))->name));
|
428
|
846 #endif
|
|
847 if (prev)
|
|
848 prev->next = rest->next;
|
|
849 else
|
|
850 for_whom_the_bell_tolls = rest->next;
|
1726
|
851 xfree (rest, struct prop_location *);
|
428
|
852 return;
|
|
853 }
|
|
854 prev = rest;
|
|
855 rest = rest->next;
|
|
856 }
|
|
857 #if 0
|
|
858 stderr_out ("Saw UNexpected prop-%s on %s\n",
|
793
|
859 (event->state == PropertyDelete ? "delete" : "change"),
|
|
860 XSTRING_DATA (XSYMBOL (x_atom_to_symbol
|
|
861 (get_device_from_display (event->display),
|
|
862 event->atom))->name));
|
428
|
863 #endif
|
|
864 }
|
|
865
|
|
866
|
|
867
|
|
868 #if 0 /* #### MULTIPLE doesn't work yet */
|
|
869
|
|
870 static Lisp_Object
|
|
871 fetch_multiple_target (XSelectionRequestEvent *event)
|
|
872 {
|
|
873 /* This function can GC */
|
|
874 Display *display = event->display;
|
|
875 Window window = event->requestor;
|
|
876 Atom target = event->target;
|
|
877 Atom selection_atom = event->selection;
|
|
878 int result;
|
|
879
|
|
880 return
|
|
881 Fcons (QMULTIPLE,
|
|
882 x_get_window_property_as_lisp_data (display, window, target,
|
|
883 QMULTIPLE,
|
|
884 selection_atom));
|
|
885 }
|
|
886
|
|
887 static Lisp_Object
|
|
888 copy_multiple_data (Lisp_Object obj)
|
|
889 {
|
|
890 Lisp_Object vec;
|
665
|
891 Elemcount i;
|
|
892 Elemcount len;
|
428
|
893 if (CONSP (obj))
|
|
894 return Fcons (XCAR (obj), copy_multiple_data (XCDR (obj)));
|
|
895
|
|
896 CHECK_VECTOR (obj);
|
|
897 len = XVECTOR_LENGTH (obj);
|
|
898 vec = make_vector (len, Qnil);
|
|
899 for (i = 0; i < len; i++)
|
|
900 {
|
|
901 Lisp_Object vec2 = XVECTOR_DATA (obj) [i];
|
|
902 CHECK_VECTOR (vec2);
|
|
903 if (XVECTOR_LENGTH (vec2) != 2)
|
563
|
904 sferror ("vectors must be of length 2", vec2);
|
428
|
905 XVECTOR_DATA (vec) [i] = make_vector (2, Qnil);
|
|
906 XVECTOR_DATA (XVECTOR_DATA (vec) [i]) [0] = XVECTOR_DATA (vec2) [0];
|
|
907 XVECTOR_DATA (XVECTOR_DATA (vec) [i]) [1] = XVECTOR_DATA (vec2) [1];
|
|
908 }
|
|
909 return vec;
|
|
910 }
|
|
911
|
|
912 #endif /* 0 */
|
|
913
|
|
914
|
|
915 static Window reading_selection_reply;
|
|
916 static Atom reading_which_selection;
|
|
917 static int selection_reply_timed_out;
|
|
918
|
|
919 static int
|
2286
|
920 selection_reply_done (void *UNUSED (unused))
|
428
|
921 {
|
|
922 return !reading_selection_reply;
|
|
923 }
|
|
924
|
|
925 static Lisp_Object Qx_selection_reply_timeout_internal;
|
|
926
|
|
927 DEFUN ("x-selection-reply-timeout-internal", Fx_selection_reply_timeout_internal,
|
|
928 1, 1, 0, /*
|
|
929 */
|
2286
|
930 (UNUSED (arg)))
|
428
|
931 {
|
|
932 selection_reply_timed_out = 1;
|
|
933 reading_selection_reply = 0;
|
|
934 return Qnil;
|
|
935 }
|
|
936
|
|
937
|
|
938 /* Do protocol to read selection-data from the server.
|
|
939 Converts this to lisp data and returns it.
|
|
940 */
|
|
941 static Lisp_Object
|
|
942 x_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type)
|
|
943 {
|
|
944 /* This function can GC */
|
|
945 struct device *d = decode_x_device (Qnil);
|
|
946 Display *display = DEVICE_X_DISPLAY (d);
|
|
947 struct frame *sel_frame = selected_frame ();
|
|
948 Window requestor_window = XtWindow (FRAME_X_TEXT_WIDGET (sel_frame));
|
|
949 Time requestor_time = DEVICE_X_MOUSE_TIMESTAMP (d);
|
|
950 Atom target_property = DEVICE_XATOM_EMACS_TMP (d);
|
|
951 Atom selection_atom = symbol_to_x_atom (d, selection_symbol, 0);
|
|
952 int speccount;
|
|
953 Atom type_atom = symbol_to_x_atom (d, (CONSP (target_type) ?
|
|
954 XCAR (target_type) : target_type), 0);
|
|
955
|
|
956 XConvertSelection (display, selection_atom, type_atom, target_property,
|
|
957 requestor_window, requestor_time);
|
|
958
|
|
959 /* Block until the reply has been read. */
|
|
960 reading_selection_reply = requestor_window;
|
|
961 reading_which_selection = selection_atom;
|
|
962 selection_reply_timed_out = 0;
|
|
963
|
|
964 speccount = specpdl_depth ();
|
|
965
|
|
966 /* add a timeout handler */
|
|
967 if (x_selection_timeout > 0)
|
|
968 {
|
|
969 Lisp_Object id = Fadd_timeout (make_int (x_selection_timeout),
|
|
970 Qx_selection_reply_timeout_internal,
|
|
971 Qnil, Qnil);
|
|
972 record_unwind_protect (Fdisable_timeout, id);
|
|
973 }
|
|
974
|
|
975 /* This is ^Gable */
|
|
976 wait_delaying_user_input (selection_reply_done, 0);
|
|
977
|
|
978 if (selection_reply_timed_out)
|
563
|
979 signal_error (Qselection_conversion_error, "timed out waiting for reply from selection owner", Qunbound);
|
428
|
980
|
771
|
981 unbind_to (speccount);
|
428
|
982
|
|
983 /* otherwise, the selection is waiting for us on the requested property. */
|
442
|
984
|
|
985 return select_convert_in (selection_symbol,
|
|
986 target_type,
|
|
987 x_get_window_property_as_lisp_data(display,
|
|
988 requestor_window,
|
|
989 target_property,
|
|
990 target_type,
|
|
991 selection_atom));
|
428
|
992 }
|
|
993
|
|
994
|
|
995 static void
|
|
996 x_get_window_property (Display *display, Window window, Atom property,
|
2367
|
997 Rawbyte **data_ret, Bytecount *bytes_ret,
|
428
|
998 Atom *actual_type_ret, int *actual_format_ret,
|
|
999 unsigned long *actual_size_ret, int delete_p)
|
|
1000 {
|
665
|
1001 Bytecount total_size;
|
428
|
1002 unsigned long bytes_remaining;
|
665
|
1003 Bytecount offset = 0;
|
2367
|
1004 Rawbyte *tmp_data = 0;
|
428
|
1005 int result;
|
665
|
1006 Bytecount buffer_size = SELECTION_QUANTUM (display);
|
428
|
1007 if (buffer_size > MAX_SELECTION_QUANTUM) buffer_size = MAX_SELECTION_QUANTUM;
|
|
1008
|
|
1009 /* First probe the thing to find out how big it is. */
|
|
1010 result = XGetWindowProperty (display, window, property,
|
|
1011 0, 0, False, AnyPropertyType,
|
|
1012 actual_type_ret, actual_format_ret,
|
|
1013 actual_size_ret,
|
|
1014 &bytes_remaining, &tmp_data);
|
|
1015 if (result != Success)
|
|
1016 {
|
|
1017 *data_ret = 0;
|
|
1018 *bytes_ret = 0;
|
|
1019 return;
|
|
1020 }
|
|
1021 XFree ((char *) tmp_data);
|
|
1022
|
|
1023 if (*actual_type_ret == None || *actual_format_ret == 0)
|
|
1024 {
|
|
1025 if (delete_p) XDeleteProperty (display, window, property);
|
|
1026 *data_ret = 0;
|
|
1027 *bytes_ret = 0;
|
|
1028 return;
|
|
1029 }
|
|
1030
|
|
1031 total_size = bytes_remaining + 1;
|
2367
|
1032 *data_ret = xnew_rawbytes (total_size);
|
428
|
1033
|
|
1034 /* Now read, until we've gotten it all. */
|
|
1035 while (bytes_remaining)
|
|
1036 {
|
|
1037 #if 0
|
665
|
1038 Bytecount last = bytes_remaining;
|
428
|
1039 #endif
|
|
1040 result =
|
|
1041 XGetWindowProperty (display, window, property,
|
|
1042 offset/4, buffer_size/4,
|
|
1043 (delete_p ? True : False),
|
|
1044 AnyPropertyType,
|
|
1045 actual_type_ret, actual_format_ret,
|
|
1046 actual_size_ret, &bytes_remaining, &tmp_data);
|
|
1047 #if 0
|
|
1048 stderr_out ("<< read %d\n", last-bytes_remaining);
|
|
1049 #endif
|
|
1050 /* If this doesn't return Success at this point, it means that
|
|
1051 some clod deleted the selection while we were in the midst of
|
|
1052 reading it. Deal with that, I guess....
|
|
1053 */
|
|
1054 if (result != Success) break;
|
|
1055 *actual_size_ret *= *actual_format_ret / 8;
|
|
1056 memcpy ((*data_ret) + offset, tmp_data, *actual_size_ret);
|
|
1057 offset += *actual_size_ret;
|
|
1058 XFree ((char *) tmp_data);
|
|
1059 }
|
|
1060 *bytes_ret = offset;
|
|
1061 }
|
|
1062
|
|
1063
|
|
1064 static void
|
|
1065 receive_incremental_selection (Display *display, Window window, Atom property,
|
|
1066 /* this one is for error messages only */
|
2286
|
1067 Lisp_Object UNUSED (target_type),
|
665
|
1068 Bytecount min_size_bytes,
|
2367
|
1069 Rawbyte **data_ret,
|
665
|
1070 Bytecount *size_bytes_ret,
|
428
|
1071 Atom *type_ret, int *format_ret,
|
|
1072 unsigned long *size_ret)
|
|
1073 {
|
|
1074 /* This function can GC */
|
665
|
1075 Bytecount offset = 0;
|
428
|
1076 int prop_id;
|
|
1077 *size_bytes_ret = min_size_bytes;
|
2367
|
1078 *data_ret = xnew_rawbytes (*size_bytes_ret);
|
428
|
1079 #if 0
|
|
1080 stderr_out ("\nread INCR %d\n", min_size_bytes);
|
|
1081 #endif
|
|
1082 /* At this point, we have read an INCR property, and deleted it (which
|
|
1083 is how we ack its receipt: the sending window will be selecting
|
|
1084 PropertyNotify events on our window to notice this).
|
|
1085
|
|
1086 Now, we must loop, waiting for the sending window to put a value on
|
|
1087 that property, then reading the property, then deleting it to ack.
|
|
1088 We are done when the sender places a property of length 0.
|
|
1089 */
|
|
1090 prop_id = expect_property_change (display, window, property,
|
|
1091 PropertyNewValue);
|
|
1092 while (1)
|
|
1093 {
|
2367
|
1094 Rawbyte *tmp_data;
|
665
|
1095 Bytecount tmp_size_bytes;
|
428
|
1096 wait_for_property_change (prop_id);
|
|
1097 /* expect it again immediately, because x_get_window_property may
|
|
1098 .. no it won't, I don't get it.
|
|
1099 .. Ok, I get it now, the Xt code that implements INCR is broken.
|
|
1100 */
|
|
1101 prop_id = expect_property_change (display, window, property,
|
|
1102 PropertyNewValue);
|
|
1103 x_get_window_property (display, window, property,
|
|
1104 &tmp_data, &tmp_size_bytes,
|
|
1105 type_ret, format_ret, size_ret, 1);
|
|
1106
|
|
1107 if (tmp_size_bytes == 0) /* we're done */
|
|
1108 {
|
|
1109 #if 0
|
|
1110 stderr_out (" read INCR done\n");
|
|
1111 #endif
|
|
1112 unexpect_property_change (prop_id);
|
1726
|
1113 if (tmp_data)
|
2367
|
1114 xfree (tmp_data, Rawbyte *);
|
428
|
1115 break;
|
|
1116 }
|
|
1117 #if 0
|
|
1118 stderr_out (" read INCR %d\n", tmp_size_bytes);
|
|
1119 #endif
|
|
1120 if (*size_bytes_ret < offset + tmp_size_bytes)
|
|
1121 {
|
|
1122 #if 0
|
|
1123 stderr_out (" read INCR realloc %d -> %d\n",
|
|
1124 *size_bytes_ret, offset + tmp_size_bytes);
|
|
1125 #endif
|
|
1126 *size_bytes_ret = offset + tmp_size_bytes;
|
2367
|
1127 *data_ret = (Rawbyte *) xrealloc (*data_ret, *size_bytes_ret);
|
428
|
1128 }
|
|
1129 memcpy ((*data_ret) + offset, tmp_data, tmp_size_bytes);
|
|
1130 offset += tmp_size_bytes;
|
2367
|
1131 xfree (tmp_data, Rawbyte *);
|
428
|
1132 }
|
|
1133 }
|
|
1134
|
|
1135
|
|
1136 static Lisp_Object
|
|
1137 x_get_window_property_as_lisp_data (Display *display,
|
|
1138 Window window,
|
|
1139 Atom property,
|
|
1140 /* next two for error messages only */
|
|
1141 Lisp_Object target_type,
|
|
1142 Atom selection_atom)
|
|
1143 {
|
|
1144 /* This function can GC */
|
|
1145 Atom actual_type;
|
|
1146 int actual_format;
|
|
1147 unsigned long actual_size;
|
2367
|
1148 Rawbyte *data = NULL;
|
665
|
1149 Bytecount bytes = 0;
|
428
|
1150 Lisp_Object val;
|
|
1151 struct device *d = get_device_from_display (display);
|
|
1152
|
|
1153 x_get_window_property (display, window, property, &data, &bytes,
|
|
1154 &actual_type, &actual_format, &actual_size, 1);
|
|
1155 if (! data)
|
|
1156 {
|
|
1157 if (XGetSelectionOwner (display, selection_atom))
|
|
1158 /* there is a selection owner */
|
563
|
1159 signal_error (Qselection_conversion_error,
|
|
1160 "selection owner couldn't convert",
|
|
1161 Fcons (Qunbound,
|
|
1162 Fcons (x_atom_to_symbol (d, selection_atom),
|
|
1163 actual_type ?
|
|
1164 list2 (target_type,
|
|
1165 x_atom_to_symbol (d, actual_type)) :
|
|
1166 list1 (target_type))));
|
428
|
1167 else
|
563
|
1168 signal_error (Qselection_conversion_error,
|
|
1169 "no selection",
|
|
1170 x_atom_to_symbol (d, selection_atom));
|
428
|
1171 }
|
|
1172
|
|
1173 if (actual_type == DEVICE_XATOM_INCR (d))
|
|
1174 {
|
|
1175 /* Ok, that data wasn't *the* data, it was just the beginning. */
|
|
1176
|
665
|
1177 Bytecount min_size_bytes =
|
647
|
1178 /* careful here. */
|
665
|
1179 (Bytecount) (* ((unsigned int *) data));
|
2367
|
1180 xfree (data, Rawbyte *);
|
428
|
1181 receive_incremental_selection (display, window, property, target_type,
|
|
1182 min_size_bytes, &data, &bytes,
|
|
1183 &actual_type, &actual_format,
|
|
1184 &actual_size);
|
|
1185 }
|
|
1186
|
|
1187 /* It's been read. Now convert it to a lisp object in some semi-rational
|
|
1188 manner. */
|
|
1189 val = selection_data_to_lisp_data (d, data, bytes,
|
|
1190 actual_type, actual_format);
|
|
1191
|
2367
|
1192 xfree (data, Rawbyte *);
|
428
|
1193 return val;
|
|
1194 }
|
|
1195
|
|
1196
|
|
1197 /* Called from the event loop to handle SelectionNotify events.
|
|
1198 I don't think this needs to be reentrant.
|
|
1199 */
|
|
1200 void
|
|
1201 x_handle_selection_notify (XSelectionEvent *event)
|
|
1202 {
|
|
1203 if (! reading_selection_reply)
|
|
1204 message ("received an unexpected SelectionNotify event");
|
|
1205 else if (event->requestor != reading_selection_reply)
|
|
1206 message ("received a SelectionNotify event for the wrong window");
|
|
1207 else if (event->selection != reading_which_selection)
|
|
1208 message ("received the wrong selection type in SelectionNotify!");
|
|
1209 else
|
|
1210 reading_selection_reply = 0; /* we're done now. */
|
|
1211 }
|
|
1212
|
|
1213 static void
|
|
1214 x_disown_selection (Lisp_Object selection, Lisp_Object timeval)
|
|
1215 {
|
|
1216 struct device *d = decode_x_device (Qnil);
|
|
1217 Display *display = DEVICE_X_DISPLAY (d);
|
|
1218 Time timestamp;
|
|
1219 Atom selection_atom;
|
|
1220
|
|
1221 CHECK_SYMBOL (selection);
|
|
1222 if (NILP (timeval))
|
|
1223 timestamp = DEVICE_X_MOUSE_TIMESTAMP (d);
|
|
1224 else
|
|
1225 {
|
|
1226 /* #### This is bogus. See the comment above about problems
|
|
1227 on OSF/1 and DEC Alphas. Yet another reason why it sucks
|
|
1228 to have the implementation (i.e. cons of two 16-bit
|
|
1229 integers) exposed. */
|
|
1230 time_t the_time;
|
|
1231 lisp_to_time (timeval, &the_time);
|
|
1232 timestamp = (Time) the_time;
|
|
1233 }
|
|
1234
|
|
1235 selection_atom = symbol_to_x_atom (d, selection, 0);
|
|
1236
|
|
1237 XSetSelectionOwner (display, selection_atom, None, timestamp);
|
|
1238 }
|
|
1239
|
|
1240 static Lisp_Object
|
442
|
1241 x_selection_exists_p (Lisp_Object selection,
|
2286
|
1242 Lisp_Object UNUSED (selection_type))
|
428
|
1243 {
|
|
1244 struct device *d = decode_x_device (Qnil);
|
|
1245 Display *dpy = DEVICE_X_DISPLAY (d);
|
|
1246 return XGetSelectionOwner (dpy, symbol_to_x_atom (d, selection, 0)) != None ?
|
|
1247 Qt : Qnil;
|
|
1248 }
|
|
1249
|
|
1250
|
|
1251 #ifdef CUT_BUFFER_SUPPORT
|
|
1252
|
|
1253 static int cut_buffers_initialized; /* Whether we're sure they all exist */
|
|
1254
|
|
1255 /* Ensure that all 8 cut buffers exist. ICCCM says we gotta... */
|
|
1256 static void
|
|
1257 initialize_cut_buffers (Display *display, Window window)
|
|
1258 {
|
442
|
1259 static unsigned const char * const data = (unsigned const char *) "";
|
428
|
1260 #define FROB(atom) XChangeProperty (display, window, atom, XA_STRING, 8, \
|
|
1261 PropModeAppend, data, 0)
|
|
1262 FROB (XA_CUT_BUFFER0);
|
|
1263 FROB (XA_CUT_BUFFER1);
|
|
1264 FROB (XA_CUT_BUFFER2);
|
|
1265 FROB (XA_CUT_BUFFER3);
|
|
1266 FROB (XA_CUT_BUFFER4);
|
|
1267 FROB (XA_CUT_BUFFER5);
|
|
1268 FROB (XA_CUT_BUFFER6);
|
|
1269 FROB (XA_CUT_BUFFER7);
|
|
1270 #undef FROB
|
|
1271 cut_buffers_initialized = 1;
|
|
1272 }
|
|
1273
|
|
1274 #define CHECK_CUTBUFFER(symbol) do { \
|
|
1275 CHECK_SYMBOL (symbol); \
|
|
1276 if (! (EQ (symbol, QCUT_BUFFER0) || \
|
|
1277 EQ (symbol, QCUT_BUFFER1) || \
|
|
1278 EQ (symbol, QCUT_BUFFER2) || \
|
|
1279 EQ (symbol, QCUT_BUFFER3) || \
|
|
1280 EQ (symbol, QCUT_BUFFER4) || \
|
|
1281 EQ (symbol, QCUT_BUFFER5) || \
|
|
1282 EQ (symbol, QCUT_BUFFER6) || \
|
|
1283 EQ (symbol, QCUT_BUFFER7))) \
|
563
|
1284 invalid_constant ("Doesn't name a cutbuffer", symbol); \
|
428
|
1285 } while (0)
|
|
1286
|
|
1287 DEFUN ("x-get-cutbuffer-internal", Fx_get_cutbuffer_internal, 1, 1, 0, /*
|
|
1288 Return the value of the named CUTBUFFER (typically CUT_BUFFER0).
|
|
1289 */
|
|
1290 (cutbuffer))
|
|
1291 {
|
|
1292 struct device *d = decode_x_device (Qnil);
|
|
1293 Display *display = DEVICE_X_DISPLAY (d);
|
|
1294 Window window = RootWindow (display, 0); /* Cutbuffers are on frame 0 */
|
|
1295 Atom cut_buffer_atom;
|
2367
|
1296 Rawbyte *data;
|
665
|
1297 Bytecount bytes;
|
428
|
1298 Atom type;
|
|
1299 int format;
|
|
1300 unsigned long size;
|
|
1301 Lisp_Object ret;
|
|
1302
|
|
1303 CHECK_CUTBUFFER (cutbuffer);
|
|
1304 cut_buffer_atom = symbol_to_x_atom (d, cutbuffer, 0);
|
|
1305
|
|
1306 x_get_window_property (display, window, cut_buffer_atom, &data, &bytes,
|
|
1307 &type, &format, &size, 0);
|
|
1308 if (!data) return Qnil;
|
|
1309
|
|
1310 if (format != 8 || type != XA_STRING)
|
563
|
1311 invalid_state_2 ("Cut buffer doesn't contain 8-bit STRING data",
|
|
1312 x_atom_to_symbol (d, type),
|
|
1313 make_int (format));
|
428
|
1314
|
|
1315 /* We cheat - if the string contains an ESC character, that's
|
|
1316 technically not allowed in a STRING, so we assume it's
|
|
1317 COMPOUND_TEXT that we stored there ourselves earlier,
|
|
1318 in x-store-cutbuffer-internal */
|
|
1319 ret = (bytes ?
|
647
|
1320 make_ext_string ((Extbyte *) data, bytes,
|
428
|
1321 memchr (data, 0x1b, bytes) ?
|
440
|
1322 Qctext : Qbinary)
|
428
|
1323 : Qnil);
|
2367
|
1324 xfree (data, Rawbyte *);
|
428
|
1325 return ret;
|
|
1326 }
|
|
1327
|
|
1328
|
|
1329 DEFUN ("x-store-cutbuffer-internal", Fx_store_cutbuffer_internal, 2, 2, 0, /*
|
|
1330 Set the value of the named CUTBUFFER (typically CUT_BUFFER0) to STRING.
|
|
1331 */
|
|
1332 (cutbuffer, string))
|
|
1333 {
|
|
1334 struct device *d = decode_x_device (Qnil);
|
|
1335 Display *display = DEVICE_X_DISPLAY (d);
|
|
1336 Window window = RootWindow (display, 0); /* Cutbuffers are on frame 0 */
|
|
1337 Atom cut_buffer_atom;
|
867
|
1338 const Ibyte *data = XSTRING_DATA (string);
|
444
|
1339 Bytecount bytes = XSTRING_LENGTH (string);
|
|
1340 Bytecount bytes_remaining;
|
665
|
1341 Bytecount max_bytes = SELECTION_QUANTUM (display);
|
428
|
1342 #ifdef MULE
|
867
|
1343 const Ibyte *ptr, *end;
|
428
|
1344 enum { ASCII, LATIN_1, WORLD } chartypes = ASCII;
|
|
1345 #endif
|
|
1346
|
|
1347 if (max_bytes > MAX_SELECTION_QUANTUM)
|
|
1348 max_bytes = MAX_SELECTION_QUANTUM;
|
|
1349
|
|
1350 CHECK_CUTBUFFER (cutbuffer);
|
|
1351 CHECK_STRING (string);
|
|
1352 cut_buffer_atom = symbol_to_x_atom (d, cutbuffer, 0);
|
|
1353
|
|
1354 if (! cut_buffers_initialized)
|
|
1355 initialize_cut_buffers (display, window);
|
|
1356
|
|
1357 /* We use the STRING encoding (Latin-1 only) if we can, else COMPOUND_TEXT.
|
|
1358 We cheat and use type = `STRING' even when using COMPOUND_TEXT.
|
|
1359 The ICCCM requires that this be so, and other clients assume it,
|
|
1360 as we do ourselves in initialize_cut_buffers. */
|
|
1361
|
|
1362 #ifdef MULE
|
|
1363 /* Optimize for the common ASCII case */
|
|
1364 for (ptr = data, end = ptr + bytes; ptr <= end; )
|
|
1365 {
|
826
|
1366 if (byte_ascii_p (*ptr))
|
428
|
1367 {
|
|
1368 ptr++;
|
|
1369 continue;
|
|
1370 }
|
|
1371
|
|
1372 if ((*ptr) == LEADING_BYTE_LATIN_ISO8859_1 ||
|
|
1373 (*ptr) == LEADING_BYTE_CONTROL_1)
|
|
1374 {
|
|
1375 chartypes = LATIN_1;
|
|
1376 ptr += 2;
|
|
1377 continue;
|
|
1378 }
|
|
1379
|
|
1380 chartypes = WORLD;
|
|
1381 break;
|
|
1382 }
|
|
1383
|
|
1384 if (chartypes == LATIN_1)
|
440
|
1385 TO_EXTERNAL_FORMAT (LISP_STRING, string,
|
|
1386 ALLOCA, (data, bytes),
|
|
1387 Qbinary);
|
428
|
1388 else if (chartypes == WORLD)
|
440
|
1389 TO_EXTERNAL_FORMAT (LISP_STRING, string,
|
|
1390 ALLOCA, (data, bytes),
|
|
1391 Qctext);
|
428
|
1392 #endif /* MULE */
|
|
1393
|
|
1394 bytes_remaining = bytes;
|
|
1395
|
|
1396 while (bytes_remaining)
|
|
1397 {
|
665
|
1398 Bytecount chunk =
|
647
|
1399 bytes_remaining < max_bytes ? bytes_remaining : max_bytes;
|
428
|
1400 XChangeProperty (display, window, cut_buffer_atom, XA_STRING, 8,
|
|
1401 (bytes_remaining == bytes
|
|
1402 ? PropModeReplace : PropModeAppend),
|
|
1403 data, chunk);
|
|
1404 data += chunk;
|
|
1405 bytes_remaining -= chunk;
|
|
1406 }
|
|
1407 return string;
|
|
1408 }
|
|
1409
|
|
1410
|
|
1411 DEFUN ("x-rotate-cutbuffers-internal", Fx_rotate_cutbuffers_internal, 1, 1, 0, /*
|
|
1412 Rotate the values of the cutbuffers by the given number of steps;
|
|
1413 positive means move values forward, negative means backward.
|
|
1414 */
|
|
1415 (n))
|
|
1416 {
|
|
1417 struct device *d = decode_x_device (Qnil);
|
|
1418 Display *display = DEVICE_X_DISPLAY (d);
|
|
1419 Window window = RootWindow (display, 0); /* Cutbuffers are on frame 0 */
|
|
1420 Atom props [8];
|
|
1421
|
|
1422 CHECK_INT (n);
|
|
1423 if (XINT (n) == 0)
|
|
1424 return n;
|
|
1425 if (! cut_buffers_initialized)
|
|
1426 initialize_cut_buffers (display, window);
|
|
1427 props[0] = XA_CUT_BUFFER0;
|
|
1428 props[1] = XA_CUT_BUFFER1;
|
|
1429 props[2] = XA_CUT_BUFFER2;
|
|
1430 props[3] = XA_CUT_BUFFER3;
|
|
1431 props[4] = XA_CUT_BUFFER4;
|
|
1432 props[5] = XA_CUT_BUFFER5;
|
|
1433 props[6] = XA_CUT_BUFFER6;
|
|
1434 props[7] = XA_CUT_BUFFER7;
|
|
1435 XRotateWindowProperties (display, window, props, 8, XINT (n));
|
|
1436 return n;
|
|
1437 }
|
|
1438
|
|
1439 #endif /* CUT_BUFFER_SUPPORT */
|
|
1440
|
|
1441
|
|
1442
|
|
1443 /************************************************************************/
|
|
1444 /* initialization */
|
|
1445 /************************************************************************/
|
|
1446
|
|
1447 void
|
440
|
1448 syms_of_select_x (void)
|
428
|
1449 {
|
|
1450
|
|
1451 #ifdef CUT_BUFFER_SUPPORT
|
|
1452 DEFSUBR (Fx_get_cutbuffer_internal);
|
|
1453 DEFSUBR (Fx_store_cutbuffer_internal);
|
|
1454 DEFSUBR (Fx_rotate_cutbuffers_internal);
|
|
1455 #endif /* CUT_BUFFER_SUPPORT */
|
|
1456
|
|
1457 /* Unfortunately, timeout handlers must be lisp functions. */
|
563
|
1458 DEFSYMBOL (Qx_selection_reply_timeout_internal);
|
428
|
1459 DEFSUBR (Fx_selection_reply_timeout_internal);
|
|
1460
|
|
1461 #ifdef CUT_BUFFER_SUPPORT
|
|
1462 defsymbol (&QCUT_BUFFER0, "CUT_BUFFER0");
|
|
1463 defsymbol (&QCUT_BUFFER1, "CUT_BUFFER1");
|
|
1464 defsymbol (&QCUT_BUFFER2, "CUT_BUFFER2");
|
|
1465 defsymbol (&QCUT_BUFFER3, "CUT_BUFFER3");
|
|
1466 defsymbol (&QCUT_BUFFER4, "CUT_BUFFER4");
|
|
1467 defsymbol (&QCUT_BUFFER5, "CUT_BUFFER5");
|
|
1468 defsymbol (&QCUT_BUFFER6, "CUT_BUFFER6");
|
|
1469 defsymbol (&QCUT_BUFFER7, "CUT_BUFFER7");
|
|
1470 #endif /* CUT_BUFFER_SUPPORT */
|
|
1471 }
|
|
1472
|
|
1473 void
|
|
1474 console_type_create_select_x (void)
|
|
1475 {
|
|
1476 CONSOLE_HAS_METHOD (x, own_selection);
|
|
1477 CONSOLE_HAS_METHOD (x, disown_selection);
|
|
1478 CONSOLE_HAS_METHOD (x, get_foreign_selection);
|
|
1479 CONSOLE_HAS_METHOD (x, selection_exists_p);
|
|
1480 }
|
|
1481
|
|
1482 void
|
440
|
1483 reinit_vars_of_select_x (void)
|
428
|
1484 {
|
|
1485 reading_selection_reply = 0;
|
|
1486 reading_which_selection = 0;
|
|
1487 selection_reply_timed_out = 0;
|
|
1488 for_whom_the_bell_tolls = 0;
|
|
1489 prop_location_tick = 0;
|
|
1490 }
|
|
1491
|
|
1492 void
|
440
|
1493 vars_of_select_x (void)
|
428
|
1494 {
|
|
1495 #ifdef CUT_BUFFER_SUPPORT
|
|
1496 cut_buffers_initialized = 0;
|
|
1497 Fprovide (intern ("cut-buffer"));
|
|
1498 #endif
|
|
1499
|
|
1500 DEFVAR_LISP ("x-sent-selection-hooks", &Vx_sent_selection_hooks /*
|
|
1501 A function or functions to be called after we have responded to some
|
|
1502 other client's request for the value of a selection that we own. The
|
|
1503 function(s) will be called with four arguments:
|
|
1504 - the name of the selection (typically PRIMARY, SECONDARY, or CLIPBOARD);
|
|
1505 - the name of the selection-type which we were requested to convert the
|
|
1506 selection into before sending (for example, STRING or LENGTH);
|
|
1507 - and whether we successfully transmitted the selection.
|
|
1508 We might have failed (and declined the request) for any number of reasons,
|
|
1509 including being asked for a selection that we no longer own, or being asked
|
|
1510 to convert into a type that we don't know about or that is inappropriate.
|
|
1511 This hook doesn't let you change the behavior of emacs's selection replies,
|
|
1512 it merely informs you that they have happened.
|
|
1513 */ );
|
|
1514 Vx_sent_selection_hooks = Qunbound;
|
|
1515
|
|
1516 DEFVAR_INT ("x-selection-timeout", &x_selection_timeout /*
|
|
1517 If the selection owner doesn't reply in this many seconds, we give up.
|
|
1518 A value of 0 means wait as long as necessary. This is initialized from the
|
|
1519 \"*selectionTimeout\" resource (which is expressed in milliseconds).
|
|
1520 */ );
|
|
1521 x_selection_timeout = 0;
|
456
|
1522
|
|
1523 DEFVAR_BOOL ("x-selection-strict-motif-ownership", &x_selection_strict_motif_ownership /*
|
863
|
1524 *If nil and XEmacs already owns the clipboard, don't own it again in the
|
456
|
1525 Motif way. Owning the selection on the Motif way does a huge amount of
|
|
1526 X protocol, and it makes killing text incredibly slow when using an
|
|
1527 X terminal. However, when enabled Motif text fields don't bother to look up
|
|
1528 the new value, and you can't Copy from a buffer, Paste into a text
|
|
1529 field, then Copy something else from the buffer and paste it into the
|
|
1530 text field; it pastes the first thing again.
|
|
1531 */ );
|
|
1532 x_selection_strict_motif_ownership = 1;
|
428
|
1533 }
|
|
1534
|
|
1535 void
|
440
|
1536 Xatoms_of_select_x (struct device *d)
|
428
|
1537 {
|
|
1538 Display *D = DEVICE_X_DISPLAY (d);
|
|
1539
|
|
1540 /* Non-predefined atoms that we might end up using a lot */
|
|
1541 DEVICE_XATOM_CLIPBOARD (d) = XInternAtom (D, "CLIPBOARD", False);
|
|
1542 DEVICE_XATOM_TIMESTAMP (d) = XInternAtom (D, "TIMESTAMP", False);
|
|
1543 DEVICE_XATOM_TEXT (d) = XInternAtom (D, "TEXT", False);
|
|
1544 DEVICE_XATOM_DELETE (d) = XInternAtom (D, "DELETE", False);
|
|
1545 DEVICE_XATOM_MULTIPLE (d) = XInternAtom (D, "MULTIPLE", False);
|
|
1546 DEVICE_XATOM_INCR (d) = XInternAtom (D, "INCR", False);
|
|
1547 DEVICE_XATOM_TARGETS (d) = XInternAtom (D, "TARGETS", False);
|
|
1548 DEVICE_XATOM_NULL (d) = XInternAtom (D, "NULL", False);
|
|
1549 DEVICE_XATOM_ATOM_PAIR (d) = XInternAtom (D, "ATOM_PAIR", False);
|
|
1550 DEVICE_XATOM_COMPOUND_TEXT (d) = XInternAtom (D, "COMPOUND_TEXT", False);
|
442
|
1551
|
|
1552 /* #### I don't like the looks of this... what is it for? - ajh */
|
428
|
1553 DEVICE_XATOM_EMACS_TMP (d) = XInternAtom (D, "_EMACS_TMP_", False);
|
|
1554 }
|