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
|
934
|
30 #ifdef USE_KKCC
|
|
31 #include "opaque.h"
|
|
32 #endif /* USE_KKCC */
|
|
33
|
428
|
34 /* There is one object called an event_stream. This object contains
|
|
35 callback functions for doing the window-system-dependent operations
|
|
36 that XEmacs requires.
|
|
37
|
|
38 If XEmacs is compiled with support for X11 and the X Toolkit, then this
|
|
39 event_stream structure will contain functions that can cope with input
|
|
40 on XEmacs windows on multiple displays, as well as input from dumb tty
|
|
41 frames.
|
|
42
|
|
43 If it is desired to have XEmacs able to open frames on the displays of
|
|
44 multiple heterogeneous machines, X11 and SunView, or X11 and NeXT, for
|
|
45 example, then it will be necessary to construct an event_stream structure
|
|
46 that can cope with the given types. Currently, the only implemented
|
440
|
47 event_streams are for dumb-ttys, and for X11 plus dumb-ttys,
|
|
48 and for mswindows.
|
428
|
49
|
|
50 To implement this for one window system is relatively simple.
|
|
51 To implement this for multiple window systems is trickier and may
|
|
52 not be possible in all situations, but it's been done for X and TTY.
|
|
53
|
|
54 Note that these callbacks are *NOT* console methods; that's because
|
|
55 the routines are not specific to a particular console type but must
|
|
56 be able to simultaneously cope with all allowable console types.
|
|
57
|
|
58 The slots of the event_stream structure:
|
|
59
|
|
60 next_event_cb A function which fills in an XEmacs_event structure
|
|
61 with the next event available. If there is no event
|
|
62 available, then this should block.
|
|
63
|
|
64 IMPORTANT: timer events and especially process
|
|
65 events *must not* be returned if there are
|
|
66 events of other types available; otherwise you
|
|
67 can end up with an infinite loop in Fdiscard_input().
|
|
68
|
|
69 event_pending_cb A function which says whether there are events to be
|
|
70 read. If called with an argument of 0, then this
|
|
71 should say whether calling the next_event_cb will
|
|
72 block. If called with an argument of 1, then this
|
|
73 should say whether there are user-generated events
|
|
74 pending (that is, keypresses or mouse-clicks). This
|
|
75 is used for redisplay optimization, among other
|
|
76 things. On dumb ttys, these two results are the
|
|
77 same, but under a window system, they are not.
|
|
78
|
|
79 If this function is not sure whether there are events
|
|
80 to be read, it *must* return 0. Otherwise various
|
|
81 undesirable effects will occur, such as redisplay
|
|
82 not occurring until the next event occurs.
|
|
83
|
|
84 handle_magic_event_cb XEmacs calls this with an event structure which
|
|
85 contains window-system dependent information that
|
|
86 XEmacs doesn't need to know about, but which must
|
|
87 happen in order. If the next_event_cb never returns
|
|
88 an event of type "magic", this will never be used.
|
|
89
|
788
|
90 format_magic_event_cb Called with a magic event; print a representation of
|
|
91 the innards of the event to PSTREAM.
|
|
92
|
|
93 compare_magic_event_cb Called with two magic events; return non-zero if
|
|
94 the innards of the two are equal, zero otherwise.
|
|
95
|
|
96 hash_magic_event_cb Called with a magic event; return a hash of the
|
|
97 innards of the event.
|
|
98
|
428
|
99 add_timeout_cb Called with an EMACS_TIME, the absolute time at
|
|
100 which a wakeup event should be generated; and a
|
|
101 void *, which is an arbitrary value that will be
|
|
102 returned in the timeout event. The timeouts
|
|
103 generated by this function should be one-shots:
|
|
104 they fire once and then disappear. This callback
|
|
105 should return an int id-number which uniquely
|
|
106 identifies this wakeup. If an implementation
|
|
107 doesn't have microseconds or millisecond
|
|
108 granularity, it should round up to the closest
|
|
109 value it can deal with.
|
|
110
|
|
111 remove_timeout_cb Called with an int, the id number of a wakeup to
|
|
112 discard. This id number must have been returned by
|
|
113 the add_timeout_cb. If the given wakeup has
|
|
114 already expired, this should do nothing.
|
|
115
|
|
116 select_process_cb These callbacks tell the underlying implementation to
|
|
117 unselect_process_cb add or remove a file descriptor from the list of fds
|
|
118 which are polled for inferior-process input. When
|
|
119 input becomes available on the given process
|
|
120 connection, an event of type "process" should be
|
|
121 generated.
|
|
122
|
|
123 select_console_cb These callbacks tell the underlying implementation
|
|
124 unselect_console_cb to add or remove a console from the list of consoles
|
|
125 which are polled for user-input.
|
|
126
|
|
127 select_device_cb These callbacks are used by Unixoid event loops
|
|
128 unselect_device_cb (those that use select() and file descriptors and
|
|
129 have a separate input fd per device).
|
|
130
|
853
|
131 create_io_streams_cb These callbacks are called by process code to
|
|
132 delete_io_streams_cb create the input and output lstreams which are used
|
|
133 for subprocess I/O.
|
428
|
134
|
|
135 quitp_cb A handler function called from the `QUIT' macro which
|
|
136 should check whether the quit character has been
|
|
137 typed. On systems with SIGIO, this will not be called
|
|
138 unless the `sigio_happened' flag is true (it is set
|
|
139 from the SIGIO handler).
|
|
140
|
|
141 XEmacs has its own event structures, which are distinct from the event
|
|
142 structures used by X or any other window system. It is the job of the
|
|
143 event_stream layer to translate to this format.
|
|
144 */
|
|
145
|
|
146 /*
|
|
147 Stream pairs description
|
|
148 ------------------------
|
|
149
|
|
150 Since there are many possible processes/event loop combinations, the event code
|
|
151 is responsible for creating an appropriate lstream type. The process
|
|
152 implementation does not care about that implementation.
|
|
153
|
|
154 The Create stream pair function is passed two void* values, which identify
|
|
155 process-dependent 'handles'. The process implementation uses these handles
|
|
156 to communicate with child processes. The function must be prepared to receive
|
440
|
157 handle types of any process implementation. Since only one process
|
428
|
158 implementation exists in a particular XEmacs configuration, preprocessing
|
440
|
159 is a means of compiling in the support for the code which deals with particular
|
428
|
160 handle types.
|
|
161
|
|
162 For example, a unixoid type loop, which relies on file descriptors, may be
|
|
163 asked to create a pair of streams by a unix-style process implementation.
|
|
164 In this case, the handles passed are unix file descriptors, and the code
|
|
165 may deal with these directly. Although, the same code may be used on Win32
|
|
166 system with X-Windows. In this case, Win32 process implementation passes
|
853
|
167 handles of type HANDLE, and the create_io_streams function must call
|
428
|
168 appropriate function to get file descriptors given HANDLEs, so that these
|
|
169 descriptors may be passed to XtAddInput.
|
|
170
|
|
171 The handle given may have special denying value, in which case the
|
|
172 corresponding lstream should not be created.
|
|
173
|
|
174 The return value of the function is a unique stream identifier. It is used
|
|
175 by processes implementation, in its platform-independent part. There is
|
|
176 the get_process_from_usid function, which returns process object given its
|
|
177 USID. The event stream is responsible for converting its internal handle
|
|
178 type into USID.
|
|
179
|
|
180 Example is the TTY event stream. When a file descriptor signals input, the
|
|
181 event loop must determine process to which the input is destined. Thus,
|
|
182 the implementation uses process input stream file descriptor as USID, by
|
|
183 simply casting the fd value to USID type.
|
|
184
|
|
185 There are two special USID values. One, USID_ERROR, indicates that the stream
|
|
186 pair cannot be created. The second, USID_DONTHASH, indicates that streams are
|
|
187 created, but the event stream does not wish to be able to find the process
|
|
188 by its USID. Specifically, if an event stream implementation never calls
|
|
189 get_process_from_usid, this value should always be returned, to prevent
|
|
190 accumulating useless information on USID to process relationship.
|
|
191 */
|
|
192
|
|
193 /* typedef unsigned int USID; in lisp.h */
|
|
194 #define USID_ERROR ((USID)-1)
|
|
195 #define USID_DONTHASH ((USID)0)
|
|
196
|
|
197
|
|
198 struct event_stream
|
|
199 {
|
|
200 int (*event_pending_p) (int);
|
440
|
201 void (*next_event_cb) (Lisp_Event *);
|
|
202 void (*handle_magic_event_cb) (Lisp_Event *);
|
788
|
203 void (*format_magic_event_cb) (Lisp_Event *, Lisp_Object pstream);
|
|
204 int (*compare_magic_event_cb) (Lisp_Event *, Lisp_Event *);
|
|
205 Hashcode (*hash_magic_event_cb)(Lisp_Event *);
|
428
|
206 int (*add_timeout_cb) (EMACS_TIME);
|
|
207 void (*remove_timeout_cb) (int);
|
|
208 void (*select_console_cb) (struct console *);
|
|
209 void (*unselect_console_cb) (struct console *);
|
853
|
210 void (*select_process_cb) (Lisp_Process *, int doin, int doerr);
|
|
211 void (*unselect_process_cb) (Lisp_Process *, int doin, int doerr);
|
428
|
212 void (*quit_p_cb) (void);
|
442
|
213 void (*force_event_pending) (struct frame* f);
|
853
|
214 void (*create_io_streams_cb) (void* /* inhandle*/, void* /*outhandle*/ ,
|
|
215 void * /* errhandle*/,
|
428
|
216 Lisp_Object* /* instream */,
|
|
217 Lisp_Object* /* outstream */,
|
853
|
218 Lisp_Object* /* errstream */,
|
|
219 USID * /* in_usid */, USID * /* err_usid */,
|
428
|
220 int /* flags */);
|
853
|
221 void (*delete_io_streams_cb) (Lisp_Object /* instream */,
|
|
222 Lisp_Object /* outstream */,
|
|
223 Lisp_Object /* errstream */,
|
|
224 USID * /* in_usid */, USID * /* err_usid */);
|
442
|
225 int (*current_event_timestamp_cb) (struct console *);
|
428
|
226 };
|
|
227
|
853
|
228 /* Flags for create_io_streams_cb() FLAGS parameter */
|
428
|
229 #define STREAM_PTY_FLUSHING 0x0001
|
|
230 #define STREAM_NETWORK_CONNECTION 0x0002
|
|
231
|
|
232 extern struct event_stream *event_stream;
|
|
233
|
934
|
234 #ifdef USE_KKCC
|
|
235 Lisp_Object make_key_data (void);
|
|
236 Lisp_Object make_button_data (void);
|
|
237 Lisp_Object make_motion_data (void);
|
|
238 Lisp_Object make_process_data (void);
|
|
239 Lisp_Object make_timeout_data (void);
|
|
240 Lisp_Object make_magic_data (void);
|
|
241 Lisp_Object make_magic_eval_data (void);
|
|
242 Lisp_Object make_eval_data (void);
|
|
243 Lisp_Object make_misc_user_data (void);
|
|
244 #endif USE_KKCC
|
|
245
|
428
|
246 typedef enum emacs_event_type
|
|
247 {
|
|
248 empty_event,
|
|
249 key_press_event,
|
|
250 button_press_event,
|
|
251 button_release_event,
|
|
252 pointer_motion_event,
|
|
253 process_event,
|
|
254 timeout_event,
|
|
255 magic_event,
|
|
256 magic_eval_event,
|
|
257 eval_event,
|
|
258 misc_user_event,
|
|
259 dead_event
|
|
260 } emacs_event_type;
|
|
261
|
|
262 #define first_event_type empty_event
|
|
263 #define last_event_type dead_event
|
|
264
|
771
|
265 #ifdef MULE
|
|
266
|
|
267 enum alternative_key_chars
|
|
268 {
|
|
269 KEYCHAR_CURRENT_LANGENV,
|
|
270 KEYCHAR_DEFAULT_USER,
|
|
271 KEYCHAR_DEFAULT_SYSTEM,
|
|
272 KEYCHAR_UNDERLYING_VIRTUAL_KEY_CURRENT_LANGENV,
|
|
273 KEYCHAR_UNDERLYING_VIRTUAL_KEY_DEFAULT_USER,
|
|
274 KEYCHAR_UNDERLYING_VIRTUAL_KEY_DEFAULT_SYSTEM,
|
|
275 KEYCHAR_QWERTY,
|
|
276 KEYCHAR_LAST
|
|
277 };
|
|
278
|
|
279 #endif /* MULE */
|
428
|
280
|
934
|
281 #ifdef USE_KKCC
|
|
282 struct Lisp_Key_Data
|
|
283 #else /* not USE_KKCC */
|
428
|
284 struct key_data
|
934
|
285 #endif /* not USE_KKCC */
|
428
|
286 {
|
934
|
287 #ifdef USE_KKCC
|
|
288 struct lrecord_header lheader;
|
|
289 #endif /* USE_KKCC */
|
771
|
290 /* What keysym this is; a character or a symbol. */
|
|
291 Lisp_Object keysym;
|
|
292 /* Modifiers held down when key was pressed: control, meta, etc.
|
|
293 Also includes buttons. For many keys, Shift is not a bit; that
|
|
294 is implicit in the keyboard layout. */
|
|
295 int modifiers;
|
|
296 #ifdef MULE
|
|
297 /* Alternate character interpretations for this key in different
|
|
298 keyboard layouts. This deals with the problem of pressing C-x in
|
|
299 the Russian layout (the so-called "Russian C-x problem"), for
|
|
300 example: `x' gets mapped to a Cyrillic character, so what do we
|
|
301 do? For that matter, what about `C-x b'? What we do is look the
|
|
302 key up in the default locales (current language environment, user
|
|
303 default, system default), then check to see if the underlying
|
|
304 virtual key is alphabetic in the same three defaults, then
|
|
305 finally check US ASCII. We ignore the underlying virtual key for
|
|
306 the current layout to avoid the problem of a French speaker
|
|
307 (AZERTY layout) who temporarily switches to Russian: The virtual
|
|
308 keys underlying Russian are US-ASCII, so what the French speaker
|
|
309 things of as C-a (the key just to the right of TAB) appears as
|
|
310 C-q. (#### We should probably ignore the current char and look
|
|
311 *ONLY* in alt_keychars for all control keys. What about the
|
|
312 English speaker who temporarily switches to the French layout and
|
|
313 finds C-q mapped to C-a?) */
|
867
|
314 Ichar alt_keychars[KEYCHAR_LAST];
|
771
|
315 #endif /* MULE */
|
428
|
316 };
|
|
317
|
934
|
318 #ifdef USE_KKCC
|
|
319 typedef struct Lisp_Key_Data Lisp_Key_Data;
|
|
320
|
|
321 DECLARE_LRECORD (key_data, Lisp_Key_Data);
|
|
322 #define XKEY_DATA(x) XRECORD (x, key_data, Lisp_Key_Data)
|
|
323 #define wrap_key_data(p) wrap_record (p, key_data)
|
|
324 #define KEY_DATAP(x) RECORDP (x, key_data)
|
|
325 #define CHECK_KEY_DATA(x) CHECK_RECORD (x, key_data)
|
|
326 #define CONCHECK_KEY_DATA(x) CONCHECK_RECORD (x, key_data)
|
|
327
|
|
328 #define XKEY_DATA_KEYSYM(d) (XKEY_DATA (d)->keysym)
|
|
329 #define KEY_DATA_KEYSYM(d) ((d)->keysym)
|
|
330 #define XKEY_DATA_MODIFIERS(d) (XKEY_DATA (d)->modifiers)
|
|
331 #define KEY_DATA_MODIFIERS(d) ((d)->modifiers)
|
|
332
|
|
333 #define XSET_KEY_DATA_KEYSYM(d, k) (XKEY_DATA (d)->keysym = (k))
|
|
334 #define SET_KEY_DATA_KEYSYM(d, k) ((d)->keysym = k)
|
|
335 #define XSET_KEY_DATA_MODIFIERS(d, m) (XKEY_DATA (d)->modifiers = m)
|
|
336 #define SET_KEY_DATA_MODIFIERS(d, m) ((d)->modifiers = m)
|
|
337 #endif /* USE_KKCC */
|
|
338
|
|
339 #ifdef USE_KKCC
|
|
340 struct Lisp_Button_Data
|
|
341 #else /* not USE_KKCC */
|
428
|
342 struct button_data
|
934
|
343 #endif /* not USE_KKCC */
|
428
|
344 {
|
934
|
345 #ifdef USE_KKCC
|
|
346 struct lrecord_header lheader;
|
|
347 #endif /* USE_KKCC */
|
771
|
348 /* What button went down or up. */
|
|
349 int button;
|
|
350 /* Bucky-bits on that button: shift, control, meta, etc. Also
|
|
351 includes other buttons (not the one pressed). */
|
|
352 int modifiers;
|
|
353 /* Where it was at the button-state-change (in pixels). */
|
|
354 int x, y;
|
428
|
355 };
|
934
|
356 #ifdef USE_KKCC
|
|
357 typedef struct Lisp_Button_Data Lisp_Button_Data;
|
428
|
358
|
934
|
359 DECLARE_LRECORD (button_data, Lisp_Button_Data);
|
|
360 #define XBUTTON_DATA(x) XRECORD (x, button_data, Lisp_Button_Data)
|
|
361 #define wrap_button_data(p) wrap_record (p, button_data)
|
|
362 #define BUTTON_DATAP(x) RECORDP (x, button_data)
|
|
363 #define CHECK_BUTTON_DATA(x) CHECK_RECORD (x, button_data)
|
|
364 #define CONCHECK_BUTTON_DATA(x) CONCHECK_RECORD (x, button_data)
|
|
365
|
|
366 #define XBUTTON_DATA_BUTTON(d) (XBUTTON_DATA (d)->button)
|
|
367 #define XBUTTON_DATA_MODIFIERS(d) (XBUTTON_DATA (d)->modifiers)
|
|
368 #define XBUTTON_DATA_X(d) (XBUTTON_DATA (d)->x)
|
|
369 #define XBUTTON_DATA_Y(d) (XBUTTON_DATA (d)->y)
|
|
370
|
|
371 #define XSET_BUTTON_DATA_BUTTON(d, b) (XBUTTON_DATA (d)->button = (b))
|
|
372 #define XSET_BUTTON_DATA_MODIFIERS(d, m) (XBUTTON_DATA (d)->modifiers = (m))
|
|
373 #define XSET_BUTTON_DATA_X(d, new_x) (XBUTTON_DATA (d)->x = (new_x))
|
|
374 #define XSET_BUTTON_DATA_Y(d, new_y) (XBUTTON_DATA (d)->y = (new_y))
|
|
375 #endif /* USE_KKCC */
|
|
376
|
|
377 #ifdef USE_KKCC
|
|
378 struct Lisp_Motion_Data
|
|
379 #else /* not USE_KKCC */
|
428
|
380 struct motion_data
|
934
|
381 #endif /* not USE_KKCC */
|
428
|
382 {
|
934
|
383 #ifdef USE_KKCC
|
|
384 struct lrecord_header lheader;
|
|
385 #endif /* USE_KKCC */
|
771
|
386 /* Where it was after it moved (in pixels). */
|
|
387 int x, y;
|
|
388 /* Bucky-bits down when the motion was detected. */
|
|
389 int modifiers;
|
428
|
390 };
|
934
|
391 #ifdef USE_KKCC
|
|
392 typedef struct Lisp_Motion_Data Lisp_Motion_Data;
|
428
|
393
|
934
|
394 DECLARE_LRECORD (motion_data, Lisp_Motion_Data);
|
|
395 #define XMOTION_DATA(x) XRECORD (x, motion_data, Lisp_Motion_Data)
|
|
396 #define wrap_motion_data(p) wrap_record (p, motion_data)
|
|
397 #define MOTION_DATAP(x) RECORDP (x, motion_data)
|
|
398 #define CHECK_MOTION_DATA(x) CHECK_RECORD (x, motion_data)
|
|
399 #define CONCHECK_MOTION_DATA(x) CONCHECK_RECORD (x, motion_data)
|
|
400
|
|
401 #define XMOTION_DATA_X(d) (XMOTION_DATA (d)->x)
|
|
402 #define XMOTION_DATA_Y(d) (XMOTION_DATA (d)->y)
|
|
403 #define XMOTION_DATA_MODIFIERS(d) (XMOTION_DATA (d)->modifiers)
|
|
404
|
|
405 #define XSET_MOTION_DATA_X(d, new_x) (XMOTION_DATA (d)->x = (new_x))
|
|
406 #define XSET_MOTION_DATA_Y(d, new_y) (XMOTION_DATA (d)->y = (new_y))
|
|
407 #define XSET_MOTION_DATA_MODIFIERS(d, m) (XMOTION_DATA (d)->modifiers = (m))
|
|
408 #endif /* USE_KKCC */
|
|
409
|
|
410 #ifdef USE_KKCC
|
|
411 struct Lisp_Process_Data
|
|
412 #else /* not USE_KKCC */
|
428
|
413 struct process_data
|
934
|
414 #endif /* not USE_KKCC */
|
428
|
415 {
|
934
|
416 #ifdef USE_KKCC
|
|
417 struct lrecord_header lheader;
|
|
418 #endif /* USE_KKCC */
|
771
|
419 /* the XEmacs "process" object in question */
|
|
420 Lisp_Object process;
|
428
|
421 };
|
934
|
422 #ifdef USE_KKCC
|
|
423 typedef struct Lisp_Process_Data Lisp_Process_Data;
|
428
|
424
|
934
|
425 DECLARE_LRECORD (process_data, Lisp_Process_Data);
|
|
426 #define XPROCESS_DATA(x) XRECORD (x, process_data, Lisp_Process_Data)
|
|
427 #define wrap_process_data(p) wrap_record (p, process_data)
|
|
428 #define PROCESS_DATAP(x) RECORDP (x, process_data)
|
|
429 #define CHECK_PROCESS_DATA(x) CHECK_RECORD (x, process_data)
|
|
430 #define CONCHECK_PROCESS_DATA(x) CONCHECK_RECORD (x, process_data)
|
|
431
|
|
432 #define XPROCESS_DATA_PROCESS(d) (XPROCESS_DATA (d)->process)
|
|
433 #define XSET_PROCESS_DATA_PROCESS(d, p) (XPROCESS_DATA (d)->process = (p))
|
|
434 #endif /* USE_KKCC */
|
|
435
|
|
436 #ifdef USE_KKCC
|
|
437 struct Lisp_Timeout_Data
|
|
438 #else /* not USE_KKCC */
|
428
|
439 struct timeout_data
|
934
|
440 #endif /* not USE_KKCC */
|
428
|
441 {
|
771
|
442 /*
|
|
443 interval_id The ID returned when the associated call to
|
|
444 add_timeout_cb() was made
|
|
445 ------ the rest of the fields are filled in by XEmacs -----
|
|
446 id_number The XEmacs timeout ID for this timeout (more
|
|
447 than one timeout event can have the same value
|
|
448 here, since XEmacs timeouts, as opposed to
|
|
449 add_timeout_cb() timeouts, can resignal
|
|
450 themselves)
|
|
451 function An elisp function to call when this timeout is
|
|
452 processed.
|
|
453 object The object passed to that function.
|
|
454 */
|
934
|
455 #ifdef USE_KKCC
|
|
456 struct lrecord_header lheader;
|
|
457 #endif /* USE_KKCC */
|
771
|
458 int interval_id;
|
|
459 int id_number;
|
|
460 Lisp_Object function;
|
|
461 Lisp_Object object;
|
428
|
462 };
|
934
|
463 #ifdef USE_KKCC
|
|
464 typedef struct Lisp_Timeout_Data Lisp_Timeout_Data;
|
428
|
465
|
934
|
466 DECLARE_LRECORD (timeout_data, Lisp_Timeout_Data);
|
|
467 #define XTIMEOUT_DATA(x) XRECORD (x, timeout_data, Lisp_Timeout_Data)
|
|
468 #define wrap_timeout_data(p) wrap_record(p, timeout_data)
|
|
469 #define TIMEOUT_DATAP(x) RECORDP (x, timeout_data)
|
|
470 #define CHECK_TIMEOUT_DATA(x) CHECK_RECORD (x, timeout_data)
|
|
471 #define CONCHECK_TIMEOUT_DATA(x) CONCHECK_RECORD (x, timeout_data)
|
|
472
|
|
473 #define XTIMEOUT_DATA_INTERVAL_ID(d) XTIMEOUT_DATA (d)->interval_id
|
|
474 #define XTIMEOUT_DATA_ID_NUMBER(d) XTIMEOUT_DATA (d)->id_number
|
|
475 #define XTIMEOUT_DATA_FUNCTION(d) XTIMEOUT_DATA (d)->function
|
|
476 #define XTIMEOUT_DATA_OBJECT(d) XTIMEOUT_DATA (d)->object
|
|
477
|
|
478 #define XSET_TIMEOUT_DATA_INTERVAL_ID(d, i) XTIMEOUT_DATA (d)->interval_id = (i)
|
|
479 #define XSET_TIMEOUT_DATA_ID_NUMBER(d, n) XTIMEOUT_DATA (d)->id_number = (n)
|
|
480 #define XSET_TIMEOUT_DATA_FUNCTION(d, f) XTIMEOUT_DATA (d)->function = f
|
|
481 #define XSET_TIMEOUT_DATA_OBJECT(d, o) XTIMEOUT_DATA (d)->object = o
|
|
482 #endif /* USE_KKCC */
|
|
483
|
|
484 #ifdef USE_KKCC
|
|
485 struct Lisp_Eval_Data
|
|
486 #else /* not USE_KKCC */
|
428
|
487 struct eval_data
|
934
|
488 #endif /* not USE_KKCC */
|
428
|
489 {
|
771
|
490 /* This kind of event is used internally; sometimes the window system
|
|
491 interface would like to inform XEmacs of some user action (such as
|
|
492 focusing on another frame) but needs that to happen synchronously
|
|
493 with the other user input, like keypresses. This is useful when
|
|
494 events are reported through callbacks rather than in the standard
|
|
495 event stream.
|
|
496
|
|
497 function An elisp function to call with this event object.
|
|
498 object Argument of function.
|
|
499 */
|
934
|
500 #ifdef USE_KKCC
|
|
501 struct lrecord_header lheader;
|
|
502 #endif /* USE_KKCC */
|
771
|
503 Lisp_Object function;
|
|
504 Lisp_Object object;
|
428
|
505 };
|
934
|
506 #ifdef USE_KKCC
|
|
507 typedef struct Lisp_Eval_Data Lisp_Eval_Data;
|
428
|
508
|
934
|
509 DECLARE_LRECORD (eval_data, Lisp_Eval_Data);
|
|
510 #define XEVAL_DATA(x) XRECORD (x, eval_data, Lisp_Eval_Data)
|
|
511 #define wrap_eval_data(p) wrap_record(p, eval_data)
|
|
512 #define EVAL_DATAP(x) RECORDP (x, eval_data)
|
|
513 #define CHECK_EVAL_DATA(x) CHECK_RECORD (x, eval_data)
|
|
514 #define CONCHECK_EVAL_DATA(x) CONCHECK_RECORD (x, eval_data)
|
|
515
|
|
516 #define XEVAL_DATA_FUNCTION(d) (XEVAL_DATA (d)->function)
|
|
517 #define XEVAL_DATA_OBJECT(d) (XEVAL_DATA (d)->object)
|
|
518
|
|
519 #define XSET_EVAL_DATA_FUNCTION(d, f) (XEVAL_DATA (d)->function = f)
|
|
520 #define XSET_EVAL_DATA_OBJECT(d, o) (XEVAL_DATA (d)->object = o)
|
|
521 #endif /* USE_KKCC */
|
|
522
|
|
523 #ifdef USE_KKCC
|
|
524 struct Lisp_Misc_User_Data
|
|
525 #else /* not USE_KKCC */
|
428
|
526 struct misc_user_data
|
934
|
527 #endif /* not USE_KKCC */
|
428
|
528 {
|
771
|
529 /* #### The misc-user type is serious junk. It should be separated
|
|
530 out into different events. There's no reason to create
|
|
531 sub-subtypes of events.
|
|
532
|
|
533 function An elisp function to call with this event object.
|
|
534 object Argument of function.
|
|
535 button What button went down or up.
|
|
536 modifiers Bucky-bits on that button: shift, control, meta, etc.
|
|
537 x, y Where it was at the button-state-change (in pixels).
|
|
538 This is similar to an eval_event, except that it is
|
|
539 generated by user actions: selections in the
|
|
540 menubar, scrollbar actions, or drag and drop actions.
|
|
541 It is a "command" event, like key and mouse presses
|
|
542 (and unlike mouse motion, process output, and enter
|
|
543 and leave window hooks). In many ways, eval_events
|
|
544 are not the same as keypresses or misc_user_events.
|
|
545 The button, modifiers, x, and y parts are only used
|
|
546 by the XEmacs Drag'n'Drop system. Don't depend on their
|
|
547 values for other types of misc_user_events.
|
|
548 */
|
934
|
549 #ifdef USE_KKCC
|
|
550 struct lrecord_header lheader;
|
|
551 #endif /* USE_KKCC */
|
771
|
552 Lisp_Object function;
|
|
553 Lisp_Object object;
|
|
554 int button;
|
|
555 int modifiers;
|
|
556 int x, y;
|
428
|
557 };
|
934
|
558 #ifdef USE_KKCC
|
|
559 typedef struct Lisp_Misc_User_Data Lisp_Misc_User_Data;
|
428
|
560
|
934
|
561 DECLARE_LRECORD (misc_user_data, Lisp_Misc_User_Data);
|
|
562 #define XMISC_USER_DATA(x) XRECORD (x, misc_user_data, Lisp_Misc_User_Data)
|
|
563 #define wrap_misc_user_data(p) wrap_record(p, misc_user_data)
|
|
564 #define MISC_USER_DATAP(x) RECORDP (x, misc_user_data)
|
|
565 #define CHECK_MISC_USER_DATA(x) CHECK_RECORD (x, misc_user_data)
|
|
566 #define CONCHECK_MISC_USER_DATA(x) CONCHECK_RECORD (x, misc_user_data)
|
|
567
|
|
568 #define XMISC_USER_DATA_FUNCTION(d) (XMISC_USER_DATA (d)->function)
|
|
569 #define XMISC_USER_DATA_OBJECT(d) (XMISC_USER_DATA (d)->object)
|
|
570 #define XMISC_USER_DATA_BUTTON(d) (XMISC_USER_DATA (d)->button)
|
|
571 #define XMISC_USER_DATA_MODIFIERS(d) (XMISC_USER_DATA (d)->modifiers)
|
|
572 #define XMISC_USER_DATA_X(d) (XMISC_USER_DATA (d)->x)
|
|
573 #define XMISC_USER_DATA_Y(d) (XMISC_USER_DATA (d)->y)
|
|
574
|
|
575 #define XSET_MISC_USER_DATA_FUNCTION(d, f) (XMISC_USER_DATA (d)->function = (f))
|
|
576 #define XSET_MISC_USER_DATA_OBJECT(d, o) (XMISC_USER_DATA (d)->object = (o))
|
|
577 #define XSET_MISC_USER_DATA_BUTTON(d, b) (XMISC_USER_DATA (d)->button = (b))
|
|
578 #define XSET_MISC_USER_DATA_MODIFIERS(d, m) (XMISC_USER_DATA (d)->modifiers = (m))
|
|
579 #define XSET_MISC_USER_DATA_X(d, new_x) (XMISC_USER_DATA (d)->x = (new_x))
|
|
580 #define XSET_MISC_USER_DATA_Y(d, new_y) (XMISC_USER_DATA (d)->y = (new_y))
|
|
581 #endif /* USE_KKCC */
|
|
582
|
|
583 #ifdef USE_KKCC
|
|
584 typedef void (*lisp_obj_arg_fun) (Lisp_Object);
|
|
585
|
|
586
|
|
587 struct Lisp_Magic_Eval_Data
|
|
588 #else /* not USE_KKCC */
|
428
|
589 struct magic_eval_data
|
934
|
590 #endif /* not USE_KKCC */
|
428
|
591 {
|
771
|
592 /* This is like an eval event but its contents are not
|
|
593 Lisp-accessible. This allows for "internal eval events" that call
|
|
594 non-Lisp-accessible functions. Externally, a magic_eval_event just
|
|
595 appears as a magic_event; the Lisp programmer need not know
|
|
596 anything more.
|
|
597
|
|
598 internal_function An unexported function to call with this event
|
|
599 object. This allows eval events to call internal
|
|
600 functions. For a normal eval event, this field
|
|
601 will always be 0.
|
|
602 object Argument of function.
|
|
603
|
|
604 */
|
934
|
605 #ifdef USE_KKCC
|
|
606 struct lrecord_header lheader;
|
|
607 #endif /* USE_KKCC */
|
771
|
608 void (*internal_function) (Lisp_Object);
|
|
609 Lisp_Object object;
|
428
|
610 };
|
934
|
611 #ifdef USE_KKCC
|
|
612 typedef struct Lisp_Magic_Eval_Data Lisp_Magic_Eval_Data;
|
|
613
|
|
614 DECLARE_LRECORD (magic_eval_data, Lisp_Magic_Eval_Data);
|
|
615 #define XMAGIC_EVAL_DATA(x) XRECORD (x, magic_eval_data, Lisp_Magic_Eval_Data)
|
|
616 #define wrap_magic_eval_data(p) wrap_record(p, magic_eval_data)
|
|
617 #define MAGIC_EVAL_DATAP(x) RECORDP (x, magic_eval_data)
|
|
618 #define CHECK_MAGIC_EVAL_DATA(x) CHECK_RECORD (x, magic_eval_data)
|
|
619 #define CONCHECK_MAGIC_EVAL_DATA(x) CONCHECK_RECORD (x, magic_eval_data)
|
|
620
|
|
621 #define XMAGIC_EVAL_DATA_INTERNAL_FUNCTION(d) \
|
|
622 XMAGIC_EVAL_DATA (d)->internal_function
|
|
623 #define XMAGIC_EVAL_DATA_INTERNAL_FUNOBJ(d) (XMAGIC_EVAL_DATA (d)->internal_function)
|
|
624 #define XMAGIC_EVAL_DATA_OBJECT(d) (XMAGIC_EVAL_DATA (d)->object)
|
|
625
|
|
626 #define XSET_MAGIC_EVAL_DATA_INTERNAL_FUNCTION(d, f) \
|
|
627 (XMAGIC_EVAL_DATA (d)->internal_function = f)
|
|
628 #define XSET_MAGIC_EVAL_DATA_INTERNAL_FUNOBJ(d, f) (XMAGIC_EVAL_DATA (d)->internal_function = (f))
|
|
629 #define XSET_MAGIC_EVAL_DATA_OBJECT(d, o) (XMAGIC_EVAL_DATA (d)->object = (o))
|
|
630 #endif /* USE_KKCC */
|
428
|
631
|
|
632 #if defined (HAVE_X_WINDOWS) && defined(emacs)
|
|
633 # include <X11/Xlib.h>
|
|
634 #endif
|
|
635
|
462
|
636 #ifdef HAVE_GTK
|
|
637 #include <gdk/gdk.h>
|
|
638 #endif
|
|
639
|
934
|
640
|
|
641 #ifdef USE_KKCC
|
|
642 struct Lisp_Magic_Data
|
|
643 {
|
|
644 struct lrecord_header lheader;
|
|
645
|
|
646 union {
|
|
647 #ifdef HAVE_GTK
|
|
648 GdkEvent gdk_event;
|
|
649 #endif
|
|
650 #ifdef HAVE_X_WINDOWS
|
|
651 XEvent x_event;
|
|
652 #endif
|
|
653 #ifdef HAVE_MS_WINDOWS
|
|
654 int mswindows_event;
|
|
655 #endif
|
|
656 } underlying;
|
|
657 };
|
|
658
|
|
659 typedef struct Lisp_Magic_Data Lisp_Magic_Data;
|
|
660
|
|
661 DECLARE_LRECORD (magic_data, Lisp_Magic_Data);
|
|
662 #define XMAGIC_DATA(x) XRECORD (x, magic_data, Lisp_Magic_Data)
|
|
663 #define wrap_magic_data(p) wrap_record(p, magic_data)
|
|
664 #define MAGIC_DATAP(x) RECORDP (x, magic_data)
|
|
665 #define CHECK_MAGIC_DATA(x) CHECK_RECORD (x, magic_data)
|
|
666 #define CONCHECK_MAGIC_DATA(x) CONCHECK_RECORD (x, magic_data)
|
|
667
|
|
668 #define XMAGIC_DATA_UNDERLYING(d) (XMAGIC_DATA (d)->underlying)
|
|
669 #define XSET_MAGIC_DATA_UNDERLYING(d, u) (XMAGIC_DATA (d)->underlying = (u))
|
|
670
|
|
671 #ifdef HAVE_GTK
|
|
672 #define XMAGIC_DATA_GDK_EVENT(d) (XMAGIC_DATA (d)->underlying.gdk_event)
|
|
673 #define XSET_MAGIC_DATA_GDK_EVENT(d, e) (XMAGIC_DATA (d)->underlying.gdk_event = (e))
|
|
674 #endif /*HAVE_GTK*/
|
|
675
|
|
676 #ifdef HAVE_X_WINDOWS
|
|
677 #define XMAGIC_DATA_X_EVENT(d) (XMAGIC_DATA (d)->underlying.x_event)
|
|
678 #define XSET_MAGIC_DATA_X_EVENT(d, e) (XMAGIC_DATA (d)->underlying.x_event = (e))
|
|
679 #endif
|
|
680
|
|
681 #ifdef HAVE_MS_WINDOWS
|
|
682 #define XMAGIC_DATA_MSWINDOWS_EVENT(d) (XMAGIC_DATA (d)->underlying.mswindows_event)
|
|
683 #define XSET_MAGIC_DATA_MSWINDOWS_EVENT(d, e) (XMAGIC_DATA (d)->underlying.mswindows_event = (e))
|
|
684 #endif
|
|
685
|
|
686 #else /* not USE_KKCC */
|
428
|
687 union magic_data
|
|
688 {
|
771
|
689 /* No user-serviceable parts within. This is for things like
|
|
690 KeymapNotify and ExposeRegion events and so on that XEmacs itself
|
|
691 doesn't care about, but which it must do something with for proper
|
|
692 interaction with the window system.
|
|
693
|
|
694 Magic_events are handled somewhat asynchronously, just like
|
|
695 subprocess filters. However, occasionally a magic_event needs to
|
|
696 be handled synchronously; in that case, the asynchronous handling
|
|
697 of the magic_event will push an eval_event back onto the queue,
|
|
698 which will be handled synchronously later. This is one of the
|
|
699 reasons why eval_events exist; I'm not entirely happy with this
|
|
700 aspect of this event model.
|
|
701 */
|
|
702
|
462
|
703 #ifdef HAVE_GTK
|
771
|
704 GdkEvent underlying_gdk_event;
|
462
|
705 #endif
|
428
|
706 #ifdef HAVE_X_WINDOWS
|
771
|
707 XEvent underlying_x_event;
|
428
|
708 #endif
|
|
709 #ifdef HAVE_MS_WINDOWS
|
771
|
710 int underlying_mswindows_event;
|
428
|
711 #endif
|
|
712 };
|
934
|
713 #endif /* not USE_KKCC */
|
|
714
|
428
|
715
|
|
716 struct Lisp_Timeout
|
|
717 {
|
432
|
718 struct lcrecord_header header;
|
428
|
719 int id; /* Id we use to identify the timeout over its lifetime */
|
|
720 int interval_id; /* Id for this particular interval; this may
|
771
|
721 be different each time the timeout is
|
|
722 signalled.*/
|
428
|
723 Lisp_Object function, object; /* Function and object associated
|
771
|
724 with timeout. */
|
428
|
725 EMACS_TIME next_signal_time; /* Absolute time when the timeout
|
771
|
726 is next going to be signalled. */
|
428
|
727 unsigned int resignal_msecs; /* How far after the next timeout
|
771
|
728 should the one after that
|
|
729 occur? */
|
428
|
730 };
|
440
|
731 typedef struct Lisp_Timeout Lisp_Timeout;
|
428
|
732
|
440
|
733 DECLARE_LRECORD (timeout, Lisp_Timeout);
|
|
734 #define XTIMEOUT(x) XRECORD (x, timeout, Lisp_Timeout)
|
617
|
735 #define wrap_timeout(p) wrap_record (p, timeout)
|
428
|
736 #define TIMEOUTP(x) RECORDP (x, timeout)
|
|
737 #define CHECK_TIMEOUT(x) CHECK_RECORD (x, timeout)
|
|
738 #define CONCHECK_TIMEOUT(x) CONCHECK_RECORD (x, timeout)
|
|
739
|
|
740 struct Lisp_Event
|
|
741 {
|
|
742 /* header->next (aka XEVENT_NEXT ()) is used as follows:
|
|
743 - For dead events, this is the next dead one.
|
|
744 - For events on the command_event_queue, the next one on the queue.
|
|
745 - Likewise for events chained in the command builder.
|
|
746 - Otherwise it's Qnil.
|
|
747 */
|
|
748 struct lrecord_header lheader;
|
771
|
749 Lisp_Object next;
|
|
750 emacs_event_type event_type;
|
|
751
|
|
752 /* Where this event occurred on. This will be a frame, device,
|
|
753 console, or nil, depending on the event type. It is important
|
|
754 that an object of a more specific type than is actually generated
|
|
755 is not substituted -- e.g. there should not be a frame inserted
|
|
756 when a key-press event occurs, because events on dead channels
|
|
757 are automatically ignored.
|
|
758
|
|
759 Specifically:
|
|
760
|
|
761 -- for button and mouse-motion events, channel will be a
|
|
762 frame. (The translation to a window occurs later.)
|
|
763
|
|
764 -- for keyboard events, channel will be a console. Note that
|
|
765 fake keyboard events (generated by `character-to-event' or
|
|
766 something that calls this, such as macros) need to have the
|
|
767 selected console stored into them when the event is created.
|
|
768 This is so that the correct console-local variables (e.g. the
|
|
769 command builder) will get affected.
|
|
770
|
|
771 -- for timer, process, magic-eval, and eval events, channel will
|
|
772 be nil.
|
|
773
|
|
774 -- for misc-user events, channel will be a frame.
|
|
775
|
|
776 -- for magic events, channel will be a frame (usually) or a
|
|
777 device. */
|
|
778 Lisp_Object channel;
|
|
779
|
|
780 /* When this event occurred -- if not known, this is made up. ####
|
|
781 All timestamps should be measured as milliseconds since XEmacs
|
|
782 started. Currently they are raw server timestamps. (The X
|
|
783 protocol doesn't provide any easy way of translating between
|
|
784 server time and real process time; yuck.) */
|
934
|
785 unsigned int timestamp;
|
771
|
786
|
934
|
787 #ifdef USE_KKCC
|
|
788 Lisp_Object event_data;
|
|
789 #else /* not USE_KKCC */
|
428
|
790 union
|
|
791 {
|
771
|
792 struct key_data key;
|
|
793 struct button_data button;
|
|
794 struct motion_data motion;
|
|
795 struct process_data process;
|
|
796 struct timeout_data timeout;
|
|
797 struct eval_data eval; /* misc_user_event no longer uses this */
|
|
798 struct misc_user_data misc; /* because it needs position information */
|
|
799 union magic_data magic;
|
|
800 struct magic_eval_data magic_eval;
|
428
|
801 } event;
|
934
|
802 #endif /* not USE_KKCC */
|
428
|
803 };
|
|
804
|
440
|
805 DECLARE_LRECORD (event, Lisp_Event);
|
|
806 #define XEVENT(x) XRECORD (x, event, Lisp_Event)
|
617
|
807 #define wrap_event(p) wrap_record (p, event)
|
428
|
808 #define EVENTP(x) RECORDP (x, event)
|
|
809 #define CHECK_EVENT(x) CHECK_RECORD (x, event)
|
|
810 #define CONCHECK_EVENT(x) CONCHECK_RECORD (x, event)
|
|
811
|
|
812 DECLARE_LRECORD (command_builder, struct command_builder);
|
|
813
|
|
814 #define EVENT_CHANNEL(a) ((a)->channel)
|
|
815 #define EVENT_TYPE(a) ((a)->event_type)
|
|
816 #define XEVENT_TYPE(a) (XEVENT (a)->event_type)
|
|
817 #define EVENT_NEXT(a) ((a)->next)
|
|
818 #define XEVENT_NEXT(e) (XEVENT (e)->next)
|
934
|
819 #ifdef USE_KKCC
|
|
820 #else /* not USE_KKCC */
|
428
|
821 #define XSET_EVENT_NEXT(e, n) do { (XEVENT (e)->next = (n)); } while (0)
|
934
|
822 #endif /* not USE_KKCC */
|
|
823
|
|
824 #ifdef USE_KKCC
|
|
825 #define XEVENT_DATA(ev) (XEVENT (ev)->event_data)
|
|
826 #define EVENT_DATA(ev) ((ev)->event_data)
|
|
827 #define XEVENT_CHANNEL(ev) (XEVENT (ev)->channel)
|
|
828 #define EVENT_CHANNEL(ev) ((ev)->channel)
|
|
829 #define EVENT_TIMESTAMP(ev) \
|
|
830 ((ev)->timestamp)
|
|
831 #define XEVENT_TIMESTAMP(ev) EVENT_TIMESTAMP (XEVENT (ev))
|
|
832
|
|
833 #define SET_EVENT_TIMESTAMP_ZERO(ev) \
|
|
834 ((ev)->timestamp = Qzero)
|
|
835 #define SET_EVENT_TIMESTAMP(ev, t) \
|
|
836 (ev)->timestamp = (t)
|
|
837 #define XSET_EVENT_TIMESTAMP(ev, t) SET_EVENT_TIMESTAMP (XEVENT (ev), t)
|
|
838
|
|
839
|
|
840 #define SET_EVENT_CHANNEL(ev, c) \
|
|
841 do { \
|
|
842 Lisp_Event *mac_event = (ev); \
|
|
843 mac_event->channel = (c); \
|
|
844 } while (0)
|
|
845 #define XSET_EVENT_CHANNEL(ev, c) SET_EVENT_CHANNEL (XEVENT (ev), c)
|
|
846
|
|
847 #define SET_EVENT_DATA(ev, d) \
|
|
848 do { \
|
|
849 Lisp_Event *mac_event = (ev); \
|
|
850 mac_event->event_data = (d); \
|
|
851 } while (0)
|
|
852 #define XSET_EVENT_DATA(ev, d) SET_EVENT_DATA (XEVENT (ev), d)
|
|
853
|
|
854 INLINE_HEADER void set_event_type(struct Lisp_Event *event, emacs_event_type t);
|
|
855 INLINE_HEADER void
|
|
856 set_event_type(struct Lisp_Event *event, emacs_event_type t)
|
|
857 {
|
|
858 event->event_type = t;
|
|
859
|
|
860 switch (t) {
|
|
861 case key_press_event:
|
|
862 event->event_data = make_key_data ();
|
|
863 break;
|
|
864 case button_press_event:
|
|
865 case button_release_event:
|
|
866 event->event_data = make_button_data ();
|
|
867 break;
|
|
868 case pointer_motion_event:
|
|
869 event->event_data = make_motion_data ();
|
|
870 break;
|
|
871 case process_event:
|
|
872 event->event_data = make_process_data ();
|
|
873 break;
|
|
874 case timeout_event:
|
|
875 event->event_data = make_timeout_data ();
|
|
876 break;
|
|
877 case magic_event:
|
|
878 event->event_data = make_magic_data ();
|
|
879 break;
|
|
880 case magic_eval_event:
|
|
881 event->event_data = make_magic_eval_data ();
|
|
882 break;
|
|
883 case eval_event:
|
|
884 event->event_data = make_eval_data ();
|
|
885 break;
|
|
886 case misc_user_event:
|
|
887 event->event_data = make_misc_user_data ();
|
|
888 break;
|
|
889 default:
|
|
890 break;
|
|
891 }
|
|
892 }
|
|
893 #define XSET_EVENT_TYPE(ev, t) set_event_type (XEVENT (ev), t)
|
|
894 #define SET_EVENT_TYPE(ev, t) set_event_type (ev, t)
|
|
895
|
|
896
|
|
897 #define SET_EVENT_NEXT(ev, n) \
|
|
898 do { \
|
|
899 Lisp_Event *mac_event = (ev); \
|
|
900 mac_event->next = (n); \
|
|
901 } while (0)
|
|
902 #define XSET_EVENT_NEXT(ev, n) SET_EVENT_NEXT (XEVENT (ev), n)
|
|
903
|
|
904 #endif /* USE_KKCC */
|
|
905
|
428
|
906
|
|
907 #define EVENT_CHAIN_LOOP(event, chain) \
|
|
908 for (event = chain; !NILP (event); event = XEVENT_NEXT (event))
|
|
909
|
|
910 #define EVENT_LIVE_P(a) (EVENT_TYPE (a) != dead_event)
|
|
911
|
771
|
912 #define CHECK_LIVE_EVENT(x) do { \
|
|
913 CHECK_EVENT (x); \
|
|
914 if (! EVENT_LIVE_P (XEVENT (x))) \
|
|
915 dead_wrong_type_argument (Qevent_live_p, (x)); \
|
428
|
916 } while (0)
|
771
|
917 #define CONCHECK_LIVE_EVENT(x) do { \
|
|
918 CONCHECK_EVENT (x); \
|
|
919 if (! EVENT_LIVE_P (XEVENT (x))) \
|
|
920 x = wrong_type_argument (Qevent_live_p, (x)); \
|
428
|
921 } while (0)
|
|
922
|
|
923
|
|
924 EXFUN (Fcharacter_to_event, 4);
|
|
925 EXFUN (Fdeallocate_event, 1);
|
|
926 EXFUN (Fevent_glyph_extent, 1);
|
|
927 EXFUN (Fevent_modeline_position, 1);
|
|
928 EXFUN (Fevent_over_modeline_p, 1);
|
|
929 EXFUN (Fevent_over_toolbar_p, 1);
|
|
930 EXFUN (Fevent_over_vertical_divider_p, 1);
|
|
931 EXFUN (Fevent_point, 1);
|
|
932 EXFUN (Fevent_window, 1);
|
|
933 EXFUN (Fmake_event, 2);
|
|
934
|
|
935 extern Lisp_Object QKbackspace, QKdelete, QKescape, QKlinefeed, QKreturn;
|
|
936 extern Lisp_Object QKspace, QKtab, Qmouse_event_p, Vcharacter_set_property;
|
|
937 extern Lisp_Object Qcancel_mode_internal;
|
444
|
938 extern Lisp_Object Vmodifier_keys_sticky_time;
|
428
|
939
|
502
|
940 /* The modifiers XEmacs knows about; these appear in key and button events. */
|
|
941
|
771
|
942 #define XEMACS_MOD_CONTROL (1<<0)
|
|
943 #define XEMACS_MOD_META (1<<1)
|
|
944 #define XEMACS_MOD_SUPER (1<<2)
|
|
945 #define XEMACS_MOD_HYPER (1<<3)
|
|
946 #define XEMACS_MOD_ALT (1<<4)
|
|
947 #define XEMACS_MOD_SHIFT (1<<5) /* not used for dual-case characters */
|
|
948 #define XEMACS_MOD_BUTTON1 (1<<6)
|
|
949 #define XEMACS_MOD_BUTTON2 (1<<7)
|
|
950 #define XEMACS_MOD_BUTTON3 (1<<8)
|
|
951 #define XEMACS_MOD_BUTTON4 (1<<9)
|
|
952 #define XEMACS_MOD_BUTTON5 (1<<10)
|
502
|
953
|
|
954 /* Note: under X Windows, XEMACS_MOD_ALT is generated by the Alt key
|
|
955 if there are both Alt and Meta keys. If there are no Meta keys,
|
|
956 then Alt generates XEMACS_MOD_META instead.
|
428
|
957 */
|
|
958
|
|
959 /* Maybe this should be trickier */
|
|
960 #define KEYSYM(x) (intern (x))
|
|
961
|
|
962 /* from events.c */
|
934
|
963 #ifdef USE_KKCC
|
|
964 void format_event_object (Eistring *buf, Lisp_Object event, int brief);
|
|
965 #else /* not USE_KKCC */
|
793
|
966 void format_event_object (Eistring *buf, Lisp_Event *event, int brief);
|
934
|
967 #endif /* not USE_KKCC */
|
|
968 #ifdef USE_KKCC
|
|
969 //void format_event_data_object (Eistring *buf, Lisp_Object data, int brief);
|
|
970 void copy_event_data (Lisp_Object dest, Lisp_Object src);
|
|
971 #endif /* USE_KKCC */
|
867
|
972 void character_to_event (Ichar c, Lisp_Event *event,
|
771
|
973 struct console *con,
|
|
974 int use_console_meta_flag,
|
|
975 int do_backspace_mapping);
|
440
|
976 void zero_event (Lisp_Event *e);
|
428
|
977 void deallocate_event_chain (Lisp_Object event);
|
|
978 Lisp_Object event_chain_tail (Lisp_Object event);
|
|
979 void enqueue_event (Lisp_Object event, Lisp_Object *head, Lisp_Object *tail);
|
|
980 Lisp_Object dequeue_event (Lisp_Object *head, Lisp_Object *tail);
|
|
981 void enqueue_event_chain (Lisp_Object event_chain, Lisp_Object *head,
|
771
|
982 Lisp_Object *tail);
|
428
|
983 int event_chain_count (Lisp_Object event_chain);
|
771
|
984 Lisp_Object transfer_event_chain_pointer (Lisp_Object pointer,
|
|
985 Lisp_Object old_chain,
|
|
986 Lisp_Object new_chain);
|
428
|
987 void nth_of_key_sequence_as_event (Lisp_Object seq, int n, Lisp_Object event);
|
|
988 Lisp_Object key_sequence_to_event_chain (Lisp_Object seq);
|
|
989 Lisp_Object event_chain_find_previous (Lisp_Object event_chain,
|
771
|
990 Lisp_Object event);
|
428
|
991 Lisp_Object event_chain_nth (Lisp_Object event_chain, int n);
|
|
992 Lisp_Object copy_event_chain (Lisp_Object event_chain);
|
|
993 /* True if this is a non-internal event
|
|
994 (keyboard press, menu, scrollbar, mouse button) */
|
|
995 int command_event_p (Lisp_Object event);
|
440
|
996 void define_self_inserting_symbol (Lisp_Object, Lisp_Object);
|
867
|
997 Ichar event_to_character (Lisp_Event *, int, int, int);
|
428
|
998 struct console *event_console_or_selected (Lisp_Object event);
|
|
999
|
|
1000 /* from event-stream.c */
|
771
|
1001 Lisp_Object allocate_command_builder (Lisp_Object console, int with_echo_buf);
|
428
|
1002 void enqueue_magic_eval_event (void (*fun) (Lisp_Object), Lisp_Object object);
|
440
|
1003 void event_stream_handle_magic_event (Lisp_Event *event);
|
788
|
1004 void event_stream_format_magic_event (Lisp_Event *event, Lisp_Object pstream);
|
|
1005 int event_stream_compare_magic_event (Lisp_Event *e1, Lisp_Event *e2);
|
|
1006 Hashcode event_stream_hash_magic_event (Lisp_Event *e);
|
428
|
1007 void event_stream_select_console (struct console *con);
|
|
1008 void event_stream_unselect_console (struct console *con);
|
853
|
1009 void event_stream_select_process (Lisp_Process *proc, int doin, int doerr);
|
|
1010 void event_stream_unselect_process (Lisp_Process *proc, int doin, int doerr);
|
|
1011 void event_stream_create_io_streams (void* inhandle, void* outhandle,
|
|
1012 void *errhandle, Lisp_Object* instream,
|
|
1013 Lisp_Object* outstream,
|
|
1014 Lisp_Object* errstream,
|
|
1015 USID* in_usid,
|
|
1016 USID* err_usid,
|
|
1017 int flags);
|
|
1018 void event_stream_delete_io_streams (Lisp_Object instream,
|
|
1019 Lisp_Object outstream,
|
|
1020 Lisp_Object errstream,
|
|
1021 USID* in_usid,
|
|
1022 USID* err_usid);
|
428
|
1023 void event_stream_quit_p (void);
|
853
|
1024 void run_pre_idle_hook (void);
|
428
|
1025
|
|
1026 struct low_level_timeout
|
|
1027 {
|
|
1028 int id;
|
|
1029 EMACS_TIME time;
|
|
1030 struct low_level_timeout *next;
|
|
1031 };
|
|
1032
|
|
1033 int add_low_level_timeout (struct low_level_timeout **timeout_list,
|
771
|
1034 EMACS_TIME thyme);
|
428
|
1035 void remove_low_level_timeout (struct low_level_timeout **timeout_list,
|
771
|
1036 int id);
|
428
|
1037 int get_low_level_timeout_interval (struct low_level_timeout *
|
771
|
1038 timeout_list, EMACS_TIME *interval);
|
428
|
1039 int pop_low_level_timeout (struct low_level_timeout **timeout_list,
|
771
|
1040 EMACS_TIME *time_out);
|
428
|
1041 int event_stream_generate_wakeup (unsigned int milliseconds,
|
771
|
1042 unsigned int vanilliseconds,
|
|
1043 Lisp_Object function,
|
|
1044 Lisp_Object object,
|
|
1045 int async_p);
|
593
|
1046 int event_stream_resignal_wakeup (int interval_id, int async_p,
|
771
|
1047 Lisp_Object *function, Lisp_Object *object);
|
428
|
1048 void event_stream_disable_wakeup (int id, int async_p);
|
|
1049
|
593
|
1050 /* from signal.c */
|
|
1051 int signal_add_async_interval_timeout (EMACS_TIME thyme);
|
|
1052 void signal_remove_async_interval_timeout (int id);
|
428
|
1053
|
|
1054 /* from event-stream.c -- focus sanity */
|
|
1055 extern int focus_follows_mouse;
|
|
1056 void investigate_frame_change (void);
|
|
1057
|
|
1058 void emacs_handle_focus_change_preliminary (Lisp_Object frame_inp_and_dev);
|
|
1059 void emacs_handle_focus_change_final (Lisp_Object frame_inp_and_dev);
|
|
1060
|
|
1061 Lisp_Object extract_this_command_keys_nth_mouse_event (int n);
|
|
1062 Lisp_Object extract_vector_nth_mouse_event (Lisp_Object vector, int n);
|
|
1063
|
|
1064 void single_console_state (void);
|
|
1065 void any_console_state (void);
|
|
1066 int in_single_console_state (void);
|
|
1067
|
|
1068 extern int emacs_is_blocking;
|
|
1069
|
|
1070 extern volatile int sigint_happened;
|
|
1071
|
|
1072 #ifdef HAVE_UNIXOID_EVENT_LOOP
|
|
1073 /* from event-unixoid.c */
|
|
1074
|
|
1075 /* Ceci n'est pas un pipe. */
|
|
1076 extern int signal_event_pipe[];
|
|
1077
|
|
1078 void signal_fake_event (void);
|
|
1079 void drain_signal_event_pipe (void);
|
|
1080
|
|
1081 extern int fake_event_occurred;
|
|
1082
|
|
1083 int event_stream_unixoid_select_console (struct console *con);
|
|
1084 int event_stream_unixoid_unselect_console (struct console *con);
|
853
|
1085 void event_stream_unixoid_select_process (Lisp_Process *proc, int doin,
|
|
1086 int doerr, int *infd, int *errfd);
|
|
1087 void event_stream_unixoid_unselect_process (Lisp_Process *proc, int doin,
|
|
1088 int doerr, int *infd, int *errfd);
|
440
|
1089 int read_event_from_tty_or_stream_desc (Lisp_Event *event,
|
771
|
1090 struct console *con);
|
853
|
1091 void event_stream_unixoid_create_io_streams (void* inhandle, void* outhandle,
|
|
1092 void *errhandle,
|
|
1093 Lisp_Object* instream,
|
|
1094 Lisp_Object* outstream,
|
|
1095 Lisp_Object* errstream,
|
|
1096 USID* in_usid,
|
|
1097 USID* err_usid,
|
|
1098 int flags);
|
|
1099 void event_stream_unixoid_delete_io_streams (Lisp_Object instream,
|
|
1100 Lisp_Object outstream,
|
|
1101 Lisp_Object errstream,
|
|
1102 USID* in_usid,
|
|
1103 USID* err_usid);
|
428
|
1104
|
|
1105 /* Beware: this evil macro evaluates its arg many times */
|
|
1106 #define FD_TO_USID(fd) ((fd)==0 ? (USID)999999 : ((fd)<0 ? USID_DONTHASH : (USID)(fd)))
|
|
1107
|
|
1108 #endif /* HAVE_UNIXOID_EVENT_LOOP */
|
|
1109
|
|
1110 /* Define this if you want the tty event stream to be used when the
|
|
1111 first console is tty, even if HAVE_X_WINDOWS is defined */
|
|
1112 /* #define DEBUG_TTY_EVENT_STREAM */
|
|
1113
|
|
1114
|
442
|
1115 /* #### a hack, until accelerator shit is cleaned up */
|
|
1116
|
|
1117 /* This structure is what we use to encapsulate the state of a command sequence
|
|
1118 being composed; key events are executed by adding themselves to the command
|
|
1119 builder; if the command builder is then complete (does not still represent
|
|
1120 a prefix key sequence) it executes the corresponding command.
|
|
1121 */
|
|
1122 struct command_builder
|
|
1123 {
|
|
1124 struct lcrecord_header header;
|
|
1125 Lisp_Object console; /* back pointer to the console this command
|
771
|
1126 builder is for */
|
|
1127 #if 0
|
|
1128 /* #### Not implemented: nil, or an event representing the first
|
|
1129 event read after the last command completed. Threaded. */
|
442
|
1130 Lisp_Object prefix_events;
|
771
|
1131 #endif /* 0 */
|
|
1132 /* nil, or an event chain representing the events in the current
|
|
1133 keymap-lookup sequence. NOTE: All events in the chain MUST be
|
|
1134 freshly allocated, with no pointers to them elsewhere. */
|
442
|
1135 Lisp_Object current_events;
|
771
|
1136 /* Last elt of current_events */
|
442
|
1137 Lisp_Object most_current_event;
|
771
|
1138 /* Last elt before function map code took over. What this means is:
|
442
|
1139 All prefixes up to (but not including) this event have non-nil
|
|
1140 bindings, but the prefix including this event has a nil binding.
|
|
1141 Any events in the chain after this one were read solely because
|
|
1142 we're part of a possible function key. If we end up with
|
|
1143 something that's not part of a possible function key, we have to
|
|
1144 unread all of those events. */
|
|
1145 Lisp_Object last_non_munged_event;
|
|
1146 /* One set of values for function-key-map, one for key-translation-map */
|
|
1147 struct munging_key_translation
|
|
1148 {
|
|
1149 /* First event that can begin a possible function key sequence
|
|
1150 (to be translated according to function-key-map). Normally
|
|
1151 this is the first event in the chain. However, once we've
|
|
1152 translated a sequence through function-key-map, this will point
|
|
1153 to the first event after the translated sequence: we don't ever
|
|
1154 want to translate any events twice through function-key-map, or
|
|
1155 things could get really screwed up (e.g. if the user created a
|
|
1156 translation loop). If this is nil, then the next-read event is
|
|
1157 the first that can begin a function key sequence. */
|
|
1158 Lisp_Object first_mungeable_event;
|
|
1159 } munge_me[2];
|
934
|
1160 Ibyte *echo_buf;
|
442
|
1161
|
|
1162 Bytecount echo_buf_length; /* size of echo_buf */
|
|
1163 Bytecount echo_buf_index; /* index into echo_buf
|
771
|
1164 * -1 before doing echoing for new cmd */
|
442
|
1165 /* Self-insert-command is magic in that it doesn't always push an undo-
|
|
1166 boundary: up to 20 consecutive self-inserts can happen before an undo-
|
|
1167 boundary is pushed. This variable is that counter.
|
|
1168 */
|
|
1169 int self_insert_countdown;
|
|
1170 };
|
|
1171
|
440
|
1172 #endif /* INCLUDED_events_h_ */
|