428
|
1 /* Definitions for the new event model;
|
|
2 created 16-jul-91 by Jamie Zawinski
|
|
3 Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
|
788
|
4 Copyright (C) 1995, 1996, 2002 Ben Wing.
|
428
|
5
|
|
6 This file is part of XEmacs.
|
|
7
|
|
8 XEmacs is free software; you can redistribute it and/or modify it
|
|
9 under the terms of the GNU General Public License as published by the
|
|
10 Free Software Foundation; either version 2, or (at your option) any
|
|
11 later version.
|
|
12
|
|
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
16 for more details.
|
|
17
|
|
18 You should have received a copy of the GNU General Public License
|
|
19 along with XEmacs; see the file COPYING. If not, write to
|
|
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
21 Boston, MA 02111-1307, USA. */
|
|
22
|
|
23 /* Synched up with: Not in FSF. */
|
|
24
|
440
|
25 #ifndef INCLUDED_events_h_
|
|
26 #define INCLUDED_events_h_
|
428
|
27
|
|
28 #include "systime.h"
|
|
29
|
2367
|
30 /*
|
428
|
31
|
2367
|
32 See also
|
428
|
33
|
2367
|
34 (Info-goto-node "(internals)Event Stream Callback Routines")
|
|
35 (Info-goto-node "(internals)Stream Pairs")
|
428
|
36
|
|
37 */
|
|
38
|
|
39 /* typedef unsigned int USID; in lisp.h */
|
|
40 #define USID_ERROR ((USID)-1)
|
|
41 #define USID_DONTHASH ((USID)0)
|
|
42
|
|
43
|
|
44 struct event_stream
|
|
45 {
|
|
46 int (*event_pending_p) (int);
|
440
|
47 void (*next_event_cb) (Lisp_Event *);
|
|
48 void (*handle_magic_event_cb) (Lisp_Event *);
|
788
|
49 void (*format_magic_event_cb) (Lisp_Event *, Lisp_Object pstream);
|
|
50 int (*compare_magic_event_cb) (Lisp_Event *, Lisp_Event *);
|
|
51 Hashcode (*hash_magic_event_cb)(Lisp_Event *);
|
428
|
52 int (*add_timeout_cb) (EMACS_TIME);
|
|
53 void (*remove_timeout_cb) (int);
|
|
54 void (*select_console_cb) (struct console *);
|
|
55 void (*unselect_console_cb) (struct console *);
|
853
|
56 void (*select_process_cb) (Lisp_Process *, int doin, int doerr);
|
|
57 void (*unselect_process_cb) (Lisp_Process *, int doin, int doerr);
|
1204
|
58 void (*drain_queue_cb) (void);
|
|
59 void (*force_event_pending_cb)(struct frame* f);
|
853
|
60 void (*create_io_streams_cb) (void* /* inhandle*/, void* /*outhandle*/ ,
|
|
61 void * /* errhandle*/,
|
428
|
62 Lisp_Object* /* instream */,
|
|
63 Lisp_Object* /* outstream */,
|
853
|
64 Lisp_Object* /* errstream */,
|
|
65 USID * /* in_usid */, USID * /* err_usid */,
|
428
|
66 int /* flags */);
|
853
|
67 void (*delete_io_streams_cb) (Lisp_Object /* instream */,
|
|
68 Lisp_Object /* outstream */,
|
|
69 Lisp_Object /* errstream */,
|
|
70 USID * /* in_usid */, USID * /* err_usid */);
|
442
|
71 int (*current_event_timestamp_cb) (struct console *);
|
428
|
72 };
|
|
73
|
853
|
74 /* Flags for create_io_streams_cb() FLAGS parameter */
|
428
|
75 #define STREAM_PTY_FLUSHING 0x0001
|
|
76 #define STREAM_NETWORK_CONNECTION 0x0002
|
|
77
|
|
78 extern struct event_stream *event_stream;
|
|
79
|
1204
|
80 #ifdef EVENT_DATA_AS_OBJECTS
|
|
81 #define EVENT_FOO_BAR_1(extractor, field) ((extractor)->field)
|
|
82 #define EVENT_FOO_BAR(e, uptype, downtype, field) EVENT_FOO_BAR_1 (X##uptype##_DATA (EVENT_DATA (e)), field)
|
|
83 #define SET_EVENT_FOO_BAR_1(extractor, field, val) \
|
|
84 do { (extractor)->field = (val); } while (0)
|
|
85 #define SET_EVENT_FOO_BAR(e, uptype, downtype, field, val) SET_EVENT_FOO_BAR_1 (X##uptype##_DATA (EVENT_DATA (e)), field, val)
|
|
86 #else
|
|
87 #define EVENT_FOO_BAR(e, uptype, downtype, field) ((e)->event.downtype.field)
|
|
88 #define SET_EVENT_FOO_BAR(e, uptype, downtype, field, val) \
|
|
89 do { (e)->event.downtype.field = (val); } while (0)
|
|
90 #endif
|
934
|
91
|
428
|
92 typedef enum emacs_event_type
|
|
93 {
|
|
94 empty_event,
|
|
95 key_press_event,
|
|
96 button_press_event,
|
|
97 button_release_event,
|
|
98 pointer_motion_event,
|
|
99 process_event,
|
|
100 timeout_event,
|
|
101 magic_event,
|
|
102 magic_eval_event,
|
|
103 eval_event,
|
|
104 misc_user_event,
|
|
105 dead_event
|
|
106 } emacs_event_type;
|
|
107
|
|
108 #define first_event_type empty_event
|
|
109 #define last_event_type dead_event
|
|
110
|
771
|
111 #ifdef MULE
|
|
112
|
|
113 enum alternative_key_chars
|
|
114 {
|
|
115 KEYCHAR_CURRENT_LANGENV,
|
|
116 KEYCHAR_DEFAULT_USER,
|
|
117 KEYCHAR_DEFAULT_SYSTEM,
|
|
118 KEYCHAR_UNDERLYING_VIRTUAL_KEY_CURRENT_LANGENV,
|
|
119 KEYCHAR_UNDERLYING_VIRTUAL_KEY_DEFAULT_USER,
|
|
120 KEYCHAR_UNDERLYING_VIRTUAL_KEY_DEFAULT_SYSTEM,
|
|
121 KEYCHAR_QWERTY,
|
|
122 KEYCHAR_LAST
|
|
123 };
|
|
124
|
|
125 #endif /* MULE */
|
428
|
126
|
934
|
127 struct Lisp_Key_Data
|
428
|
128 {
|
1204
|
129 #ifdef EVENT_DATA_AS_OBJECTS
|
934
|
130 struct lrecord_header lheader;
|
1204
|
131 #endif /* EVENT_DATA_AS_OBJECTS */
|
771
|
132 /* What keysym this is; a character or a symbol. */
|
|
133 Lisp_Object keysym;
|
|
134 /* Modifiers held down when key was pressed: control, meta, etc.
|
|
135 Also includes buttons. For many keys, Shift is not a bit; that
|
|
136 is implicit in the keyboard layout. */
|
|
137 int modifiers;
|
|
138 #ifdef MULE
|
|
139 /* Alternate character interpretations for this key in different
|
|
140 keyboard layouts. This deals with the problem of pressing C-x in
|
|
141 the Russian layout (the so-called "Russian C-x problem"), for
|
|
142 example: `x' gets mapped to a Cyrillic character, so what do we
|
|
143 do? For that matter, what about `C-x b'? What we do is look the
|
|
144 key up in the default locales (current language environment, user
|
|
145 default, system default), then check to see if the underlying
|
|
146 virtual key is alphabetic in the same three defaults, then
|
|
147 finally check US ASCII. We ignore the underlying virtual key for
|
|
148 the current layout to avoid the problem of a French speaker
|
|
149 (AZERTY layout) who temporarily switches to Russian: The virtual
|
|
150 keys underlying Russian are US-ASCII, so what the French speaker
|
|
151 things of as C-a (the key just to the right of TAB) appears as
|
|
152 C-q. (#### We should probably ignore the current char and look
|
|
153 *ONLY* in alt_keychars for all control keys. What about the
|
|
154 English speaker who temporarily switches to the French layout and
|
|
155 finds C-q mapped to C-a?) */
|
867
|
156 Ichar alt_keychars[KEYCHAR_LAST];
|
771
|
157 #endif /* MULE */
|
428
|
158 };
|
|
159
|
934
|
160 typedef struct Lisp_Key_Data Lisp_Key_Data;
|
|
161
|
1204
|
162 #define KEY_DATA_KEYSYM(d) ((d)->keysym)
|
|
163 #define KEY_DATA_MODIFIERS(d) ((d)->modifiers)
|
|
164 #define SET_KEY_DATA_KEYSYM(d, k) ((d)->keysym = k)
|
|
165 #define SET_KEY_DATA_MODIFIERS(d, m) ((d)->modifiers = m)
|
|
166
|
|
167 #ifdef EVENT_DATA_AS_OBJECTS
|
934
|
168 DECLARE_LRECORD (key_data, Lisp_Key_Data);
|
|
169 #define XKEY_DATA(x) XRECORD (x, key_data, Lisp_Key_Data)
|
|
170 #define wrap_key_data(p) wrap_record (p, key_data)
|
|
171 #define KEY_DATAP(x) RECORDP (x, key_data)
|
|
172 #define CHECK_KEY_DATA(x) CHECK_RECORD (x, key_data)
|
|
173 #define CONCHECK_KEY_DATA(x) CONCHECK_RECORD (x, key_data)
|
1204
|
174 #endif /* EVENT_DATA_AS_OBJECTS */
|
934
|
175
|
1204
|
176 #define EVENT_KEY_KEYSYM(e) EVENT_FOO_BAR (e, KEY, key, keysym)
|
|
177 #define XEVENT_KEY_KEYSYM(e) EVENT_KEY_KEYSYM (XEVENT (e))
|
|
178 #define SET_EVENT_KEY_KEYSYM(e, val) \
|
|
179 SET_EVENT_FOO_BAR (e, KEY, key, keysym, val)
|
|
180 #define XSET_EVENT_KEY_KEYSYM(e, val) \
|
|
181 SET_EVENT_KEY_KEYSYM (XEVENT (e), val)
|
934
|
182
|
1204
|
183 #define EVENT_KEY_MODIFIERS(e) EVENT_FOO_BAR (e, KEY, key, modifiers)
|
|
184 #define XEVENT_KEY_MODIFIERS(e) EVENT_KEY_MODIFIERS (XEVENT (e))
|
|
185 #define SET_EVENT_KEY_MODIFIERS(e, val) \
|
|
186 SET_EVENT_FOO_BAR (e, KEY, key, modifiers, val)
|
|
187 #define XSET_EVENT_KEY_MODIFIERS(e, val) \
|
|
188 SET_EVENT_KEY_MODIFIERS (XEVENT (e), val)
|
934
|
189
|
1204
|
190 #define EVENT_KEY_ALT_KEYCHARS(e, n) \
|
|
191 EVENT_FOO_BAR (e, KEY, key, alt_keychars[n])
|
|
192 #define XEVENT_KEY_ALT_KEYCHARS(e, n) EVENT_KEY_ALT_KEYCHARS (XEVENT (e), n)
|
|
193 #define SET_EVENT_KEY_ALT_KEYCHARS(e, n, val) \
|
|
194 SET_EVENT_FOO_BAR (e, KEY, key, alt_keychars[n], val)
|
|
195 #define XSET_EVENT_KEY_ALT_KEYCHARS(e, n, val) \
|
|
196 SET_EVENT_KEY_ALT_KEYCHARS (XEVENT (e), n, val)
|
|
197
|
934
|
198 struct Lisp_Button_Data
|
428
|
199 {
|
1204
|
200 #ifdef EVENT_DATA_AS_OBJECTS
|
934
|
201 struct lrecord_header lheader;
|
1204
|
202 #endif /* EVENT_DATA_AS_OBJECTS */
|
771
|
203 /* What button went down or up. */
|
|
204 int button;
|
|
205 /* Bucky-bits on that button: shift, control, meta, etc. Also
|
|
206 includes other buttons (not the one pressed). */
|
|
207 int modifiers;
|
|
208 /* Where it was at the button-state-change (in pixels). */
|
|
209 int x, y;
|
428
|
210 };
|
934
|
211 typedef struct Lisp_Button_Data Lisp_Button_Data;
|
428
|
212
|
1204
|
213 #ifdef EVENT_DATA_AS_OBJECTS
|
934
|
214 DECLARE_LRECORD (button_data, Lisp_Button_Data);
|
|
215 #define XBUTTON_DATA(x) XRECORD (x, button_data, Lisp_Button_Data)
|
|
216 #define wrap_button_data(p) wrap_record (p, button_data)
|
|
217 #define BUTTON_DATAP(x) RECORDP (x, button_data)
|
|
218 #define CHECK_BUTTON_DATA(x) CHECK_RECORD (x, button_data)
|
|
219 #define CONCHECK_BUTTON_DATA(x) CONCHECK_RECORD (x, button_data)
|
1204
|
220 #endif /* EVENT_DATA_AS_OBJECTS */
|
934
|
221
|
1204
|
222 #define EVENT_BUTTON_BUTTON(e) EVENT_FOO_BAR (e, BUTTON, button, button)
|
|
223 #define XEVENT_BUTTON_BUTTON(e) EVENT_BUTTON_BUTTON (XEVENT (e))
|
|
224 #define SET_EVENT_BUTTON_BUTTON(e, val) \
|
|
225 SET_EVENT_FOO_BAR (e, BUTTON, button, button, val)
|
|
226 #define XSET_EVENT_BUTTON_BUTTON(e, val) \
|
|
227 SET_EVENT_BUTTON_BUTTON (XEVENT (e), val)
|
|
228
|
|
229 #define EVENT_BUTTON_MODIFIERS(e) EVENT_FOO_BAR (e, BUTTON, button, modifiers)
|
|
230 #define XEVENT_BUTTON_MODIFIERS(e) EVENT_BUTTON_MODIFIERS (XEVENT (e))
|
|
231 #define SET_EVENT_BUTTON_MODIFIERS(e, val) \
|
|
232 SET_EVENT_FOO_BAR (e, BUTTON, button, modifiers, val)
|
|
233 #define XSET_EVENT_BUTTON_MODIFIERS(e, val) \
|
|
234 SET_EVENT_BUTTON_MODIFIERS (XEVENT (e), val)
|
934
|
235
|
1204
|
236 #define EVENT_BUTTON_X(e) EVENT_FOO_BAR (e, BUTTON, button, x)
|
|
237 #define XEVENT_BUTTON_X(e) EVENT_BUTTON_X (XEVENT (e))
|
|
238 #define SET_EVENT_BUTTON_X(e, val) \
|
|
239 SET_EVENT_FOO_BAR (e, BUTTON, button, x, val)
|
|
240 #define XSET_EVENT_BUTTON_X(e, val) \
|
|
241 SET_EVENT_BUTTON_X (XEVENT (e), val)
|
934
|
242
|
1204
|
243 #define EVENT_BUTTON_Y(e) EVENT_FOO_BAR (e, BUTTON, button, y)
|
|
244 #define XEVENT_BUTTON_Y(e) EVENT_BUTTON_Y (XEVENT (e))
|
|
245 #define SET_EVENT_BUTTON_Y(e, val) \
|
|
246 SET_EVENT_FOO_BAR (e, BUTTON, button, y, val)
|
|
247 #define XSET_EVENT_BUTTON_Y(e, val) \
|
|
248 SET_EVENT_BUTTON_Y (XEVENT (e), val)
|
|
249
|
934
|
250 struct Lisp_Motion_Data
|
428
|
251 {
|
1204
|
252 #ifdef EVENT_DATA_AS_OBJECTS
|
934
|
253 struct lrecord_header lheader;
|
1204
|
254 #endif /* EVENT_DATA_AS_OBJECTS */
|
771
|
255 /* Where it was after it moved (in pixels). */
|
|
256 int x, y;
|
|
257 /* Bucky-bits down when the motion was detected. */
|
|
258 int modifiers;
|
428
|
259 };
|
934
|
260 typedef struct Lisp_Motion_Data Lisp_Motion_Data;
|
428
|
261
|
1204
|
262 #ifdef EVENT_DATA_AS_OBJECTS
|
934
|
263 DECLARE_LRECORD (motion_data, Lisp_Motion_Data);
|
|
264 #define XMOTION_DATA(x) XRECORD (x, motion_data, Lisp_Motion_Data)
|
|
265 #define wrap_motion_data(p) wrap_record (p, motion_data)
|
|
266 #define MOTION_DATAP(x) RECORDP (x, motion_data)
|
|
267 #define CHECK_MOTION_DATA(x) CHECK_RECORD (x, motion_data)
|
|
268 #define CONCHECK_MOTION_DATA(x) CONCHECK_RECORD (x, motion_data)
|
1204
|
269 #endif /* EVENT_DATA_AS_OBJECTS */
|
934
|
270
|
1204
|
271 #define EVENT_MOTION_X(e) EVENT_FOO_BAR (e, MOTION, motion, x)
|
|
272 #define XEVENT_MOTION_X(e) EVENT_MOTION_X (XEVENT (e))
|
|
273 #define SET_EVENT_MOTION_X(e, val) \
|
|
274 SET_EVENT_FOO_BAR (e, MOTION, motion, x, val)
|
|
275 #define XSET_EVENT_MOTION_X(e, val) \
|
|
276 SET_EVENT_MOTION_X (XEVENT (e), val)
|
934
|
277
|
1204
|
278 #define EVENT_MOTION_Y(e) EVENT_FOO_BAR (e, MOTION, motion, y)
|
|
279 #define XEVENT_MOTION_Y(e) EVENT_MOTION_Y (XEVENT (e))
|
|
280 #define SET_EVENT_MOTION_Y(e, val) \
|
|
281 SET_EVENT_FOO_BAR (e, MOTION, motion, y, val)
|
|
282 #define XSET_EVENT_MOTION_Y(e, val) \
|
|
283 SET_EVENT_MOTION_Y (XEVENT (e), val)
|
|
284
|
|
285 #define EVENT_MOTION_MODIFIERS(e) EVENT_FOO_BAR (e, MOTION, motion, modifiers)
|
|
286 #define XEVENT_MOTION_MODIFIERS(e) EVENT_MOTION_MODIFIERS (XEVENT (e))
|
|
287 #define SET_EVENT_MOTION_MODIFIERS(e, val) \
|
|
288 SET_EVENT_FOO_BAR (e, MOTION, motion, modifiers, val)
|
|
289 #define XSET_EVENT_MOTION_MODIFIERS(e, val) \
|
|
290 SET_EVENT_MOTION_MODIFIERS (XEVENT (e), val)
|
|
291
|
934
|
292 struct Lisp_Process_Data
|
428
|
293 {
|
1204
|
294 #ifdef EVENT_DATA_AS_OBJECTS
|
934
|
295 struct lrecord_header lheader;
|
1204
|
296 #endif /* EVENT_DATA_AS_OBJECTS */
|
771
|
297 /* the XEmacs "process" object in question */
|
|
298 Lisp_Object process;
|
428
|
299 };
|
934
|
300 typedef struct Lisp_Process_Data Lisp_Process_Data;
|
428
|
301
|
1204
|
302 #ifdef EVENT_DATA_AS_OBJECTS
|
934
|
303 DECLARE_LRECORD (process_data, Lisp_Process_Data);
|
|
304 #define XPROCESS_DATA(x) XRECORD (x, process_data, Lisp_Process_Data)
|
|
305 #define wrap_process_data(p) wrap_record (p, process_data)
|
|
306 #define PROCESS_DATAP(x) RECORDP (x, process_data)
|
|
307 #define CHECK_PROCESS_DATA(x) CHECK_RECORD (x, process_data)
|
|
308 #define CONCHECK_PROCESS_DATA(x) CONCHECK_RECORD (x, process_data)
|
1204
|
309 #endif /* EVENT_DATA_AS_OBJECTS */
|
934
|
310
|
1204
|
311 #define EVENT_PROCESS_PROCESS(e) EVENT_FOO_BAR (e, PROCESS, process, process)
|
|
312 #define XEVENT_PROCESS_PROCESS(e) EVENT_PROCESS_PROCESS (XEVENT (e))
|
|
313 #define SET_EVENT_PROCESS_PROCESS(e, val) \
|
|
314 SET_EVENT_FOO_BAR (e, PROCESS, process, process, val)
|
|
315 #define XSET_EVENT_PROCESS_PROCESS(e, val) \
|
|
316 SET_EVENT_PROCESS_PROCESS (XEVENT (e), val)
|
|
317
|
934
|
318 struct Lisp_Timeout_Data
|
428
|
319 {
|
771
|
320 /*
|
|
321 interval_id The ID returned when the associated call to
|
|
322 add_timeout_cb() was made
|
|
323 ------ the rest of the fields are filled in by XEmacs -----
|
|
324 id_number The XEmacs timeout ID for this timeout (more
|
|
325 than one timeout event can have the same value
|
|
326 here, since XEmacs timeouts, as opposed to
|
|
327 add_timeout_cb() timeouts, can resignal
|
|
328 themselves)
|
|
329 function An elisp function to call when this timeout is
|
|
330 processed.
|
|
331 object The object passed to that function.
|
|
332 */
|
1204
|
333 #ifdef EVENT_DATA_AS_OBJECTS
|
934
|
334 struct lrecord_header lheader;
|
1204
|
335 #endif /* EVENT_DATA_AS_OBJECTS */
|
771
|
336 int interval_id;
|
|
337 int id_number;
|
|
338 Lisp_Object function;
|
|
339 Lisp_Object object;
|
428
|
340 };
|
934
|
341 typedef struct Lisp_Timeout_Data Lisp_Timeout_Data;
|
428
|
342
|
1204
|
343 #ifdef EVENT_DATA_AS_OBJECTS
|
934
|
344 DECLARE_LRECORD (timeout_data, Lisp_Timeout_Data);
|
|
345 #define XTIMEOUT_DATA(x) XRECORD (x, timeout_data, Lisp_Timeout_Data)
|
|
346 #define wrap_timeout_data(p) wrap_record(p, timeout_data)
|
|
347 #define TIMEOUT_DATAP(x) RECORDP (x, timeout_data)
|
|
348 #define CHECK_TIMEOUT_DATA(x) CHECK_RECORD (x, timeout_data)
|
|
349 #define CONCHECK_TIMEOUT_DATA(x) CONCHECK_RECORD (x, timeout_data)
|
1204
|
350 #endif /* EVENT_DATA_AS_OBJECTS */
|
934
|
351
|
1204
|
352 #define EVENT_TIMEOUT_INTERVAL_ID(e) EVENT_FOO_BAR (e, TIMEOUT, timeout, interval_id)
|
|
353 #define XEVENT_TIMEOUT_INTERVAL_ID(e) EVENT_TIMEOUT_INTERVAL_ID (XEVENT (e))
|
|
354 #define SET_EVENT_TIMEOUT_INTERVAL_ID(e, val) \
|
|
355 SET_EVENT_FOO_BAR (e, TIMEOUT, timeout, interval_id, val)
|
|
356 #define XSET_EVENT_TIMEOUT_INTERVAL_ID(e, val) \
|
|
357 SET_EVENT_TIMEOUT_INTERVAL_ID (XEVENT (e), val)
|
|
358
|
|
359 #define EVENT_TIMEOUT_ID_NUMBER(e) EVENT_FOO_BAR (e, TIMEOUT, timeout, id_number)
|
|
360 #define XEVENT_TIMEOUT_ID_NUMBER(e) EVENT_TIMEOUT_ID_NUMBER (XEVENT (e))
|
|
361 #define SET_EVENT_TIMEOUT_ID_NUMBER(e, val) \
|
|
362 SET_EVENT_FOO_BAR (e, TIMEOUT, timeout, id_number, val)
|
|
363 #define XSET_EVENT_TIMEOUT_ID_NUMBER(e, val) \
|
|
364 SET_EVENT_TIMEOUT_ID_NUMBER (XEVENT (e), val)
|
934
|
365
|
1204
|
366 #define EVENT_TIMEOUT_FUNCTION(e) EVENT_FOO_BAR (e, TIMEOUT, timeout, function)
|
|
367 #define XEVENT_TIMEOUT_FUNCTION(e) EVENT_TIMEOUT_FUNCTION (XEVENT (e))
|
|
368 #define SET_EVENT_TIMEOUT_FUNCTION(e, val) \
|
|
369 SET_EVENT_FOO_BAR (e, TIMEOUT, timeout, function, val)
|
|
370 #define XSET_EVENT_TIMEOUT_FUNCTION(e, val) \
|
|
371 SET_EVENT_TIMEOUT_FUNCTION (XEVENT (e), val)
|
934
|
372
|
1204
|
373 #define EVENT_TIMEOUT_OBJECT(e) EVENT_FOO_BAR (e, TIMEOUT, timeout, object)
|
|
374 #define XEVENT_TIMEOUT_OBJECT(e) EVENT_TIMEOUT_OBJECT (XEVENT (e))
|
|
375 #define SET_EVENT_TIMEOUT_OBJECT(e, val) \
|
|
376 SET_EVENT_FOO_BAR (e, TIMEOUT, timeout, object, val)
|
|
377 #define XSET_EVENT_TIMEOUT_OBJECT(e, val) \
|
|
378 SET_EVENT_TIMEOUT_OBJECT (XEVENT (e), val)
|
|
379
|
934
|
380 struct Lisp_Eval_Data
|
428
|
381 {
|
771
|
382 /* This kind of event is used internally; sometimes the window system
|
|
383 interface would like to inform XEmacs of some user action (such as
|
|
384 focusing on another frame) but needs that to happen synchronously
|
|
385 with the other user input, like keypresses. This is useful when
|
|
386 events are reported through callbacks rather than in the standard
|
|
387 event stream.
|
|
388
|
|
389 function An elisp function to call with this event object.
|
|
390 object Argument of function.
|
|
391 */
|
1204
|
392 #ifdef EVENT_DATA_AS_OBJECTS
|
934
|
393 struct lrecord_header lheader;
|
1204
|
394 #endif /* EVENT_DATA_AS_OBJECTS */
|
771
|
395 Lisp_Object function;
|
|
396 Lisp_Object object;
|
428
|
397 };
|
934
|
398 typedef struct Lisp_Eval_Data Lisp_Eval_Data;
|
428
|
399
|
1204
|
400 #ifdef EVENT_DATA_AS_OBJECTS
|
934
|
401 DECLARE_LRECORD (eval_data, Lisp_Eval_Data);
|
|
402 #define XEVAL_DATA(x) XRECORD (x, eval_data, Lisp_Eval_Data)
|
|
403 #define wrap_eval_data(p) wrap_record(p, eval_data)
|
|
404 #define EVAL_DATAP(x) RECORDP (x, eval_data)
|
|
405 #define CHECK_EVAL_DATA(x) CHECK_RECORD (x, eval_data)
|
|
406 #define CONCHECK_EVAL_DATA(x) CONCHECK_RECORD (x, eval_data)
|
1204
|
407 #endif /* EVENT_DATA_AS_OBJECTS */
|
934
|
408
|
1204
|
409 #define EVENT_EVAL_FUNCTION(e) EVENT_FOO_BAR (e, EVAL, eval, function)
|
|
410 #define XEVENT_EVAL_FUNCTION(e) EVENT_EVAL_FUNCTION (XEVENT (e))
|
|
411 #define SET_EVENT_EVAL_FUNCTION(e, val) \
|
|
412 SET_EVENT_FOO_BAR (e, EVAL, eval, function, val)
|
|
413 #define XSET_EVENT_EVAL_FUNCTION(e, val) \
|
|
414 SET_EVENT_EVAL_FUNCTION (XEVENT (e), val)
|
934
|
415
|
1204
|
416 #define EVENT_EVAL_OBJECT(e) EVENT_FOO_BAR (e, EVAL, eval, object)
|
|
417 #define XEVENT_EVAL_OBJECT(e) EVENT_EVAL_OBJECT (XEVENT (e))
|
|
418 #define SET_EVENT_EVAL_OBJECT(e, val) \
|
|
419 SET_EVENT_FOO_BAR (e, EVAL, eval, object, val)
|
|
420 #define XSET_EVENT_EVAL_OBJECT(e, val) \
|
|
421 SET_EVENT_EVAL_OBJECT (XEVENT (e), val)
|
934
|
422
|
|
423 struct Lisp_Misc_User_Data
|
428
|
424 {
|
771
|
425 /* #### The misc-user type is serious junk. It should be separated
|
|
426 out into different events. There's no reason to create
|
|
427 sub-subtypes of events.
|
|
428
|
|
429 function An elisp function to call with this event object.
|
|
430 object Argument of function.
|
|
431 button What button went down or up.
|
|
432 modifiers Bucky-bits on that button: shift, control, meta, etc.
|
|
433 x, y Where it was at the button-state-change (in pixels).
|
|
434 This is similar to an eval_event, except that it is
|
|
435 generated by user actions: selections in the
|
|
436 menubar, scrollbar actions, or drag and drop actions.
|
|
437 It is a "command" event, like key and mouse presses
|
|
438 (and unlike mouse motion, process output, and enter
|
|
439 and leave window hooks). In many ways, eval_events
|
|
440 are not the same as keypresses or misc_user_events.
|
|
441 The button, modifiers, x, and y parts are only used
|
|
442 by the XEmacs Drag'n'Drop system. Don't depend on their
|
|
443 values for other types of misc_user_events.
|
|
444 */
|
1204
|
445 #ifdef EVENT_DATA_AS_OBJECTS
|
934
|
446 struct lrecord_header lheader;
|
1204
|
447 #endif /* EVENT_DATA_AS_OBJECTS */
|
771
|
448 Lisp_Object function;
|
|
449 Lisp_Object object;
|
|
450 int button;
|
|
451 int modifiers;
|
|
452 int x, y;
|
428
|
453 };
|
934
|
454 typedef struct Lisp_Misc_User_Data Lisp_Misc_User_Data;
|
428
|
455
|
1204
|
456 #ifdef EVENT_DATA_AS_OBJECTS
|
934
|
457 DECLARE_LRECORD (misc_user_data, Lisp_Misc_User_Data);
|
|
458 #define XMISC_USER_DATA(x) XRECORD (x, misc_user_data, Lisp_Misc_User_Data)
|
|
459 #define wrap_misc_user_data(p) wrap_record(p, misc_user_data)
|
|
460 #define MISC_USER_DATAP(x) RECORDP (x, misc_user_data)
|
|
461 #define CHECK_MISC_USER_DATA(x) CHECK_RECORD (x, misc_user_data)
|
|
462 #define CONCHECK_MISC_USER_DATA(x) CONCHECK_RECORD (x, misc_user_data)
|
1204
|
463 #endif /* EVENT_DATA_AS_OBJECTS */
|
934
|
464
|
1204
|
465 #define EVENT_MISC_USER_FUNCTION(e) EVENT_FOO_BAR (e, MISC_USER, misc_user, function)
|
|
466 #define XEVENT_MISC_USER_FUNCTION(e) EVENT_MISC_USER_FUNCTION (XEVENT (e))
|
|
467 #define SET_EVENT_MISC_USER_FUNCTION(e, val) \
|
|
468 SET_EVENT_FOO_BAR (e, MISC_USER, misc_user, function, val)
|
|
469 #define XSET_EVENT_MISC_USER_FUNCTION(e, val) \
|
|
470 SET_EVENT_MISC_USER_FUNCTION (XEVENT (e), val)
|
|
471
|
|
472 #define EVENT_MISC_USER_OBJECT(e) EVENT_FOO_BAR (e, MISC_USER, misc_user, object)
|
|
473 #define XEVENT_MISC_USER_OBJECT(e) EVENT_MISC_USER_OBJECT (XEVENT (e))
|
|
474 #define SET_EVENT_MISC_USER_OBJECT(e, val) \
|
|
475 SET_EVENT_FOO_BAR (e, MISC_USER, misc_user, object, val)
|
|
476 #define XSET_EVENT_MISC_USER_OBJECT(e, val) \
|
|
477 SET_EVENT_MISC_USER_OBJECT (XEVENT (e), val)
|
934
|
478
|
1204
|
479 #define EVENT_MISC_USER_BUTTON(e) EVENT_FOO_BAR (e, MISC_USER, misc_user, button)
|
|
480 #define XEVENT_MISC_USER_BUTTON(e) EVENT_MISC_USER_BUTTON (XEVENT (e))
|
|
481 #define SET_EVENT_MISC_USER_BUTTON(e, val) \
|
|
482 SET_EVENT_FOO_BAR (e, MISC_USER, misc_user, button, val)
|
|
483 #define XSET_EVENT_MISC_USER_BUTTON(e, val) \
|
|
484 SET_EVENT_MISC_USER_BUTTON (XEVENT (e), val)
|
|
485
|
|
486 #define EVENT_MISC_USER_MODIFIERS(e) EVENT_FOO_BAR (e, MISC_USER, misc_user, modifiers)
|
|
487 #define XEVENT_MISC_USER_MODIFIERS(e) EVENT_MISC_USER_MODIFIERS (XEVENT (e))
|
|
488 #define SET_EVENT_MISC_USER_MODIFIERS(e, val) \
|
|
489 SET_EVENT_FOO_BAR (e, MISC_USER, misc_user, modifiers, val)
|
|
490 #define XSET_EVENT_MISC_USER_MODIFIERS(e, val) \
|
|
491 SET_EVENT_MISC_USER_MODIFIERS (XEVENT (e), val)
|
934
|
492
|
1204
|
493 #define EVENT_MISC_USER_X(e) EVENT_FOO_BAR (e, MISC_USER, misc_user, x)
|
|
494 #define XEVENT_MISC_USER_X(e) EVENT_MISC_USER_X (XEVENT (e))
|
|
495 #define SET_EVENT_MISC_USER_X(e, val) \
|
|
496 SET_EVENT_FOO_BAR (e, MISC_USER, misc_user, x, val)
|
|
497 #define XSET_EVENT_MISC_USER_X(e, val) \
|
|
498 SET_EVENT_MISC_USER_X (XEVENT (e), val)
|
934
|
499
|
1204
|
500 #define EVENT_MISC_USER_Y(e) EVENT_FOO_BAR (e, MISC_USER, misc_user, y)
|
|
501 #define XEVENT_MISC_USER_Y(e) EVENT_MISC_USER_Y (XEVENT (e))
|
|
502 #define SET_EVENT_MISC_USER_Y(e, val) \
|
|
503 SET_EVENT_FOO_BAR (e, MISC_USER, misc_user, y, val)
|
|
504 #define XSET_EVENT_MISC_USER_Y(e, val) \
|
|
505 SET_EVENT_MISC_USER_Y (XEVENT (e), val)
|
934
|
506
|
|
507 struct Lisp_Magic_Eval_Data
|
428
|
508 {
|
771
|
509 /* This is like an eval event but its contents are not
|
|
510 Lisp-accessible. This allows for "internal eval events" that call
|
|
511 non-Lisp-accessible functions. Externally, a magic_eval_event just
|
|
512 appears as a magic_event; the Lisp programmer need not know
|
|
513 anything more.
|
|
514
|
|
515 internal_function An unexported function to call with this event
|
|
516 object. This allows eval events to call internal
|
|
517 functions. For a normal eval event, this field
|
|
518 will always be 0.
|
|
519 object Argument of function.
|
|
520
|
|
521 */
|
1204
|
522 #ifdef EVENT_DATA_AS_OBJECTS
|
934
|
523 struct lrecord_header lheader;
|
1204
|
524 #endif /* EVENT_DATA_AS_OBJECTS */
|
771
|
525 void (*internal_function) (Lisp_Object);
|
|
526 Lisp_Object object;
|
428
|
527 };
|
934
|
528 typedef struct Lisp_Magic_Eval_Data Lisp_Magic_Eval_Data;
|
|
529
|
1204
|
530 #ifdef EVENT_DATA_AS_OBJECTS
|
934
|
531 DECLARE_LRECORD (magic_eval_data, Lisp_Magic_Eval_Data);
|
|
532 #define XMAGIC_EVAL_DATA(x) XRECORD (x, magic_eval_data, Lisp_Magic_Eval_Data)
|
|
533 #define wrap_magic_eval_data(p) wrap_record(p, magic_eval_data)
|
|
534 #define MAGIC_EVAL_DATAP(x) RECORDP (x, magic_eval_data)
|
|
535 #define CHECK_MAGIC_EVAL_DATA(x) CHECK_RECORD (x, magic_eval_data)
|
|
536 #define CONCHECK_MAGIC_EVAL_DATA(x) CONCHECK_RECORD (x, magic_eval_data)
|
1204
|
537 #endif /* EVENT_DATA_AS_OBJECTS */
|
934
|
538
|
1204
|
539 #define EVENT_MAGIC_EVAL_INTERNAL_FUNCTION(e) EVENT_FOO_BAR (e, MAGIC_EVAL, magic_eval, internal_function)
|
|
540 #define XEVENT_MAGIC_EVAL_INTERNAL_FUNCTION(e) EVENT_MAGIC_EVAL_INTERNAL_FUNCTION (XEVENT (e))
|
|
541 #define SET_EVENT_MAGIC_EVAL_INTERNAL_FUNCTION(e, val) \
|
|
542 SET_EVENT_FOO_BAR (e, MAGIC_EVAL, magic_eval, internal_function, val)
|
|
543 #define XSET_EVENT_MAGIC_EVAL_INTERNAL_FUNCTION(e, val) \
|
|
544 SET_EVENT_MAGIC_EVAL_INTERNAL_FUNCTION (XEVENT (e), val)
|
|
545
|
|
546 #define EVENT_MAGIC_EVAL_OBJECT(e) EVENT_FOO_BAR (e, MAGIC_EVAL, magic_eval, object)
|
|
547 #define XEVENT_MAGIC_EVAL_OBJECT(e) EVENT_MAGIC_EVAL_OBJECT (XEVENT (e))
|
|
548 #define SET_EVENT_MAGIC_EVAL_OBJECT(e, val) \
|
|
549 SET_EVENT_FOO_BAR (e, MAGIC_EVAL, magic_eval, object, val)
|
|
550 #define XSET_EVENT_MAGIC_EVAL_OBJECT(e, val) \
|
|
551 SET_EVENT_MAGIC_EVAL_OBJECT (XEVENT (e), val)
|
428
|
552
|
|
553 #if defined (HAVE_X_WINDOWS) && defined(emacs)
|
|
554 # include <X11/Xlib.h>
|
|
555 #endif
|
|
556
|
462
|
557 #ifdef HAVE_GTK
|
|
558 #include <gdk/gdk.h>
|
|
559 #endif
|
|
560
|
934
|
561
|
|
562 struct Lisp_Magic_Data
|
|
563 {
|
1204
|
564 /* No user-serviceable parts within. This is for things like
|
|
565 KeymapNotify and ExposeRegion events and so on that XEmacs itself
|
|
566 doesn't care about, but which it must do something with for proper
|
|
567 interaction with the window system.
|
|
568
|
|
569 Magic_events are handled somewhat asynchronously, just like
|
|
570 subprocess filters. However, occasionally a magic_event needs to
|
|
571 be handled synchronously; in that case, the asynchronous handling
|
|
572 of the magic_event will push an eval_event back onto the queue,
|
|
573 which will be handled synchronously later. This is one of the
|
|
574 reasons why eval_events exist; I'm not entirely happy with this
|
|
575 aspect of this event model.
|
|
576 */
|
|
577
|
|
578 #ifdef EVENT_DATA_AS_OBJECTS
|
934
|
579 struct lrecord_header lheader;
|
1204
|
580 #endif /* EVENT_DATA_AS_OBJECTS */
|
934
|
581
|
|
582 union {
|
|
583 #ifdef HAVE_GTK
|
|
584 GdkEvent gdk_event;
|
|
585 #endif
|
|
586 #ifdef HAVE_X_WINDOWS
|
|
587 XEvent x_event;
|
|
588 #endif
|
|
589 #ifdef HAVE_MS_WINDOWS
|
|
590 int mswindows_event;
|
|
591 #endif
|
|
592 } underlying;
|
|
593 };
|
|
594
|
|
595 typedef struct Lisp_Magic_Data Lisp_Magic_Data;
|
|
596
|
1204
|
597 #ifdef EVENT_DATA_AS_OBJECTS
|
934
|
598 DECLARE_LRECORD (magic_data, Lisp_Magic_Data);
|
|
599 #define XMAGIC_DATA(x) XRECORD (x, magic_data, Lisp_Magic_Data)
|
|
600 #define wrap_magic_data(p) wrap_record(p, magic_data)
|
|
601 #define MAGIC_DATAP(x) RECORDP (x, magic_data)
|
|
602 #define CHECK_MAGIC_DATA(x) CHECK_RECORD (x, magic_data)
|
|
603 #define CONCHECK_MAGIC_DATA(x) CONCHECK_RECORD (x, magic_data)
|
1204
|
604 #endif /* EVENT_DATA_AS_OBJECTS */
|
934
|
605
|
1204
|
606 #define EVENT_MAGIC_UNDERLYING(e) EVENT_FOO_BAR (e, MAGIC, magic, underlying)
|
|
607 #define XEVENT_MAGIC_UNDERLYING(e) EVENT_MAGIC_UNDERLYING (XEVENT (e))
|
|
608 #define SET_EVENT_MAGIC_UNDERLYING(e, val) \
|
|
609 SET_EVENT_FOO_BAR (e, MAGIC, magic, underlying, val)
|
|
610 #define XSET_EVENT_MAGIC_UNDERLYING(e, val) \
|
|
611 SET_EVENT_MAGIC_UNDERLYING (XEVENT (e), val)
|
934
|
612
|
|
613 #ifdef HAVE_GTK
|
1204
|
614 #define EVENT_MAGIC_GDK_EVENT(e) EVENT_FOO_BAR (e, MAGIC, magic, underlying.gdk_event)
|
|
615 #define XEVENT_MAGIC_GDK_EVENT(e) EVENT_MAGIC_GDK_EVENT (XEVENT (e))
|
|
616 #define SET_EVENT_MAGIC_GDK_EVENT(e, val) \
|
|
617 SET_EVENT_FOO_BAR (e, MAGIC, magic, underlying.gdk_event, val)
|
|
618 #define XSET_EVENT_MAGIC_GDK_EVENT(e, val) \
|
|
619 SET_EVENT_MAGIC_GDK_EVENT (XEVENT (e), val)
|
|
620 #endif
|
934
|
621
|
|
622 #ifdef HAVE_X_WINDOWS
|
1204
|
623 #define EVENT_MAGIC_X_EVENT(e) EVENT_FOO_BAR (e, MAGIC, magic, underlying.x_event)
|
|
624 #define XEVENT_MAGIC_X_EVENT(e) EVENT_MAGIC_X_EVENT (XEVENT (e))
|
|
625 #define SET_EVENT_MAGIC_X_EVENT(e, val) \
|
|
626 SET_EVENT_FOO_BAR (e, MAGIC, magic, underlying.x_event, val)
|
|
627 #define XSET_EVENT_MAGIC_X_EVENT(e, val) \
|
|
628 SET_EVENT_MAGIC_X_EVENT (XEVENT (e), val)
|
934
|
629 #endif
|
|
630
|
|
631 #ifdef HAVE_MS_WINDOWS
|
1204
|
632 #define EVENT_MAGIC_MSWINDOWS_EVENT(e) EVENT_FOO_BAR (e, MAGIC, magic, underlying.mswindows_event)
|
|
633 #define XEVENT_MAGIC_MSWINDOWS_EVENT(e) EVENT_MAGIC_MSWINDOWS_EVENT (XEVENT (e))
|
|
634 #define SET_EVENT_MAGIC_MSWINDOWS_EVENT(e, val) \
|
|
635 SET_EVENT_FOO_BAR (e, MAGIC, magic, underlying.mswindows_event, val)
|
|
636 #define XSET_EVENT_MAGIC_MSWINDOWS_EVENT(e, val) \
|
|
637 SET_EVENT_MAGIC_MSWINDOWS_EVENT (XEVENT (e), val)
|
934
|
638 #endif
|
|
639
|
428
|
640 struct Lisp_Timeout
|
|
641 {
|
2720
|
642 #ifdef MC_ALLOC
|
|
643 struct lrecord_header header;
|
|
644 #else /* MC_ALLOC */
|
432
|
645 struct lcrecord_header header;
|
2720
|
646 #endif /* MC_ALLOC */
|
428
|
647 int id; /* Id we use to identify the timeout over its lifetime */
|
|
648 int interval_id; /* Id for this particular interval; this may
|
771
|
649 be different each time the timeout is
|
|
650 signalled.*/
|
428
|
651 Lisp_Object function, object; /* Function and object associated
|
771
|
652 with timeout. */
|
428
|
653 EMACS_TIME next_signal_time; /* Absolute time when the timeout
|
771
|
654 is next going to be signalled. */
|
428
|
655 unsigned int resignal_msecs; /* How far after the next timeout
|
771
|
656 should the one after that
|
|
657 occur? */
|
428
|
658 };
|
440
|
659 typedef struct Lisp_Timeout Lisp_Timeout;
|
428
|
660
|
440
|
661 DECLARE_LRECORD (timeout, Lisp_Timeout);
|
|
662 #define XTIMEOUT(x) XRECORD (x, timeout, Lisp_Timeout)
|
617
|
663 #define wrap_timeout(p) wrap_record (p, timeout)
|
428
|
664 #define TIMEOUTP(x) RECORDP (x, timeout)
|
|
665 #define CHECK_TIMEOUT(x) CHECK_RECORD (x, timeout)
|
|
666 #define CONCHECK_TIMEOUT(x) CONCHECK_RECORD (x, timeout)
|
|
667
|
|
668 struct Lisp_Event
|
|
669 {
|
|
670 /* header->next (aka XEVENT_NEXT ()) is used as follows:
|
|
671 - For dead events, this is the next dead one.
|
|
672 - For events on the command_event_queue, the next one on the queue.
|
|
673 - Likewise for events chained in the command builder.
|
|
674 - Otherwise it's Qnil.
|
|
675 */
|
|
676 struct lrecord_header lheader;
|
771
|
677 Lisp_Object next;
|
|
678 emacs_event_type event_type;
|
|
679
|
|
680 /* Where this event occurred on. This will be a frame, device,
|
|
681 console, or nil, depending on the event type. It is important
|
|
682 that an object of a more specific type than is actually generated
|
|
683 is not substituted -- e.g. there should not be a frame inserted
|
|
684 when a key-press event occurs, because events on dead channels
|
|
685 are automatically ignored.
|
|
686
|
|
687 Specifically:
|
|
688
|
|
689 -- for button and mouse-motion events, channel will be a
|
|
690 frame. (The translation to a window occurs later.)
|
|
691
|
|
692 -- for keyboard events, channel will be a console. Note that
|
|
693 fake keyboard events (generated by `character-to-event' or
|
|
694 something that calls this, such as macros) need to have the
|
|
695 selected console stored into them when the event is created.
|
|
696 This is so that the correct console-local variables (e.g. the
|
|
697 command builder) will get affected.
|
|
698
|
|
699 -- for timer, process, magic-eval, and eval events, channel will
|
|
700 be nil.
|
|
701
|
|
702 -- for misc-user events, channel will be a frame.
|
|
703
|
|
704 -- for magic events, channel will be a frame (usually) or a
|
|
705 device. */
|
|
706 Lisp_Object channel;
|
|
707
|
|
708 /* When this event occurred -- if not known, this is made up. ####
|
|
709 All timestamps should be measured as milliseconds since XEmacs
|
|
710 started. Currently they are raw server timestamps. (The X
|
|
711 protocol doesn't provide any easy way of translating between
|
|
712 server time and real process time; yuck.) */
|
934
|
713 unsigned int timestamp;
|
771
|
714
|
1204
|
715 #ifdef EVENT_DATA_AS_OBJECTS
|
934
|
716 Lisp_Object event_data;
|
1204
|
717 #else /* not EVENT_DATA_AS_OBJECTS */
|
428
|
718 union
|
|
719 {
|
1204
|
720 Lisp_Key_Data key;
|
|
721 Lisp_Button_Data button;
|
|
722 Lisp_Motion_Data motion;
|
|
723 Lisp_Process_Data process;
|
|
724 Lisp_Timeout_Data timeout;
|
|
725 Lisp_Eval_Data eval; /* misc_user_event no longer uses this */
|
|
726 Lisp_Misc_User_Data misc_user;/* because it needs position information */
|
|
727 Lisp_Magic_Data magic;
|
|
728 Lisp_Magic_Eval_Data magic_eval;
|
428
|
729 } event;
|
1204
|
730 #endif /* not EVENT_DATA_AS_OBJECTS */
|
428
|
731 };
|
|
732
|
440
|
733 DECLARE_LRECORD (event, Lisp_Event);
|
|
734 #define XEVENT(x) XRECORD (x, event, Lisp_Event)
|
617
|
735 #define wrap_event(p) wrap_record (p, event)
|
428
|
736 #define EVENTP(x) RECORDP (x, event)
|
|
737 #define CHECK_EVENT(x) CHECK_RECORD (x, event)
|
|
738 #define CONCHECK_EVENT(x) CONCHECK_RECORD (x, event)
|
|
739
|
|
740 DECLARE_LRECORD (command_builder, struct command_builder);
|
|
741
|
|
742 #define EVENT_CHANNEL(a) ((a)->channel)
|
1204
|
743 #define XEVENT_CHANNEL(ev) (XEVENT (ev)->channel)
|
428
|
744 #define EVENT_TYPE(a) ((a)->event_type)
|
|
745 #define XEVENT_TYPE(a) (XEVENT (a)->event_type)
|
|
746 #define EVENT_NEXT(a) ((a)->next)
|
|
747 #define XEVENT_NEXT(e) (XEVENT (e)->next)
|
1204
|
748 #define EVENT_TIMESTAMP(ev) ((ev)->timestamp)
|
|
749 #define XEVENT_TIMESTAMP(ev) EVENT_TIMESTAMP (XEVENT (ev))
|
934
|
750
|
1204
|
751 #ifdef EVENT_DATA_AS_OBJECTS
|
934
|
752 #define XEVENT_DATA(ev) (XEVENT (ev)->event_data)
|
|
753 #define EVENT_DATA(ev) ((ev)->event_data)
|
1204
|
754 #define SET_EVENT_DATA(ev, d) \
|
|
755 do { \
|
|
756 Lisp_Event *mac_event = (ev); \
|
|
757 mac_event->event_data = (d); \
|
|
758 } while (0)
|
|
759 #define XSET_EVENT_DATA(ev, d) SET_EVENT_DATA (XEVENT (ev), d)
|
|
760 #endif /* EVENT_DATA_AS_OBJECTS */
|
934
|
761
|
1204
|
762 #define SET_EVENT_TIMESTAMP_ZERO(ev) ((ev)->timestamp = 0)
|
|
763 #define SET_EVENT_TIMESTAMP(ev, t) ((ev)->timestamp = (t))
|
934
|
764 #define XSET_EVENT_TIMESTAMP(ev, t) SET_EVENT_TIMESTAMP (XEVENT (ev), t)
|
|
765
|
|
766 #define SET_EVENT_CHANNEL(ev, c) \
|
|
767 do { \
|
|
768 Lisp_Event *mac_event = (ev); \
|
|
769 mac_event->channel = (c); \
|
|
770 } while (0)
|
|
771 #define XSET_EVENT_CHANNEL(ev, c) SET_EVENT_CHANNEL (XEVENT (ev), c)
|
|
772
|
1204
|
773 DECLARE_INLINE_HEADER (
|
|
774 void
|
|
775 set_event_type (struct Lisp_Event *event, emacs_event_type t)
|
|
776 )
|
|
777 {
|
|
778 #ifdef EVENT_DATA_AS_OBJECTS
|
|
779 switch (EVENT_TYPE (event))
|
|
780 {
|
|
781 case key_press_event:
|
|
782 free_key_data (event->event_data);
|
|
783 break;
|
|
784 case button_press_event:
|
|
785 case button_release_event:
|
|
786 free_button_data (event->event_data);
|
|
787 break;
|
|
788 case pointer_motion_event:
|
|
789 free_motion_data (event->event_data);
|
|
790 break;
|
|
791 case process_event:
|
|
792 free_process_data (event->event_data);
|
|
793 break;
|
|
794 case timeout_event:
|
|
795 free_timeout_data (event->event_data);
|
|
796 break;
|
|
797 case magic_event:
|
|
798 free_magic_data (event->event_data);
|
|
799 break;
|
|
800 case magic_eval_event:
|
|
801 free_magic_eval_data (event->event_data);
|
|
802 break;
|
|
803 case eval_event:
|
|
804 free_eval_data (event->event_data);
|
|
805 break;
|
|
806 case misc_user_event:
|
|
807 free_misc_user_data (event->event_data);
|
|
808 break;
|
|
809 default:
|
|
810 break;
|
|
811 }
|
|
812 #endif /* EVENT_DATA_AS_OBJECTS */
|
934
|
813
|
|
814 event->event_type = t;
|
|
815
|
1204
|
816 #ifdef EVENT_DATA_AS_OBJECTS
|
|
817 switch (t)
|
|
818 {
|
|
819 case key_press_event:
|
|
820 event->event_data = make_key_data ();
|
|
821 break;
|
|
822 case button_press_event:
|
|
823 case button_release_event:
|
|
824 event->event_data = make_button_data ();
|
|
825 break;
|
|
826 case pointer_motion_event:
|
|
827 event->event_data = make_motion_data ();
|
|
828 break;
|
|
829 case process_event:
|
|
830 event->event_data = make_process_data ();
|
|
831 break;
|
|
832 case timeout_event:
|
|
833 event->event_data = make_timeout_data ();
|
|
834 break;
|
|
835 case magic_event:
|
|
836 event->event_data = make_magic_data ();
|
|
837 break;
|
|
838 case magic_eval_event:
|
|
839 event->event_data = make_magic_eval_data ();
|
|
840 break;
|
|
841 case eval_event:
|
|
842 event->event_data = make_eval_data ();
|
|
843 break;
|
|
844 case misc_user_event:
|
|
845 event->event_data = make_misc_user_data ();
|
|
846 break;
|
|
847 default:
|
|
848 event->event_data = Qnil;
|
|
849 break;
|
|
850 }
|
|
851 #endif /* EVENT_DATA_AS_OBJECTS */
|
934
|
852 }
|
1204
|
853
|
|
854 #define SET_EVENT_NEXT(ev, n) do { (ev)->next = (n); } while (0)
|
|
855 #define XSET_EVENT_NEXT(ev, n) SET_EVENT_NEXT (XEVENT (ev), n)
|
|
856
|
934
|
857 #define XSET_EVENT_TYPE(ev, t) set_event_type (XEVENT (ev), t)
|
|
858 #define SET_EVENT_TYPE(ev, t) set_event_type (ev, t)
|
|
859
|
428
|
860 #define EVENT_CHAIN_LOOP(event, chain) \
|
|
861 for (event = chain; !NILP (event); event = XEVENT_NEXT (event))
|
|
862
|
|
863 #define EVENT_LIVE_P(a) (EVENT_TYPE (a) != dead_event)
|
|
864
|
771
|
865 #define CHECK_LIVE_EVENT(x) do { \
|
|
866 CHECK_EVENT (x); \
|
|
867 if (! EVENT_LIVE_P (XEVENT (x))) \
|
|
868 dead_wrong_type_argument (Qevent_live_p, (x)); \
|
428
|
869 } while (0)
|
771
|
870 #define CONCHECK_LIVE_EVENT(x) do { \
|
|
871 CONCHECK_EVENT (x); \
|
|
872 if (! EVENT_LIVE_P (XEVENT (x))) \
|
|
873 x = wrong_type_argument (Qevent_live_p, (x)); \
|
428
|
874 } while (0)
|
|
875
|
|
876
|
|
877 EXFUN (Fcharacter_to_event, 4);
|
|
878 EXFUN (Fdeallocate_event, 1);
|
|
879 EXFUN (Fevent_glyph_extent, 1);
|
|
880 EXFUN (Fevent_modeline_position, 1);
|
|
881 EXFUN (Fevent_over_modeline_p, 1);
|
|
882 EXFUN (Fevent_over_toolbar_p, 1);
|
|
883 EXFUN (Fevent_over_vertical_divider_p, 1);
|
|
884 EXFUN (Fevent_point, 1);
|
|
885 EXFUN (Fevent_window, 1);
|
|
886 EXFUN (Fmake_event, 2);
|
1268
|
887 EXFUN (Fnext_command_event, 2);
|
428
|
888
|
|
889 extern Lisp_Object QKbackspace, QKdelete, QKescape, QKlinefeed, QKreturn;
|
|
890 extern Lisp_Object QKspace, QKtab, Qmouse_event_p, Vcharacter_set_property;
|
|
891 extern Lisp_Object Qcancel_mode_internal;
|
444
|
892 extern Lisp_Object Vmodifier_keys_sticky_time;
|
428
|
893
|
502
|
894 /* The modifiers XEmacs knows about; these appear in key and button events. */
|
|
895
|
771
|
896 #define XEMACS_MOD_CONTROL (1<<0)
|
|
897 #define XEMACS_MOD_META (1<<1)
|
|
898 #define XEMACS_MOD_SUPER (1<<2)
|
|
899 #define XEMACS_MOD_HYPER (1<<3)
|
|
900 #define XEMACS_MOD_ALT (1<<4)
|
|
901 #define XEMACS_MOD_SHIFT (1<<5) /* not used for dual-case characters */
|
|
902 #define XEMACS_MOD_BUTTON1 (1<<6)
|
|
903 #define XEMACS_MOD_BUTTON2 (1<<7)
|
|
904 #define XEMACS_MOD_BUTTON3 (1<<8)
|
|
905 #define XEMACS_MOD_BUTTON4 (1<<9)
|
|
906 #define XEMACS_MOD_BUTTON5 (1<<10)
|
502
|
907
|
|
908 /* Note: under X Windows, XEMACS_MOD_ALT is generated by the Alt key
|
|
909 if there are both Alt and Meta keys. If there are no Meta keys,
|
|
910 then Alt generates XEMACS_MOD_META instead.
|
428
|
911 */
|
|
912
|
|
913 /* Maybe this should be trickier */
|
|
914 #define KEYSYM(x) (intern (x))
|
|
915
|
|
916 /* from events.c */
|
934
|
917 void format_event_object (Eistring *buf, Lisp_Object event, int brief);
|
1229
|
918 /*void format_event_data_object (Eistring *buf, Lisp_Object data, int brief);*/
|
867
|
919 void character_to_event (Ichar c, Lisp_Event *event,
|
771
|
920 struct console *con,
|
|
921 int use_console_meta_flag,
|
|
922 int do_backspace_mapping);
|
440
|
923 void zero_event (Lisp_Event *e);
|
1204
|
924
|
|
925 #define MECR_DEALLOCATE_EVENT 1
|
|
926
|
428
|
927 void deallocate_event_chain (Lisp_Object event);
|
|
928 Lisp_Object event_chain_tail (Lisp_Object event);
|
|
929 void enqueue_event (Lisp_Object event, Lisp_Object *head, Lisp_Object *tail);
|
|
930 Lisp_Object dequeue_event (Lisp_Object *head, Lisp_Object *tail);
|
|
931 void enqueue_event_chain (Lisp_Object event_chain, Lisp_Object *head,
|
771
|
932 Lisp_Object *tail);
|
1204
|
933 int map_event_chain_remove (int (*fn) (Lisp_Object ev, void *user_data),
|
|
934 Lisp_Object *head, Lisp_Object *tail,
|
|
935 void *user_data, int flags);
|
428
|
936 int event_chain_count (Lisp_Object event_chain);
|
|
937 Lisp_Object event_chain_find_previous (Lisp_Object event_chain,
|
771
|
938 Lisp_Object event);
|
428
|
939 Lisp_Object event_chain_nth (Lisp_Object event_chain, int n);
|
|
940 Lisp_Object copy_event_chain (Lisp_Object event_chain);
|
1204
|
941 Lisp_Object transfer_event_chain_pointer (Lisp_Object pointer,
|
|
942 Lisp_Object old_chain,
|
|
943 Lisp_Object new_chain);
|
|
944
|
|
945
|
|
946 void nth_of_key_sequence_as_event (Lisp_Object seq, int n, Lisp_Object event);
|
|
947 Lisp_Object key_sequence_to_event_chain (Lisp_Object seq);
|
428
|
948 /* True if this is a non-internal event
|
|
949 (keyboard press, menu, scrollbar, mouse button) */
|
|
950 int command_event_p (Lisp_Object event);
|
440
|
951 void define_self_inserting_symbol (Lisp_Object, Lisp_Object);
|
1204
|
952 Ichar event_to_character (Lisp_Object, int, int, int);
|
428
|
953 struct console *event_console_or_selected (Lisp_Object event);
|
1204
|
954 void upshift_event (Lisp_Object event);
|
|
955 void downshift_event (Lisp_Object event);
|
|
956 int event_upshifted_p (Lisp_Object event);
|
428
|
957
|
|
958 /* from event-stream.c */
|
1204
|
959 extern Lisp_Object dispatch_event_queue;
|
771
|
960 Lisp_Object allocate_command_builder (Lisp_Object console, int with_echo_buf);
|
1204
|
961 void enqueue_dispatch_event (Lisp_Object event);
|
|
962 Lisp_Object dequeue_dispatch_event (void);
|
428
|
963 void enqueue_magic_eval_event (void (*fun) (Lisp_Object), Lisp_Object object);
|
440
|
964 void event_stream_handle_magic_event (Lisp_Event *event);
|
788
|
965 void event_stream_format_magic_event (Lisp_Event *event, Lisp_Object pstream);
|
|
966 int event_stream_compare_magic_event (Lisp_Event *e1, Lisp_Event *e2);
|
|
967 Hashcode event_stream_hash_magic_event (Lisp_Event *e);
|
428
|
968 void event_stream_select_console (struct console *con);
|
|
969 void event_stream_unselect_console (struct console *con);
|
853
|
970 void event_stream_select_process (Lisp_Process *proc, int doin, int doerr);
|
|
971 void event_stream_unselect_process (Lisp_Process *proc, int doin, int doerr);
|
|
972 void event_stream_create_io_streams (void* inhandle, void* outhandle,
|
|
973 void *errhandle, Lisp_Object* instream,
|
|
974 Lisp_Object* outstream,
|
|
975 Lisp_Object* errstream,
|
|
976 USID* in_usid,
|
|
977 USID* err_usid,
|
|
978 int flags);
|
|
979 void event_stream_delete_io_streams (Lisp_Object instream,
|
|
980 Lisp_Object outstream,
|
|
981 Lisp_Object errstream,
|
|
982 USID* in_usid,
|
|
983 USID* err_usid);
|
1268
|
984 Lisp_Object event_stream_protect_modal_loop (const char *error_string,
|
|
985 Lisp_Object (*bfun) (void *barg),
|
|
986 void *barg, int flags);
|
|
987 void event_stream_drain_queue (void);
|
428
|
988 void event_stream_quit_p (void);
|
853
|
989 void run_pre_idle_hook (void);
|
428
|
990
|
|
991 struct low_level_timeout
|
|
992 {
|
|
993 int id;
|
|
994 EMACS_TIME time;
|
|
995 struct low_level_timeout *next;
|
|
996 };
|
|
997
|
|
998 int add_low_level_timeout (struct low_level_timeout **timeout_list,
|
771
|
999 EMACS_TIME thyme);
|
428
|
1000 void remove_low_level_timeout (struct low_level_timeout **timeout_list,
|
771
|
1001 int id);
|
428
|
1002 int get_low_level_timeout_interval (struct low_level_timeout *
|
771
|
1003 timeout_list, EMACS_TIME *interval);
|
428
|
1004 int pop_low_level_timeout (struct low_level_timeout **timeout_list,
|
771
|
1005 EMACS_TIME *time_out);
|
428
|
1006 int event_stream_generate_wakeup (unsigned int milliseconds,
|
771
|
1007 unsigned int vanilliseconds,
|
|
1008 Lisp_Object function,
|
|
1009 Lisp_Object object,
|
|
1010 int async_p);
|
593
|
1011 int event_stream_resignal_wakeup (int interval_id, int async_p,
|
771
|
1012 Lisp_Object *function, Lisp_Object *object);
|
428
|
1013 void event_stream_disable_wakeup (int id, int async_p);
|
|
1014
|
593
|
1015 /* from signal.c */
|
|
1016 int signal_add_async_interval_timeout (EMACS_TIME thyme);
|
|
1017 void signal_remove_async_interval_timeout (int id);
|
428
|
1018
|
|
1019 /* from event-stream.c -- focus sanity */
|
|
1020 extern int focus_follows_mouse;
|
|
1021 void investigate_frame_change (void);
|
|
1022
|
|
1023 void emacs_handle_focus_change_preliminary (Lisp_Object frame_inp_and_dev);
|
|
1024 void emacs_handle_focus_change_final (Lisp_Object frame_inp_and_dev);
|
|
1025
|
|
1026 Lisp_Object extract_this_command_keys_nth_mouse_event (int n);
|
|
1027 Lisp_Object extract_vector_nth_mouse_event (Lisp_Object vector, int n);
|
|
1028
|
|
1029 void single_console_state (void);
|
|
1030 void any_console_state (void);
|
|
1031 int in_single_console_state (void);
|
|
1032
|
|
1033 extern int emacs_is_blocking;
|
1268
|
1034 extern int in_modal_loop;
|
428
|
1035 extern volatile int sigint_happened;
|
|
1036
|
|
1037 #ifdef HAVE_UNIXOID_EVENT_LOOP
|
|
1038 /* from event-unixoid.c */
|
|
1039
|
|
1040 /* Ceci n'est pas un pipe. */
|
|
1041 extern int signal_event_pipe[];
|
|
1042
|
|
1043 void signal_fake_event (void);
|
|
1044 void drain_signal_event_pipe (void);
|
1204
|
1045 void drain_tty_devices (void);
|
428
|
1046
|
|
1047 extern int fake_event_occurred;
|
|
1048
|
|
1049 int event_stream_unixoid_select_console (struct console *con);
|
|
1050 int event_stream_unixoid_unselect_console (struct console *con);
|
853
|
1051 void event_stream_unixoid_select_process (Lisp_Process *proc, int doin,
|
|
1052 int doerr, int *infd, int *errfd);
|
|
1053 void event_stream_unixoid_unselect_process (Lisp_Process *proc, int doin,
|
|
1054 int doerr, int *infd, int *errfd);
|
1204
|
1055 struct console *find_tty_or_stream_console_from_fd (int fd);
|
440
|
1056 int read_event_from_tty_or_stream_desc (Lisp_Event *event,
|
771
|
1057 struct console *con);
|
853
|
1058 void event_stream_unixoid_create_io_streams (void* inhandle, void* outhandle,
|
|
1059 void *errhandle,
|
|
1060 Lisp_Object* instream,
|
|
1061 Lisp_Object* outstream,
|
|
1062 Lisp_Object* errstream,
|
|
1063 USID* in_usid,
|
|
1064 USID* err_usid,
|
|
1065 int flags);
|
|
1066 void event_stream_unixoid_delete_io_streams (Lisp_Object instream,
|
|
1067 Lisp_Object outstream,
|
|
1068 Lisp_Object errstream,
|
|
1069 USID* in_usid,
|
|
1070 USID* err_usid);
|
428
|
1071
|
1204
|
1072 #endif /* HAVE_UNIXOID_EVENT_LOOP */
|
|
1073
|
|
1074 /* The following is not inside of HAVE_UNIXOID_EVENT_LOOP because of the
|
|
1075 possibility of combiling XEmacs with no-MSW, no-X, no-TTY --
|
|
1076 process-unix.c is still compiled. #### Should we still compile
|
|
1077 subprocesses with no event loops? */
|
428
|
1078 /* Beware: this evil macro evaluates its arg many times */
|
|
1079 #define FD_TO_USID(fd) ((fd)==0 ? (USID)999999 : ((fd)<0 ? USID_DONTHASH : (USID)(fd)))
|
|
1080
|
|
1081 /* Define this if you want the tty event stream to be used when the
|
|
1082 first console is tty, even if HAVE_X_WINDOWS is defined */
|
|
1083 /* #define DEBUG_TTY_EVENT_STREAM */
|
|
1084
|
|
1085
|
442
|
1086 /* #### a hack, until accelerator shit is cleaned up */
|
|
1087
|
|
1088 /* This structure is what we use to encapsulate the state of a command sequence
|
|
1089 being composed; key events are executed by adding themselves to the command
|
|
1090 builder; if the command builder is then complete (does not still represent
|
|
1091 a prefix key sequence) it executes the corresponding command.
|
|
1092 */
|
|
1093 struct command_builder
|
|
1094 {
|
2720
|
1095 #ifdef MC_ALLOC
|
|
1096 struct lrecord_header header;
|
|
1097 #else /* MC_ALLOC */
|
442
|
1098 struct lcrecord_header header;
|
2720
|
1099 #endif /* MC_ALLOC */
|
442
|
1100 Lisp_Object console; /* back pointer to the console this command
|
771
|
1101 builder is for */
|
|
1102 #if 0
|
|
1103 /* #### Not implemented: nil, or an event representing the first
|
|
1104 event read after the last command completed. Threaded. */
|
442
|
1105 Lisp_Object prefix_events;
|
771
|
1106 #endif /* 0 */
|
|
1107 /* nil, or an event chain representing the events in the current
|
|
1108 keymap-lookup sequence. NOTE: All events in the chain MUST be
|
|
1109 freshly allocated, with no pointers to them elsewhere. */
|
442
|
1110 Lisp_Object current_events;
|
771
|
1111 /* Last elt of current_events */
|
442
|
1112 Lisp_Object most_current_event;
|
771
|
1113 /* Last elt before function map code took over. What this means is:
|
442
|
1114 All prefixes up to (but not including) this event have non-nil
|
|
1115 bindings, but the prefix including this event has a nil binding.
|
|
1116 Any events in the chain after this one were read solely because
|
|
1117 we're part of a possible function key. If we end up with
|
|
1118 something that's not part of a possible function key, we have to
|
|
1119 unread all of those events. */
|
|
1120 Lisp_Object last_non_munged_event;
|
1204
|
1121 /* One value for function-key-map, one for key-translation-map:
|
|
1122 First event that can begin a possible function key sequence
|
|
1123 (to be translated according to function-key-map). Normally
|
|
1124 this is the first event in the chain. However, once we've
|
|
1125 translated a sequence through function-key-map, this will point
|
|
1126 to the first event after the translated sequence: we don't ever
|
|
1127 want to translate any events twice through function-key-map, or
|
|
1128 things could get really screwed up (e.g. if the user created a
|
|
1129 translation loop). If this is nil, then the next-read event is
|
|
1130 the first that can begin a function key sequence. */
|
|
1131 Lisp_Object first_mungeable_event[2];
|
934
|
1132 Ibyte *echo_buf;
|
442
|
1133
|
|
1134 Bytecount echo_buf_length; /* size of echo_buf */
|
|
1135 Bytecount echo_buf_index; /* index into echo_buf
|
771
|
1136 * -1 before doing echoing for new cmd */
|
442
|
1137 /* Self-insert-command is magic in that it doesn't always push an undo-
|
|
1138 boundary: up to 20 consecutive self-inserts can happen before an undo-
|
|
1139 boundary is pushed. This variable is that counter.
|
|
1140 */
|
|
1141 int self_insert_countdown;
|
|
1142 };
|
|
1143
|
440
|
1144 #endif /* INCLUDED_events_h_ */
|