annotate src/=xselect.c.old @ 736:18b892513cb7

*** empty log message ***
author Richard M. Stallman <rms@gnu.org>
date Thu, 02 Jul 1992 22:11:40 +0000
parents a8d94735277e
children 538c0bcb418e
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"
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 #include "screen.h"
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
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
56 /* Types of selections we may make. Note that Qcut_buffer0 isn't really
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
57 a selection, but it acts like one for the sake of Fx_own_selection and
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
58 Fx_selection_value. */
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
59 Lisp_Object Qprimary, Qsecondary, Qclipboard, Qcut_buffer0;
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
60
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
61 /* Emacs' selection property identifiers. */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 Atom Xatom_emacs_selection;
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
63 Atom Xatom_emacs_secondary_selection;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 /* Clipboard selection atom. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 Atom Xatom_clipboard_selection;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 /* Clipboard atom. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 Atom Xatom_clipboard;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 /* Atom for indicating incremental selection transfer. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 Atom Xatom_incremental;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 /* Atom for indicating multiple selection request list */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 Atom Xatom_multiple;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 /* Atom for what targets emacs handles. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 Atom Xatom_targets;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 /* Atom for indicating timstamp selection request */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 Atom Xatom_timestamp;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 /* Atom requesting we delete our selection. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 Atom Xatom_delete;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 /* Selection magic. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 Atom Xatom_insert_selection;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 /* Type of property for INSERT_SELECTION. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 Atom Xatom_pair;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 /* More selection magic. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 Atom Xatom_insert_property;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 /* Atom for indicating property type TEXT */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 Atom Xatom_text;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
98 /* Kinds of protocol things we may receive. */
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
99 Atom Xatom_wm_take_focus;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
100 Atom Xatom_wm_save_yourself;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
101 Atom Xatom_wm_delete_window;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
102
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
103 /* Communication with window managers. */
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
104 Atom Xatom_wm_protocols;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
105
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 /* These are to handle incremental selection transfer. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 Window incr_requestor;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 Atom incr_property;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 int incr_nbytes;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 unsigned char *incr_value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 unsigned char *incr_ptr;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 /* SELECTION OWNER CODE */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
115
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
116 /* Request selection ownership if we do not already have it. */
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
117
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
118 static int
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
119 own_selection (selection_type, time)
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
120 Atom selection_type;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
121 Time time;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
122 {
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
123 Window owner_window, selecting_window;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
124
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
125 if ((EQ (selection_type, Qprimary) && !NILP (Vx_selection_value))
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
126 || ((EQ (selection_type, Qsecondary)) && !NILP (Vx_secondary_selection_value))
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
127 || ((EQ (selection_type, Qclipboard)) && !NILP (Vx_clipboard_value)))
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
128 return 1;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
129
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
130 selecting_window = selected_screen->display.x->window_desc;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
131 XSetSelectionOwner (x_current_display, selection_type,
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
132 selecting_window, time);
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
133 owner_window = XGetSelectionOwner (x_current_display, selection_type);
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
134
648
70b112526394 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 641
diff changeset
135 if (owner_window != selecting_window)
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
136 return 0;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
137
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
138 return 1;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
139 }
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
140
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 /* Become the selection owner and make our data the selection value.
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 If we are already the owner, merely change data and timestamp values.
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 This avoids generating SelectionClear events for ourselves. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 DEFUN ("x-own-selection", Fx_own_selection, Sx_own_selection,
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
146 1, 2, "",
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
147 "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
148 but optional second argument TYPE may specify secondary or clipboard.\n\
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
149 \n\
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
150 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
151 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
152 applications which still use the cut buffers; new applications should\n\
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
153 use X selections.")
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
154 (string, type)
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
155 register Lisp_Object string, type;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 {
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
157 Atom selection_type;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
158 Lisp_Object val;
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
159 Time event_time = last_event_timestamp;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 CHECK_STRING (string, 0);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
162 if (NILP (type) || EQ (type, Qprimary))
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 {
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
164 BLOCK_INPUT;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
165 if (own_selection (XA_PRIMARY, event_time))
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
166 {
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
167 x_begin_selection_own = event_time;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
168 val = Vx_selection_value = string;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
169 }
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
170 UNBLOCK_INPUT;
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
171 }
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
172 else if (EQ (type, Qsecondary))
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
173 {
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
174 BLOCK_INPUT;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
175 if (own_selection (XA_SECONDARY, event_time))
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 {
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
177 x_begin_secondary_selection_own = event_time;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
178 val = Vx_secondary_selection_value = string;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 }
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
180 UNBLOCK_INPUT;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 }
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
182 else if (EQ (type, Qclipboard))
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 BLOCK_INPUT;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
185 if (own_selection (Xatom_clipboard, event_time))
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
186 {
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
187 x_begin_clipboard_own = event_time;
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
188 val = Vx_clipboard_value = string;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
189 }
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
190 UNBLOCK_INPUT;
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
191 }
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
192 else if (EQ (type, Qcut_buffer0))
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
193 {
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
194 BLOCK_INPUT;
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
195 XStoreBytes (x_current_display,
732
a8d94735277e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 708
diff changeset
196 (char *) XSTRING (string)->data,
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
197 XSTRING (string)->size);
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
198 UNBLOCK_INPUT;
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
199 }
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
200 else
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
201 error ("Invalid X selection 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 return val;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 /* Clear our selection ownership data, as some other client has
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 become the owner. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 void
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 x_disown_selection (old_owner, selection, changed_owner_time)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 Window *old_owner;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 Atom selection;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 Time changed_owner_time;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 struct screen *s = x_window_to_screen (old_owner);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 if (s) /* We are the owner */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 if (selection == XA_PRIMARY)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 x_begin_selection_own = 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 Vx_selection_value = Qnil;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 }
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
224 else if (selection == XA_SECONDARY)
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
225 {
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
226 x_begin_secondary_selection_own = 0;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
227 Vx_secondary_selection_value = Qnil;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
228 }
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 else if (selection == Xatom_clipboard)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 x_begin_clipboard_own = 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 Vx_clipboard_value = Qnil;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 abort ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 abort (); /* Inconsistent state. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 int x_selection_alloc_error;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242 int x_converting_selection;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 /* Reply to some client's request for our selection data. Data is
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
245 placed in a property supplied by the requesting window.
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247 If the data exceeds the maximum amount the server can send,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248 then prepare to send it incrementally, and reply to the client with
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 the total size of the data.
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 But first, check for all the other crufty stuff we could get. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 void
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 x_answer_selection_request (event)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 XSelectionRequestEvent event;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 Time emacs_own_time;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 Lisp_Object selection_value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 XSelectionEvent evt;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260 int format = 8; /* We have only byte sized (text) data. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 evt.type = SelectionNotify; /* Construct reply event */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 evt.display = event.display;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 evt.requestor = event.requestor;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 evt.selection = event.selection;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 evt.time = event.time;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 evt.target = event.target;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 if (event.selection == XA_PRIMARY)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 emacs_own_time = x_begin_selection_own;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 selection_value = Vx_selection_value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 }
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
274 else if (event.selection == XA_SECONDARY)
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
275 {
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
276 emacs_own_time = x_begin_secondary_selection_own;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
277 selection_value = Vx_secondary_selection_value;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
278 }
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 else if (event.selection == Xatom_clipboard)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 emacs_own_time = x_begin_clipboard_own;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 selection_value = Vx_clipboard_value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 abort ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 if (event.time != CurrentTime
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 && event.time < emacs_own_time)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 evt.property = None;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 if (event.property == None) /* obsolete client */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 evt.property = event.target;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295 evt.property = event.property;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298 if (event.target == Xatom_targets) /* Send List of target atoms */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299 {
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 if (event.target == Xatom_multiple) /* Recvd list: <target, prop> */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303 Atom type;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304 int return_format;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305 unsigned long items, bytes_left;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 unsigned char *data;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307 int result, i;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
309 if (event.property == 0 /* 0 == NILP */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 || event.property == None)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 return;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 result = XGetWindowProperty (event.display, event.requestor,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 event.property, 0L, 10000000L,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315 True, Xatom_pair, &type, &return_format,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316 &items, &bytes_left, &data);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318 if (result == Success && type == Xatom_pair)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319 for (i = items; i > 0; i--)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321 /* Convert each element of the list. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324 (void) XSendEvent (x_current_display, evt.requestor, False,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 0L, (XEvent *) &evt);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 return;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 else if (event.target == Xatom_timestamp) /* Send ownership timestamp */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 if (! emacs_own_time)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 abort ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333 format = 32;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 XChangeProperty (evt.display, evt.requestor, evt.property,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 evt.target, format, PropModeReplace,
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
336 (unsigned char *) &emacs_own_time, 1);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337 return;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 else if (event.target == Xatom_delete) /* Delete our selection. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 if (EQ (Qnil, selection_value))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 abort ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344 x_disown_selection (event.owner, event.selection, event.time);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
346 /* Now return property of type NILP, length 0. */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 XChangeProperty (event.display, event.requestor, event.property,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 0, format, PropModeReplace, (unsigned char *) 0, 0);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 return;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 else if (event.target == Xatom_insert_selection)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 Atom type;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354 int return_format;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355 unsigned long items, bytes_left;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 unsigned char *data;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 int result = XGetWindowProperty (event.display, event.requestor,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 event.property, 0L, 10000000L,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359 True, Xatom_pair, &type, &return_format,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360 &items, &bytes_left, &data);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361 if (result == Success && type == Xatom_pair)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 /* Convert the first atom to (a selection) to the target
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
364 indicated by the second atom. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367 else if (event.target == Xatom_insert_property)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 Atom type;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
370 int return_format;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 unsigned long items, bytes_left;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 unsigned char *data;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 int result = XGetWindowProperty (event.display, event.requestor,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 event.property, 0L, 10000000L,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 True, XA_STRING, &type, &return_format,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376 &items, &bytes_left, &data);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
377
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378 if (result == Success && type == XA_STRING && return_format == 8)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
379 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
380 if (event.selection == Xatom_emacs_selection)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381 Vx_selection_value = make_string (data);
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
382 else if (event.selection == Xatom_emacs_secondary_selection)
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
383 Vx_secondary_selection_value = make_string (data);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
384 else if (event.selection == Xatom_clipboard_selection)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
385 Vx_clipboard_value = make_string (data);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
386 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
387 abort ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
389
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
390 return;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
391 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
392 else if ((event.target == Xatom_text
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
393 || event.target == XA_STRING))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
394 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
395 int size = XSTRING (selection_value)->size;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396 unsigned char *data = XSTRING (selection_value)->data;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
397
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
398 if (EQ (Qnil, selection_value))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
399 abort ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401 /* Place data on requestor window's property. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402 if (SELECTION_LENGTH (size, format)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
403 <= MAX_SELECTION (x_current_display))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
404 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
405 x_converting_selection = 1;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
406 XChangeProperty (evt.display, evt.requestor, evt.property,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
407 evt.target, format, PropModeReplace,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
408 data, size);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
409 if (x_selection_alloc_error)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
410 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
411 x_selection_alloc_error = 0;
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_converting_selection = 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
416 else /* Send incrementally */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418 evt.target = Xatom_incremental;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419 incr_requestor = evt.requestor;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420 incr_property = evt.property;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
421 x_converting_selection = 1;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
422
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423 /* Need to handle Alloc errors on these requests. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424 XChangeProperty (evt.display, incr_requestor, incr_property,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 Xatom_incremental, 32,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
426 PropModeReplace,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
427 (unsigned char *) &size, 1);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428 if (x_selection_alloc_error)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
429 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 x_selection_alloc_error = 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
431 x_converting_selection = 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 abort ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
433 /* Now abort the send. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
434 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
436 incr_nbytes = size;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437 incr_value = data;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
438 incr_ptr = data;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440 /* Ask for notification when requestor deletes property. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441 XSelectInput (x_current_display, incr_requestor, PropertyChangeMask);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 /* If we're sending incrementally, perhaps block here
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444 until all sent? */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
448 evt.property = None;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
449
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
450 /* Don't do this if there was an Alloc error: abort the transfer
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451 by sending None. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
452 (void) XSendEvent (x_current_display, evt.requestor, False,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
453 0L, (XEvent *) &evt);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
454 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
456 /* Send an increment of selection data in response to a PropertyNotify event.
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
457 The increment is placed in a property on the requestor's window.
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458 When the requestor has processed the increment, it deletes the property,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459 which sends us another PropertyNotify event.
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
460
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461 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
462
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
463 void
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
464 x_send_incremental (event)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
465 XPropertyEvent event;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
466 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467 if (incr_requestor
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468 && incr_requestor == event.window
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
469 && incr_property == event.atom
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
470 && event.state == PropertyDelete)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
471 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472 int format = 8;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
473 int length = MAX_SELECTION (x_current_display);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474 int bytes_left = (incr_nbytes - (incr_ptr - incr_value));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
475
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
476 if (length > bytes_left) /* Also sends 0 len when finished. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
477 length = bytes_left;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
478 XChangeProperty (x_current_display, incr_requestor,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
479 incr_property, XA_STRING, format,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
480 PropModeAppend, incr_ptr, length);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
481 if (x_selection_alloc_error)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
482 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
483 x_selection_alloc_error = 0;
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 /* Abandon the transmission. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
486 abort ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
487 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
488 if (length > 0)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
489 incr_ptr += length;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
490 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
491 { /* Everything's sent */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
492 XSelectInput (x_current_display, incr_requestor, 0L);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
493 incr_requestor = (Window) 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
494 incr_property = (Atom) 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
495 incr_nbytes = 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
496 incr_value = (unsigned char *) 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
497 incr_ptr = (unsigned char *) 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
498 x_converting_selection = 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
499 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
500 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
501 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
502
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
503 /* SELECTION REQUESTOR CODE */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
504
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
505 /* Predicate function used to match a requested event. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
506
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
507 Bool
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
508 XCheckSelectionEvent (dpy, event, window)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
509 Display *dpy;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
510 XEvent *event;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
511 char *window;
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 (event->type == SelectionNotify)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
514 if (event->xselection.requestor == (Window) window)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
515 return True;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
516
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
517 return False;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
518 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
519
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
520 /* Request a selection value from its owner. This will block until
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
521 all the data is arrived. */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
522
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
523 static Lisp_Object
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
524 get_selection_value (type)
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
525 Atom type;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
526 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
527 XEvent event;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
528 Lisp_Object val;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
529 Time requestor_time; /* Timestamp of selection request. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
530 Window requestor_window;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
531
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
532 BLOCK_INPUT;
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
533 requestor_time = last_event_timestamp;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
534 requestor_window = selected_screen->display.x->window_desc;
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
535 XConvertSelection (x_current_display, type, XA_STRING,
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
536 Xatom_emacs_selection, requestor_window, requestor_time);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
537 XIfEvent (x_current_display,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
538 &event,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
539 XCheckSelectionEvent,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
540 (char *) requestor_window);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
541 val = x_selection_arrival (&event, requestor_window, requestor_time);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
542 UNBLOCK_INPUT;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
543
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
544 return val;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
545 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
546
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
547 /* 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
548 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
549 will block until all of the data has arrived. */
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
550
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
551 DEFUN ("x-selection-value", Fx_selection_value, Sx_selection_value,
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
552 0, 1, "",
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
553 "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
554 selection, but optional argument TYPE may specify secondary or clipboard.")
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
555 (type)
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
556 register Lisp_Object type;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
557 {
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
558 Atom selection_type;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
559
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
560 if (NILP (type) || EQ (type, Qprimary))
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
561 {
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
562 if (!NILP (Vx_selection_value))
648
70b112526394 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 641
diff changeset
563 return Vx_selection_value;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
564
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
565 return get_selection_value (XA_PRIMARY);
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
566 }
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
567 else if (EQ (type, Qsecondary))
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
568 {
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
569 if (!NILP (Vx_secondary_selection_value))
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
570 return Vx_secondary_selection_value;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
571
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
572 return get_selection_value (XA_SECONDARY);
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
573 }
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
574 else if (EQ (type, Qclipboard))
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
575 {
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
576 if (!NILP (Vx_clipboard_value))
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
577 return Vx_clipboard_value;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
578
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
579 return get_selection_value (Xatom_clipboard);
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
580 }
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
581 else if (EQ (type, Qcut_buffer0))
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
582 {
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
583 char *data;
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
584 int size;
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
585 Lisp_Object string;
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
586
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
587 BLOCK_INPUT;
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
588 data = XFetchBytes (x_current_display, &size);
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
589 if (data == 0)
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
590 string = Qnil;
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
591 else
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
592 string = make_string (data, size);
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
593 UNBLOCK_INPUT;
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
594
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
595 return string;
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
596 }
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
597 else
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
598 error ("Invalid X selection 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
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
601 Lisp_Object
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
602 x_selection_arrival (event, requestor_window, requestor_time)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
603 register XSelectionEvent *event;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
604 Window requestor_window;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
605 Time requestor_time;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
606 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
607 int result;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
608 Atom type, selection;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
609 int format;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
610 unsigned long items;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
611 unsigned long bytes_left;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
612 unsigned char *data = 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
613 int offset = 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
614
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
615 if (event->selection == XA_PRIMARY)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
616 selection = Xatom_emacs_selection;
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
617 else if (event->selection == XA_SECONDARY)
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
618 selection = Xatom_emacs_secondary_selection;
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
619 else if (event->selection == Xatom_clipboard)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
620 selection = Xatom_clipboard_selection;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
621 else
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
622 abort ();
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
623
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
624 if (event->requestor == requestor_window
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
625 && event->time == requestor_time
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
626 && event->property != None)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
627 if (event->target != Xatom_incremental)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
628 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
629 unsigned char *return_string =
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
630 (unsigned char *) alloca (MAX_SELECTION (x_current_display));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
631
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
632 do
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
633 {
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
634 result = XGetWindowProperty (x_current_display, requestor_window,
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
635 event->property, 0L,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
636 10000000L, True, XA_STRING,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
637 &type, &format, &items,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
638 &bytes_left, &data);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
639 if (result == Success && type == XA_STRING && format == 8
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
640 && offset < MAX_SELECTION (x_current_display))
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
641 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
642 bcopy (data, return_string + offset, items);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
643 offset += items;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
644 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
645 XFree ((char *) data);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
646 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
647 while (bytes_left);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
648
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
649 return make_string (return_string, offset);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
650 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
651 else /* Prepare incremental transfer. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
652 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
653 unsigned char *increment_value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
654 unsigned char *increment_ptr;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
655 int total_size;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
656 int *increment_nbytes = 0;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
657
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
658 result = XGetWindowProperty (x_current_display, requestor_window,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
659 selection, 0L, 10000000L, False,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
660 event->property, &type, &format,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
661 &items, &bytes_left,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
662 (unsigned char **) &increment_nbytes);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
663 if (result == Success)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
664 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
665 XPropertyEvent property_event;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
666
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
667 total_size = *increment_nbytes;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
668 increment_value = (unsigned char *) alloca (total_size);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
669 increment_ptr = increment_value;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
670
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
671 XDeleteProperty (x_current_display, event->requestor,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
672 event->property);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
673 XFlush (x_current_display);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
674 XFree ((char *) increment_nbytes);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
675
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
676 do
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
677 { /* NOTE: this blocks. */
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
678 XWindowEvent (x_current_display, requestor_window,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
679 PropertyChangeMask,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
680 (XEvent *) &property_event);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
681
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
682 if (property_event.atom == selection
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
683 && property_event.state == PropertyNewValue)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
684 do
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
685 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
686 result = XGetWindowProperty (x_current_display,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
687 requestor_window,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
688 selection, 0L,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
689 10000000L, True,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
690 AnyPropertyType,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
691 &type, &format,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
692 &items, &bytes_left,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
693 &data);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
694 if (result == Success && type == XA_STRING
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
695 && format == 8)
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
696 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
697 bcopy (data, increment_ptr, items);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
698 increment_ptr += items;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
699 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
700 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
701 while (bytes_left);
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
702
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
703 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
704 while (increment_ptr < (increment_value + total_size));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
705
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
706 return make_string (increment_value,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
707 (increment_ptr - increment_value));
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
708 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
709 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
710
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
711 return Qnil;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
712 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
713
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
714 void
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
715 syms_of_xselect ()
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
716 {
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
717 DEFVAR_LISP ("x-selection-value", &Vx_selection_value,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
718 "The value of emacs' last cut-string.");
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
719 Vx_selection_value = Qnil;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
720
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
721 DEFVAR_LISP ("x-secondary-selection-value", &Vx_secondary_selection_value,
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
722 "The value of emacs' last secondary cut-string.");
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
723 Vx_secondary_selection_value = Qnil;
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
724
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
725 DEFVAR_LISP ("x-clipboard-value", &Vx_clipboard_value,
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
726 "The string emacs last sent to the clipboard.");
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
727 Vx_clipboard_value = Qnil;
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
728
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
729 Qprimary = intern ("primary");
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
730 staticpro (&Qprimary);
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
731 Qsecondary = intern ("secondary");
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
732 staticpro (&Qsecondary);
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
733 Qclipboard = intern ("clipboard");
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
734 staticpro (&Qclipboard);
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
735 Qcut_buffer0 = intern ("cut-buffer0");
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 648
diff changeset
736 staticpro (&Qcut_buffer0);
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
737
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
738 defsubr (&Sx_own_selection);
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 485
diff changeset
739 defsubr (&Sx_selection_value);
159
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
740 }
e7abb99c2a38 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
741 #endif /* X11 */