annotate src/=xselect.c.old @ 1724:2dccfada2107

(visit-tags-table-buffer): When picking a table and using tags-table-list, skip over nonexistent files in the list.
author Roland McGrath <roland@gnu.org>
date Thu, 24 Dec 1992 22:42:05 +0000
parents f0c4c8771cd4
children 04fb1d3d6992
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 /* X Selection processing for emacs
648
70b112526394 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 641
diff changeset
2 Copyright (C) 1990, 1992 Free Software Foundation.
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4 This file is part of GNU Emacs.
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
648
70b112526394 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 641
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 any later version.
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 GNU General Public License for more details.
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 #include "config.h"
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 #include "lisp.h"
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 #include "xterm.h"
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
23 #include "buffer.h"
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
24 #include "frame.h"
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 #ifdef HAVE_X11
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 /* Macros for X Selections */
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
29 #define MAX_SELECTION(dpy) (((dpy)->max_request_size << 2) - 100)
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
30 #define SELECTION_LENGTH(len,format) ((len) * ((format) >> 2))
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
32 /* The timestamp of the last input event we received from the X server. */
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
33 unsigned long last_event_timestamp;
648
70b112526394 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 641
diff changeset
34
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 /* t if a mouse button is depressed. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 extern Lisp_Object Vmouse_grabbed;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 /* When emacs became the PRIMARY selection owner. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 Time x_begin_selection_own;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
41 /* When emacs became the SECONDARY selection owner. */
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
42 Time x_begin_secondary_selection_own;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
43
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 /* When emacs became the CLIPBOARD selection owner. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 Time x_begin_clipboard_own;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 /* The value of the current CLIPBOARD selection. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 Lisp_Object Vx_clipboard_value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 /* The value of the current PRIMARY selection. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 Lisp_Object Vx_selection_value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
53 /* The value of the current SECONDARY selection. */
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
54 Lisp_Object Vx_secondary_selection_value;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
55
1268
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
56 /* Types of selections we may make. */
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
57 Lisp_Object Qprimary, Qsecondary, Qclipboard;
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
58
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
59 /* Emacs' selection property identifiers. */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 Atom Xatom_emacs_selection;
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
61 Atom Xatom_emacs_secondary_selection;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 /* Clipboard selection atom. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 Atom Xatom_clipboard_selection;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 /* Clipboard atom. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 Atom Xatom_clipboard;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 /* Atom for indicating incremental selection transfer. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 Atom Xatom_incremental;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 /* Atom for indicating multiple selection request list */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 Atom Xatom_multiple;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 /* Atom for what targets emacs handles. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 Atom Xatom_targets;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 /* Atom for indicating timstamp selection request */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 Atom Xatom_timestamp;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 /* Atom requesting we delete our selection. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 Atom Xatom_delete;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 /* Selection magic. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 Atom Xatom_insert_selection;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 /* Type of property for INSERT_SELECTION. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 Atom Xatom_pair;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 /* More selection magic. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 Atom Xatom_insert_property;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 /* Atom for indicating property type TEXT */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 Atom Xatom_text;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
96 /* Kinds of protocol things we may receive. */
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
97 Atom Xatom_wm_take_focus;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
98 Atom Xatom_wm_save_yourself;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
99 Atom Xatom_wm_delete_window;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
100
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
101 /* Communication with window managers. */
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
102 Atom Xatom_wm_protocols;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
103
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 /* These are to handle incremental selection transfer. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 Window incr_requestor;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 Atom incr_property;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 int incr_nbytes;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 unsigned char *incr_value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 unsigned char *incr_ptr;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110
1268
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
111 /* Declarations for handling cut buffers.
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
112
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
113 Whenever we set a cut buffer or read a cut buffer's value, we cache
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
114 it in cut_buffer_value. We look for PropertyNotify events about
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
115 the CUT_BUFFER properties, and invalidate our cache accordingly.
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
116 We ignore PropertyNotify events that we suspect were caused by our
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
117 own changes to the cut buffers, so we can keep the cache valid
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
118 longer.
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
119
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
120 IS ALL THIS HAIR WORTH IT? Well, these functions get called every
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
121 time an element goes into or is retrieved from the kill ring, and
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
122 those ought to be quick. It's not fun in time or space to wait for
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
123 50k cut buffers to fly back and forth across the net. */
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
124
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
125 /* The number of CUT_BUFFER properties defined under X. */
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
126 #define NUM_CUT_BUFFERS (8)
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
127
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
128 /* cut_buffer_atom[n] is the atom naming the nth cut buffer. */
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
129 static Atom cut_buffer_atom[NUM_CUT_BUFFERS] = {
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
130 XA_CUT_BUFFER0, XA_CUT_BUFFER1, XA_CUT_BUFFER2, XA_CUT_BUFFER3,
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
131 XA_CUT_BUFFER4, XA_CUT_BUFFER5, XA_CUT_BUFFER6, XA_CUT_BUFFER7
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
132 };
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
133
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
134 /* cut_buffer_value is an eight-element vector;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
135 (aref cut_buffer_value n) is the cached value of cut buffer n, or
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
136 Qnil if cut buffer n is unset. */
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
137 static Lisp_Object cut_buffer_value;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
138
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
139 /* Bit N of cut_buffer_cached is true if (aref cut_buffer_value n) is
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
140 known to be valid. This is cleared by PropertyNotify events
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
141 handled by x_invalidate_cut_buffer_cache. It would be wonderful if
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
142 that routine could just set the appropriate element of
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
143 cut_buffer_value to some special value meaning "uncached", but that
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
144 would lose if a GC happened to be in progress.
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
145
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
146 Bit N of cut_buffer_just_set is true if cut buffer N has been set since
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
147 the last PropertyNotify event; since we get an event even when we set
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
148 the property ourselves, we should ignore one event after setting
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
149 a cut buffer, so we don't have to throw away our cache. */
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
150 #ifdef __STDC__
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
151 volatile
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
152 #endif
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
153 static cut_buffer_cached, cut_buffer_just_set;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
154
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
155
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
156 /* Acquiring ownership of a selection. */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
158
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
159 /* Request selection ownership if we do not already have it. */
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
160
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
161 static int
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
162 own_selection (selection_type, time)
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
163 Atom selection_type;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
164 Time time;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
165 {
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
166 Window owner_window, selecting_window;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
167
1529
d73ee126c15d * xselect.c (own_selection): selection_type is an X Atom value,
Jim Blandy <jimb@redhat.com>
parents: 1268
diff changeset
168 if ((selection_type == XA_PRIMARY
d73ee126c15d * xselect.c (own_selection): selection_type is an X Atom value,
Jim Blandy <jimb@redhat.com>
parents: 1268
diff changeset
169 && !NILP (Vx_selection_value))
d73ee126c15d * xselect.c (own_selection): selection_type is an X Atom value,
Jim Blandy <jimb@redhat.com>
parents: 1268
diff changeset
170 || (selection_type == XA_SECONDARY
d73ee126c15d * xselect.c (own_selection): selection_type is an X Atom value,
Jim Blandy <jimb@redhat.com>
parents: 1268
diff changeset
171 && !NILP (Vx_secondary_selection_value))
d73ee126c15d * xselect.c (own_selection): selection_type is an X Atom value,
Jim Blandy <jimb@redhat.com>
parents: 1268
diff changeset
172 || (selection_type == Xatom_clipboard
d73ee126c15d * xselect.c (own_selection): selection_type is an X Atom value,
Jim Blandy <jimb@redhat.com>
parents: 1268
diff changeset
173 && !NILP (Vx_clipboard_value)))
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
174 return 1;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
175
1053
a411429c4140 * xselect.c: Use the FRAME_X_WINDOW macro, for readability.
Jim Blandy <jimb@redhat.com>
parents: 847
diff changeset
176 selecting_window = FRAME_X_WINDOW (selected_frame);
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
177 XSetSelectionOwner (x_current_display, selection_type,
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
178 selecting_window, time);
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
179 owner_window = XGetSelectionOwner (x_current_display, selection_type);
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
180
648
70b112526394 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 641
diff changeset
181 if (owner_window != selecting_window)
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
182 return 0;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
183
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
184 return 1;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
185 }
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
186
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 /* Become the selection owner and make our data the selection value.
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 If we are already the owner, merely change data and timestamp values.
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 This avoids generating SelectionClear events for ourselves. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 DEFUN ("x-own-selection", Fx_own_selection, Sx_own_selection,
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
192 1, 2, "",
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
193 "Make STRING the selection value. Default is the primary selection,\n\
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
194 but optional second argument TYPE may specify secondary or clipboard.\n\
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
195 \n\
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
196 TYPE may also be cut-buffer0, indicating that Emacs should set the X\n\
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
197 cut buffer 0 to STRING. This is for compatibility with older X\n\
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
198 applications which still use the cut buffers; new applications should\n\
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
199 use X selections.")
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
200 (string, type)
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
201 register Lisp_Object string, type;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 {
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
203 Atom selection_type;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
204 Lisp_Object val;
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
205 Time event_time = last_event_timestamp;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 CHECK_STRING (string, 0);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207
839
c32d6beb8aec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 771
diff changeset
208 val = Qnil;
c32d6beb8aec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 771
diff changeset
209
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
210 if (NILP (type) || EQ (type, Qprimary))
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 {
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
212 BLOCK_INPUT;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
213 if (own_selection (XA_PRIMARY, event_time))
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
214 {
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
215 x_begin_selection_own = event_time;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
216 val = Vx_selection_value = string;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
217 }
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
218 UNBLOCK_INPUT;
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
219 }
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
220 else if (EQ (type, Qsecondary))
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
221 {
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
222 BLOCK_INPUT;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
223 if (own_selection (XA_SECONDARY, event_time))
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 {
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
225 x_begin_secondary_selection_own = event_time;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
226 val = Vx_secondary_selection_value = string;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 }
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
228 UNBLOCK_INPUT;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 }
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
230 else if (EQ (type, Qclipboard))
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
231 {
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
232 BLOCK_INPUT;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
233 if (own_selection (Xatom_clipboard, event_time))
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
234 {
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
235 x_begin_clipboard_own = event_time;
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
236 val = Vx_clipboard_value = string;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
237 }
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
238 UNBLOCK_INPUT;
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
239 }
1268
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
240 #if 0
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
241 else if (EQ (type, Qcut_buffer0))
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
242 {
847
8d43bfe19803 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 839
diff changeset
243 /* DECwindows and some other servers don't seem to like setting
8d43bfe19803 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 839
diff changeset
244 properties to values larger than about 20k. For very large
8d43bfe19803 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 839
diff changeset
245 values, they signal an error, but for intermediate values
8d43bfe19803 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 839
diff changeset
246 they just seem to hang.
8d43bfe19803 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 839
diff changeset
247
8d43bfe19803 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 839
diff changeset
248 We could just truncate the request, but it's better to let
8d43bfe19803 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 839
diff changeset
249 the user know that the strategy he/she's using isn't going to
8d43bfe19803 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 839
diff changeset
250 work than to have it work partially, but incorrectly. */
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
251 BLOCK_INPUT;
847
8d43bfe19803 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 839
diff changeset
252 if (XSTRING (string)->size > MAX_SELECTION (x_current_display))
8d43bfe19803 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 839
diff changeset
253 {
8d43bfe19803 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 839
diff changeset
254 XStoreBytes (x_current_display, (char *) 0, 0);
8d43bfe19803 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 839
diff changeset
255 val = Qnil;
8d43bfe19803 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 839
diff changeset
256 }
8d43bfe19803 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 839
diff changeset
257 else
8d43bfe19803 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 839
diff changeset
258 {
8d43bfe19803 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 839
diff changeset
259 XStoreBytes (x_current_display,
8d43bfe19803 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 839
diff changeset
260 (char *) XSTRING (string)->data,
8d43bfe19803 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 839
diff changeset
261 XSTRING (string)->size);
8d43bfe19803 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 839
diff changeset
262 val = string;
8d43bfe19803 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 839
diff changeset
263 }
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
264 UNBLOCK_INPUT;
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
265 }
1268
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
266 #endif
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
267 else
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
268 error ("Invalid X selection type");
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
270 return val;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 /* Clear our selection ownership data, as some other client has
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 become the owner. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 void
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 x_disown_selection (old_owner, selection, changed_owner_time)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 Window *old_owner;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 Atom selection;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280 Time changed_owner_time;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 {
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
282 struct frame *s = x_window_to_frame (old_owner);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 if (s) /* We are the owner */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 if (selection == XA_PRIMARY)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 x_begin_selection_own = 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 Vx_selection_value = Qnil;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 }
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
291 else if (selection == XA_SECONDARY)
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
292 {
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
293 x_begin_secondary_selection_own = 0;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
294 Vx_secondary_selection_value = Qnil;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
295 }
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 else if (selection == Xatom_clipboard)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298 x_begin_clipboard_own = 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299 Vx_clipboard_value = Qnil;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
301 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302 abort ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305 abort (); /* Inconsistent state. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307
1268
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
308
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
309 /* Answering selection requests. */
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
310
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 int x_selection_alloc_error;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 int x_converting_selection;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313
1268
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
314 /* Reply to some client's request for our selection data.
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
315 Data is placed in a property supplied by the requesting window.
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317 If the data exceeds the maximum amount the server can send,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318 then prepare to send it incrementally, and reply to the client with
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319 the total size of the data.
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321 But first, check for all the other crufty stuff we could get. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 void
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324 x_answer_selection_request (event)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 XSelectionRequestEvent event;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 Time emacs_own_time;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 Lisp_Object selection_value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 XSelectionEvent evt;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 int format = 8; /* We have only byte sized (text) data. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 evt.type = SelectionNotify; /* Construct reply event */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333 evt.display = event.display;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 evt.requestor = event.requestor;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 evt.selection = event.selection;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 evt.time = event.time;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337 evt.target = event.target;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 if (event.selection == XA_PRIMARY)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 emacs_own_time = x_begin_selection_own;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 selection_value = Vx_selection_value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343 }
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
344 else if (event.selection == XA_SECONDARY)
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
345 {
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
346 emacs_own_time = x_begin_secondary_selection_own;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
347 selection_value = Vx_secondary_selection_value;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
348 }
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 else if (event.selection == Xatom_clipboard)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 emacs_own_time = x_begin_clipboard_own;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352 selection_value = Vx_clipboard_value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355 abort ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 if (event.time != CurrentTime
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 && event.time < emacs_own_time)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359 evt.property = None;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362 if (event.property == None) /* obsolete client */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 evt.property = event.target;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
364 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365 evt.property = event.property;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368 if (event.target == Xatom_targets) /* Send List of target atoms */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
370 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 else if (event.target == Xatom_multiple) /* Recvd list: <target, prop> */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 Atom type;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 int return_format;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 unsigned long items, bytes_left;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376 unsigned char *data;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
377 int result, i;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
379 if (event.property == 0 /* 0 == NILP */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
380 || event.property == None)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381 return;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
382
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
383 result = XGetWindowProperty (event.display, event.requestor,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
384 event.property, 0L, 10000000L,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
385 True, Xatom_pair, &type, &return_format,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
386 &items, &bytes_left, &data);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
387
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388 if (result == Success && type == Xatom_pair)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
389 for (i = items; i > 0; i--)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
390 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
391 /* Convert each element of the list. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
392 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
393
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
394 (void) XSendEvent (x_current_display, evt.requestor, False,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
395 0L, (XEvent *) &evt);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396 return;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
397 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
398 else if (event.target == Xatom_timestamp) /* Send ownership timestamp */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
399 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400 if (! emacs_own_time)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401 abort ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
403 format = 32;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
404 XChangeProperty (evt.display, evt.requestor, evt.property,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
405 evt.target, format, PropModeReplace,
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
406 (unsigned char *) &emacs_own_time, 1);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
407 return;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
408 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
409 else if (event.target == Xatom_delete) /* Delete our selection. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
410 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
411 if (EQ (Qnil, selection_value))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
412 abort ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
413
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
414 x_disown_selection (event.owner, event.selection, event.time);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
416 /* Now return property of type NILP, length 0. */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 XChangeProperty (event.display, event.requestor, event.property,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418 0, format, PropModeReplace, (unsigned char *) 0, 0);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419 return;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
421 else if (event.target == Xatom_insert_selection)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
422 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423 Atom type;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424 int return_format;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 unsigned long items, bytes_left;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
426 unsigned char *data;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
427 int result = XGetWindowProperty (event.display, event.requestor,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428 event.property, 0L, 10000000L,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
429 True, Xatom_pair, &type, &return_format,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 &items, &bytes_left, &data);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
431 if (result == Success && type == Xatom_pair)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
433 /* Convert the first atom to (a selection) to the target
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
434 indicated by the second atom. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
436 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437 else if (event.target == Xatom_insert_property)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
438 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439 Atom type;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440 int return_format;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441 unsigned long items, bytes_left;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442 unsigned char *data;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 int result = XGetWindowProperty (event.display, event.requestor,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444 event.property, 0L, 10000000L,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 True, XA_STRING, &type, &return_format,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446 &items, &bytes_left, &data);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
448 if (result == Success && type == XA_STRING && return_format == 8)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
449 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
450 if (event.selection == Xatom_emacs_selection)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451 Vx_selection_value = make_string (data);
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
452 else if (event.selection == Xatom_emacs_secondary_selection)
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
453 Vx_secondary_selection_value = make_string (data);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
454 else if (event.selection == Xatom_clipboard_selection)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455 Vx_clipboard_value = make_string (data);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
456 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
457 abort ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
460 return;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
462 else if ((event.target == Xatom_text
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
463 || event.target == XA_STRING))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
464 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
465 int size = XSTRING (selection_value)->size;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
466 unsigned char *data = XSTRING (selection_value)->data;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468 if (EQ (Qnil, selection_value))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
469 abort ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
470
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
471 /* Place data on requestor window's property. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472 if (SELECTION_LENGTH (size, format)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
473 <= MAX_SELECTION (x_current_display))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
475 x_converting_selection = 1;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
476 XChangeProperty (evt.display, evt.requestor, evt.property,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
477 evt.target, format, PropModeReplace,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
478 data, size);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
479 if (x_selection_alloc_error)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
480 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
481 x_selection_alloc_error = 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
482 abort ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
483 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
484 x_converting_selection = 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
485 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
486 else /* Send incrementally */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
487 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
488 evt.target = Xatom_incremental;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
489 incr_requestor = evt.requestor;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
490 incr_property = evt.property;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
491 x_converting_selection = 1;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
492
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
493 /* Need to handle Alloc errors on these requests. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
494 XChangeProperty (evt.display, incr_requestor, incr_property,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
495 Xatom_incremental, 32,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
496 PropModeReplace,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
497 (unsigned char *) &size, 1);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
498 if (x_selection_alloc_error)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
499 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
500 x_selection_alloc_error = 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
501 x_converting_selection = 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
502 abort ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
503 /* Now abort the send. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
504 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
505
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
506 incr_nbytes = size;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
507 incr_value = data;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
508 incr_ptr = data;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
509
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
510 /* Ask for notification when requestor deletes property. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
511 XSelectInput (x_current_display, incr_requestor, PropertyChangeMask);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
512
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
513 /* If we're sending incrementally, perhaps block here
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
514 until all sent? */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
515 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
516 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
517 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
518 evt.property = None;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
519
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
520 /* Don't do this if there was an Alloc error: abort the transfer
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
521 by sending None. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
522 (void) XSendEvent (x_current_display, evt.requestor, False,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
523 0L, (XEvent *) &evt);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
524 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
525
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
526 /* Send an increment of selection data in response to a PropertyNotify event.
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
527 The increment is placed in a property on the requestor's window.
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
528 When the requestor has processed the increment, it deletes the property,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
529 which sends us another PropertyNotify event.
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
530
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
531 When there is no more data to send, we send a zero-length increment. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
532
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
533 void
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
534 x_send_incremental (event)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
535 XPropertyEvent event;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
536 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
537 if (incr_requestor
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
538 && incr_requestor == event.window
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
539 && incr_property == event.atom
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
540 && event.state == PropertyDelete)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
541 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
542 int format = 8;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
543 int length = MAX_SELECTION (x_current_display);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
544 int bytes_left = (incr_nbytes - (incr_ptr - incr_value));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
545
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
546 if (length > bytes_left) /* Also sends 0 len when finished. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
547 length = bytes_left;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
548 XChangeProperty (x_current_display, incr_requestor,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
549 incr_property, XA_STRING, format,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
550 PropModeAppend, incr_ptr, length);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
551 if (x_selection_alloc_error)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
552 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
553 x_selection_alloc_error = 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
554 x_converting_selection = 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
555 /* Abandon the transmission. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
556 abort ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
557 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
558 if (length > 0)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
559 incr_ptr += length;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
560 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
561 { /* Everything's sent */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
562 XSelectInput (x_current_display, incr_requestor, 0L);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
563 incr_requestor = (Window) 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
564 incr_property = (Atom) 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
565 incr_nbytes = 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
566 incr_value = (unsigned char *) 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
567 incr_ptr = (unsigned char *) 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
568 x_converting_selection = 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
569 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
570 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
571 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
572
1268
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
573
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
574 /* Requesting the value of a selection. */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
575
1529
d73ee126c15d * xselect.c (own_selection): selection_type is an X Atom value,
Jim Blandy <jimb@redhat.com>
parents: 1268
diff changeset
576 static Lisp_Object x_selection_arrival ();
d73ee126c15d * xselect.c (own_selection): selection_type is an X Atom value,
Jim Blandy <jimb@redhat.com>
parents: 1268
diff changeset
577
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
578 /* Predicate function used to match a requested event. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
579
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
580 Bool
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
581 XCheckSelectionEvent (dpy, event, window)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
582 Display *dpy;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
583 XEvent *event;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
584 char *window;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
585 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
586 if (event->type == SelectionNotify)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
587 if (event->xselection.requestor == (Window) window)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
588 return True;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
589
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
590 return False;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
591 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
592
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
593 /* Request a selection value from its owner. This will block until
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
594 all the data is arrived. */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
595
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
596 static Lisp_Object
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
597 get_selection_value (type)
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
598 Atom type;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
599 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
600 XEvent event;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
601 Lisp_Object val;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
602 Time requestor_time; /* Timestamp of selection request. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
603 Window requestor_window;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
604
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
605 BLOCK_INPUT;
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
606 requestor_time = last_event_timestamp;
1053
a411429c4140 * xselect.c: Use the FRAME_X_WINDOW macro, for readability.
Jim Blandy <jimb@redhat.com>
parents: 847
diff changeset
607 requestor_window = FRAME_X_WINDOW (selected_frame);
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
608 XConvertSelection (x_current_display, type, XA_STRING,
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
609 Xatom_emacs_selection, requestor_window, requestor_time);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
610 XIfEvent (x_current_display,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
611 &event,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
612 XCheckSelectionEvent,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
613 (char *) requestor_window);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
614 val = x_selection_arrival (&event, requestor_window, requestor_time);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
615 UNBLOCK_INPUT;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
616
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
617 return val;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
618 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
619
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
620 /* Request a selection value from the owner. If we are the owner,
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
621 simply return our selection value. If we are not the owner, this
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
622 will block until all of the data has arrived. */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
623
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
624 DEFUN ("x-selection-value", Fx_selection_value, Sx_selection_value,
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
625 0, 1, "",
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
626 "Return the value of one of the selections. Default is the primary\n\
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
627 selection, but optional argument TYPE may specify secondary or clipboard.")
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
628 (type)
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
629 register Lisp_Object type;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
630 {
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
631 Atom selection_type;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
632
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
633 if (NILP (type) || EQ (type, Qprimary))
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
634 {
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
635 if (!NILP (Vx_selection_value))
1268
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
636 return Vx_selection_value;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
637
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
638 return get_selection_value (XA_PRIMARY);
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
639 }
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
640 else if (EQ (type, Qsecondary))
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
641 {
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
642 if (!NILP (Vx_secondary_selection_value))
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
643 return Vx_secondary_selection_value;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
644
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
645 return get_selection_value (XA_SECONDARY);
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
646 }
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
647 else if (EQ (type, Qclipboard))
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
648 {
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
649 if (!NILP (Vx_clipboard_value))
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
650 return Vx_clipboard_value;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
651
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
652 return get_selection_value (Xatom_clipboard);
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
653 }
1268
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
654 #if 0
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
655 else if (EQ (type, Qcut_buffer0))
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
656 {
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
657 char *data;
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
658 int size;
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
659 Lisp_Object string;
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
660
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
661 BLOCK_INPUT;
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
662 data = XFetchBytes (x_current_display, &size);
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
663 if (data == 0)
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
664 string = Qnil;
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
665 else
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
666 string = make_string (data, size);
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
667 UNBLOCK_INPUT;
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
668
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
669 return string;
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
670 }
1268
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
671 #endif
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
672 else
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
673 error ("Invalid X selection type");
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
674 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
675
1529
d73ee126c15d * xselect.c (own_selection): selection_type is an X Atom value,
Jim Blandy <jimb@redhat.com>
parents: 1268
diff changeset
676 static Lisp_Object
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
677 x_selection_arrival (event, requestor_window, requestor_time)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
678 register XSelectionEvent *event;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
679 Window requestor_window;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
680 Time requestor_time;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
681 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
682 int result;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
683 Atom type, selection;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
684 int format;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
685 unsigned long items;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
686 unsigned long bytes_left;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
687 unsigned char *data = 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
688 int offset = 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
689
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
690 if (event->selection == XA_PRIMARY)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
691 selection = Xatom_emacs_selection;
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
692 else if (event->selection == XA_SECONDARY)
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
693 selection = Xatom_emacs_secondary_selection;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
694 else if (event->selection == Xatom_clipboard)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
695 selection = Xatom_clipboard_selection;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
696 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
697 abort ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
698
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
699 if (event->requestor == requestor_window
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
700 && event->time == requestor_time
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
701 && event->property != None)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
702 if (event->target != Xatom_incremental)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
703 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
704 unsigned char *return_string =
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
705 (unsigned char *) alloca (MAX_SELECTION (x_current_display));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
706
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
707 do
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
708 {
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
709 result = XGetWindowProperty (x_current_display, requestor_window,
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
710 event->property, 0L,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
711 10000000L, True, XA_STRING,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
712 &type, &format, &items,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
713 &bytes_left, &data);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
714 if (result == Success && type == XA_STRING && format == 8
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
715 && offset < MAX_SELECTION (x_current_display))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
716 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
717 bcopy (data, return_string + offset, items);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
718 offset += items;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
719 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
720 XFree ((char *) data);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
721 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
722 while (bytes_left);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
723
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
724 return make_string (return_string, offset);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
725 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
726 else /* Prepare incremental transfer. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
727 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
728 unsigned char *increment_value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
729 unsigned char *increment_ptr;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
730 int total_size;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
731 int *increment_nbytes = 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
732
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
733 result = XGetWindowProperty (x_current_display, requestor_window,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
734 selection, 0L, 10000000L, False,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
735 event->property, &type, &format,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
736 &items, &bytes_left,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
737 (unsigned char **) &increment_nbytes);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
738 if (result == Success)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
739 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
740 XPropertyEvent property_event;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
741
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
742 total_size = *increment_nbytes;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
743 increment_value = (unsigned char *) alloca (total_size);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
744 increment_ptr = increment_value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
745
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
746 XDeleteProperty (x_current_display, event->requestor,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
747 event->property);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
748 XFlush (x_current_display);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
749 XFree ((char *) increment_nbytes);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
750
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
751 do
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
752 { /* NOTE: this blocks. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
753 XWindowEvent (x_current_display, requestor_window,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
754 PropertyChangeMask,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
755 (XEvent *) &property_event);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
756
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
757 if (property_event.atom == selection
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
758 && property_event.state == PropertyNewValue)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
759 do
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
760 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
761 result = XGetWindowProperty (x_current_display,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
762 requestor_window,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
763 selection, 0L,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
764 10000000L, True,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
765 AnyPropertyType,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
766 &type, &format,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
767 &items, &bytes_left,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
768 &data);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
769 if (result == Success && type == XA_STRING
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
770 && format == 8)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
771 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
772 bcopy (data, increment_ptr, items);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
773 increment_ptr += items;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
774 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
775 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
776 while (bytes_left);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
777
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
778 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
779 while (increment_ptr < (increment_value + total_size));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
780
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
781 return make_string (increment_value,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
782 (increment_ptr - increment_value));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
783 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
784 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
785
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
786 return Qnil;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
787 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
788
1268
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
789
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
790 /* Cut buffer management. */
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
791
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
792 DEFUN ("x-get-cut-buffer", Fx_get_cut_buffer, Sx_get_cut_buffer, 0, 1, "",
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
793 "Return the value of cut buffer N, or nil if it is unset.\n\
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
794 If N is omitted, it defaults to zero.\n\
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
795 Note that cut buffers have some problems that selections don't; try to\n\
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
796 write your code to use cut buffers only for backward compatibility,\n\
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
797 and use selections for the serious work.")
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
798 (n)
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
799 Lisp_Object n;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
800 {
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
801 int buf_num;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
802
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
803 if (NILP (n))
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
804 buf_num = 0;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
805 else
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
806 {
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
807 CHECK_NUMBER (n, 0);
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
808 buf_num = XINT (n);
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
809 }
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
810
1602
f0c4c8771cd4 * xselect.c (Fx_get_cut_buffer): Correct check for buf_num in
Jim Blandy <jimb@redhat.com>
parents: 1529
diff changeset
811 if (buf_num < 0 || buf_num >= NUM_CUT_BUFFERS)
f0c4c8771cd4 * xselect.c (Fx_get_cut_buffer): Correct check for buf_num in
Jim Blandy <jimb@redhat.com>
parents: 1529
diff changeset
812 error ("cut buffer numbers must be from zero to seven");
1268
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
813
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
814 {
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
815 Lisp_Object value;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
816
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
817 /* Note that no PropertyNotify events will be processed while
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
818 input is blocked. */
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
819 BLOCK_INPUT;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
820
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
821 if (cut_buffer_cached & (1 << buf_num))
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
822 value = XVECTOR (cut_buffer_value)->contents[buf_num];
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
823 else
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
824 {
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
825 /* Our cache is invalid; retrieve the property's value from
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
826 the server. */
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
827 int buf_len;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
828 char *buf = XFetchBuffer (x_current_display, &buf_len, buf_num);
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
829
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
830 if (buf_len == 0)
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
831 value = Qnil;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
832 else
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
833 value = make_string (buf, buf_len);
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
834
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
835 XVECTOR (cut_buffer_value)->contents[buf_num] = value;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
836 cut_buffer_cached |= (1 << buf_num);
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
837
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
838 XFree (buf);
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
839 }
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
840
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
841 UNBLOCK_INPUT;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
842
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
843 return value;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
844 }
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
845 }
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
846
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
847 DEFUN ("x-set-cut-buffer", Fx_set_cut_buffer, Sx_set_cut_buffer, 2, 2, "",
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
848 "Set the value of cut buffer N to STRING.\n\
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
849 Note that cut buffers have some problems that selections don't; try to\n\
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
850 write your code to use cut buffers only for backward compatibility,\n\
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
851 and use selections for the serious work.")
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
852 (n, string)
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
853 Lisp_Object n, string;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
854 {
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
855 int buf_num;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
856
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
857 CHECK_NUMBER (n, 0);
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
858 CHECK_STRING (string, 1);
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
859
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
860 buf_num = XINT (n);
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
861
1602
f0c4c8771cd4 * xselect.c (Fx_get_cut_buffer): Correct check for buf_num in
Jim Blandy <jimb@redhat.com>
parents: 1529
diff changeset
862 if (buf_num < 0 || buf_num >= NUM_CUT_BUFFERS)
f0c4c8771cd4 * xselect.c (Fx_get_cut_buffer): Correct check for buf_num in
Jim Blandy <jimb@redhat.com>
parents: 1529
diff changeset
863 error ("cut buffer numbers must be from zero to seven");
1268
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
864
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
865 BLOCK_INPUT;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
866
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
867 /* DECwindows and some other servers don't seem to like setting
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
868 properties to values larger than about 20k. For very large
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
869 values, they signal an error, but for intermediate values they
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
870 just seem to hang.
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
871
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
872 We could just truncate the request, but it's better to let the
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
873 user know that the strategy he/she's using isn't going to work
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
874 than to have it work partially, but incorrectly. */
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
875
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
876 if (XSTRING (string)->size == 0
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
877 || XSTRING (string)->size > MAX_SELECTION (x_current_display))
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
878 {
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
879 XStoreBuffer (x_current_display, (char *) 0, 0, buf_num);
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
880 string = Qnil;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
881 }
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
882 else
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
883 {
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
884 XStoreBuffer (x_current_display,
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
885 (char *) XSTRING (string)->data, XSTRING (string)->size,
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
886 buf_num);
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
887 }
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
888
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
889 XVECTOR (cut_buffer_value)->contents[buf_num] = string;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
890 cut_buffer_cached |= (1 << buf_num);
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
891 cut_buffer_just_set |= (1 << buf_num);
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
892
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
893 UNBLOCK_INPUT;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
894
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
895 return string;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
896 }
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
897
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
898 /* Ask the server to send us an event if any cut buffer is modified. */
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
899
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
900 void
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
901 x_watch_cut_buffer_cache ()
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
902 {
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
903 XSelectInput (x_current_display, ROOT_WINDOW, PropertyChangeMask);
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
904 }
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
905
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
906 /* The server has told us that a cut buffer has been modified; deal with that.
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
907 Note that this function is called at interrupt level. */
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
908 void
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
909 x_invalidate_cut_buffer_cache (XPropertyEvent *event)
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
910 {
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
911 int i;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
912
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
913 /* See which cut buffer this is about, if any. */
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
914 for (i = 0; i < NUM_CUT_BUFFERS; i++)
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
915 if (event->atom == cut_buffer_atom[i])
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
916 {
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
917 int mask = (1 << i);
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
918
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
919 if (cut_buffer_just_set & mask)
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
920 cut_buffer_just_set &= ~mask;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
921 else
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
922 cut_buffer_cached &= ~mask;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
923
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
924 break;
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
925 }
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
926 }
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
927
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
928
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
929 /* Bureaucracy. */
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
930
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
931 void
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
932 syms_of_xselect ()
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
933 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
934 DEFVAR_LISP ("x-selection-value", &Vx_selection_value,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
935 "The value of emacs' last cut-string.");
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
936 Vx_selection_value = Qnil;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
937
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
938 DEFVAR_LISP ("x-secondary-selection-value", &Vx_secondary_selection_value,
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
939 "The value of emacs' last secondary cut-string.");
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
940 Vx_secondary_selection_value = Qnil;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
941
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
942 DEFVAR_LISP ("x-clipboard-value", &Vx_clipboard_value,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
943 "The string emacs last sent to the clipboard.");
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
944 Vx_clipboard_value = Qnil;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
945
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
946 Qprimary = intern ("primary");
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
947 staticpro (&Qprimary);
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
948 Qsecondary = intern ("secondary");
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
949 staticpro (&Qsecondary);
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
950 Qclipboard = intern ("clipboard");
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
951 staticpro (&Qclipboard);
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
952
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
953 defsubr (&Sx_own_selection);
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
954 defsubr (&Sx_selection_value);
1268
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
955
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
956 cut_buffer_value = Fmake_vector (make_number (NUM_CUT_BUFFERS), Qnil);
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
957 staticpro (&cut_buffer_value);
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
958
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
959 defsubr (&Sx_get_cut_buffer);
39c6e9d28de2 * xselect.c (Qcut_buffer0): Symbol removed; we're using a new
Jim Blandy <jimb@redhat.com>
parents: 1053
diff changeset
960 defsubr (&Sx_set_cut_buffer);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
961 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
962 #endif /* X11 */