annotate src/select-x.c @ 5624:c39052c921b5

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