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
|
|
30 /* There is one object called an event_stream. This object contains
|
|
31 callback functions for doing the window-system-dependent operations
|
|
32 that XEmacs requires.
|
|
33
|
|
34 If XEmacs is compiled with support for X11 and the X Toolkit, then this
|
|
35 event_stream structure will contain functions that can cope with input
|
|
36 on XEmacs windows on multiple displays, as well as input from dumb tty
|
|
37 frames.
|
|
38
|
|
39 If it is desired to have XEmacs able to open frames on the displays of
|
|
40 multiple heterogeneous machines, X11 and SunView, or X11 and NeXT, for
|
|
41 example, then it will be necessary to construct an event_stream structure
|
|
42 that can cope with the given types. Currently, the only implemented
|
440
|
43 event_streams are for dumb-ttys, and for X11 plus dumb-ttys,
|
|
44 and for mswindows.
|
428
|
45
|
|
46 To implement this for one window system is relatively simple.
|
|
47 To implement this for multiple window systems is trickier and may
|
|
48 not be possible in all situations, but it's been done for X and TTY.
|
|
49
|
|
50 Note that these callbacks are *NOT* console methods; that's because
|
|
51 the routines are not specific to a particular console type but must
|
|
52 be able to simultaneously cope with all allowable console types.
|
|
53
|
|
54 The slots of the event_stream structure:
|
|
55
|
|
56 next_event_cb A function which fills in an XEmacs_event structure
|
|
57 with the next event available. If there is no event
|
|
58 available, then this should block.
|
|
59
|
|
60 IMPORTANT: timer events and especially process
|
|
61 events *must not* be returned if there are
|
|
62 events of other types available; otherwise you
|
|
63 can end up with an infinite loop in Fdiscard_input().
|
|
64
|
|
65 event_pending_cb A function which says whether there are events to be
|
|
66 read. If called with an argument of 0, then this
|
|
67 should say whether calling the next_event_cb will
|
|
68 block. If called with an argument of 1, then this
|
|
69 should say whether there are user-generated events
|
|
70 pending (that is, keypresses or mouse-clicks). This
|
|
71 is used for redisplay optimization, among other
|
|
72 things. On dumb ttys, these two results are the
|
|
73 same, but under a window system, they are not.
|
|
74
|
|
75 If this function is not sure whether there are events
|
|
76 to be read, it *must* return 0. Otherwise various
|
|
77 undesirable effects will occur, such as redisplay
|
|
78 not occurring until the next event occurs.
|
|
79
|
|
80 handle_magic_event_cb XEmacs calls this with an event structure which
|
|
81 contains window-system dependent information that
|
|
82 XEmacs doesn't need to know about, but which must
|
|
83 happen in order. If the next_event_cb never returns
|
|
84 an event of type "magic", this will never be used.
|
|
85
|
788
|
86 format_magic_event_cb Called with a magic event; print a representation of
|
|
87 the innards of the event to PSTREAM.
|
|
88
|
|
89 compare_magic_event_cb Called with two magic events; return non-zero if
|
|
90 the innards of the two are equal, zero otherwise.
|
|
91
|
|
92 hash_magic_event_cb Called with a magic event; return a hash of the
|
|
93 innards of the event.
|
|
94
|
428
|
95 add_timeout_cb Called with an EMACS_TIME, the absolute time at
|
|
96 which a wakeup event should be generated; and a
|
|
97 void *, which is an arbitrary value that will be
|
|
98 returned in the timeout event. The timeouts
|
|
99 generated by this function should be one-shots:
|
|
100 they fire once and then disappear. This callback
|
|
101 should return an int id-number which uniquely
|
|
102 identifies this wakeup. If an implementation
|
|
103 doesn't have microseconds or millisecond
|
|
104 granularity, it should round up to the closest
|
|
105 value it can deal with.
|
|
106
|
|
107 remove_timeout_cb Called with an int, the id number of a wakeup to
|
|
108 discard. This id number must have been returned by
|
|
109 the add_timeout_cb. If the given wakeup has
|
|
110 already expired, this should do nothing.
|
|
111
|
|
112 select_process_cb These callbacks tell the underlying implementation to
|
|
113 unselect_process_cb add or remove a file descriptor from the list of fds
|
|
114 which are polled for inferior-process input. When
|
|
115 input becomes available on the given process
|
|
116 connection, an event of type "process" should be
|
|
117 generated.
|
|
118
|
|
119 select_console_cb These callbacks tell the underlying implementation
|
|
120 unselect_console_cb to add or remove a console from the list of consoles
|
|
121 which are polled for user-input.
|
|
122
|
|
123 select_device_cb These callbacks are used by Unixoid event loops
|
|
124 unselect_device_cb (those that use select() and file descriptors and
|
|
125 have a separate input fd per device).
|
|
126
|
|
127 create_stream_pair_cb These callbacks are called by process code to
|
|
128 delete_stream_pair_cb create and delete a pair of input and output lstreams
|
|
129 which are used for subprocess I/O.
|
|
130
|
|
131 quitp_cb A handler function called from the `QUIT' macro which
|
|
132 should check whether the quit character has been
|
|
133 typed. On systems with SIGIO, this will not be called
|
|
134 unless the `sigio_happened' flag is true (it is set
|
|
135 from the SIGIO handler).
|
|
136
|
|
137 XEmacs has its own event structures, which are distinct from the event
|
|
138 structures used by X or any other window system. It is the job of the
|
|
139 event_stream layer to translate to this format.
|
|
140 */
|
|
141
|
|
142 /*
|
|
143 Stream pairs description
|
|
144 ------------------------
|
|
145
|
|
146 Since there are many possible processes/event loop combinations, the event code
|
|
147 is responsible for creating an appropriate lstream type. The process
|
|
148 implementation does not care about that implementation.
|
|
149
|
|
150 The Create stream pair function is passed two void* values, which identify
|
|
151 process-dependent 'handles'. The process implementation uses these handles
|
|
152 to communicate with child processes. The function must be prepared to receive
|
440
|
153 handle types of any process implementation. Since only one process
|
428
|
154 implementation exists in a particular XEmacs configuration, preprocessing
|
440
|
155 is a means of compiling in the support for the code which deals with particular
|
428
|
156 handle types.
|
|
157
|
|
158 For example, a unixoid type loop, which relies on file descriptors, may be
|
|
159 asked to create a pair of streams by a unix-style process implementation.
|
|
160 In this case, the handles passed are unix file descriptors, and the code
|
|
161 may deal with these directly. Although, the same code may be used on Win32
|
|
162 system with X-Windows. In this case, Win32 process implementation passes
|
|
163 handles of type HANDLE, and the create_stream_pair function must call
|
|
164 appropriate function to get file descriptors given HANDLEs, so that these
|
|
165 descriptors may be passed to XtAddInput.
|
|
166
|
|
167 The handle given may have special denying value, in which case the
|
|
168 corresponding lstream should not be created.
|
|
169
|
|
170 The return value of the function is a unique stream identifier. It is used
|
|
171 by processes implementation, in its platform-independent part. There is
|
|
172 the get_process_from_usid function, which returns process object given its
|
|
173 USID. The event stream is responsible for converting its internal handle
|
|
174 type into USID.
|
|
175
|
|
176 Example is the TTY event stream. When a file descriptor signals input, the
|
|
177 event loop must determine process to which the input is destined. Thus,
|
|
178 the implementation uses process input stream file descriptor as USID, by
|
|
179 simply casting the fd value to USID type.
|
|
180
|
|
181 There are two special USID values. One, USID_ERROR, indicates that the stream
|
|
182 pair cannot be created. The second, USID_DONTHASH, indicates that streams are
|
|
183 created, but the event stream does not wish to be able to find the process
|
|
184 by its USID. Specifically, if an event stream implementation never calls
|
|
185 get_process_from_usid, this value should always be returned, to prevent
|
|
186 accumulating useless information on USID to process relationship.
|
|
187 */
|
|
188
|
|
189 /* typedef unsigned int USID; in lisp.h */
|
|
190 #define USID_ERROR ((USID)-1)
|
|
191 #define USID_DONTHASH ((USID)0)
|
|
192
|
|
193
|
|
194 struct event_stream
|
|
195 {
|
|
196 int (*event_pending_p) (int);
|
440
|
197 void (*next_event_cb) (Lisp_Event *);
|
|
198 void (*handle_magic_event_cb) (Lisp_Event *);
|
788
|
199 void (*format_magic_event_cb) (Lisp_Event *, Lisp_Object pstream);
|
|
200 int (*compare_magic_event_cb) (Lisp_Event *, Lisp_Event *);
|
|
201 Hashcode (*hash_magic_event_cb)(Lisp_Event *);
|
428
|
202 int (*add_timeout_cb) (EMACS_TIME);
|
|
203 void (*remove_timeout_cb) (int);
|
|
204 void (*select_console_cb) (struct console *);
|
|
205 void (*unselect_console_cb) (struct console *);
|
440
|
206 void (*select_process_cb) (Lisp_Process *);
|
|
207 void (*unselect_process_cb) (Lisp_Process *);
|
428
|
208 void (*quit_p_cb) (void);
|
442
|
209 void (*force_event_pending) (struct frame* f);
|
428
|
210 USID (*create_stream_pair_cb) (void* /* inhandle*/, void* /*outhandle*/ ,
|
|
211 Lisp_Object* /* instream */,
|
|
212 Lisp_Object* /* outstream */,
|
|
213 int /* flags */);
|
|
214 USID (*delete_stream_pair_cb) (Lisp_Object /* instream */,
|
|
215 Lisp_Object /* outstream */);
|
442
|
216 int (*current_event_timestamp_cb) (struct console *);
|
428
|
217 };
|
|
218
|
|
219 /* Flags for create_stream_pair_cb() FLAGS parameter */
|
|
220 #define STREAM_PTY_FLUSHING 0x0001
|
|
221 #define STREAM_NETWORK_CONNECTION 0x0002
|
|
222
|
|
223 extern struct event_stream *event_stream;
|
|
224
|
|
225 typedef enum emacs_event_type
|
|
226 {
|
|
227 empty_event,
|
|
228 key_press_event,
|
|
229 button_press_event,
|
|
230 button_release_event,
|
|
231 pointer_motion_event,
|
|
232 process_event,
|
|
233 timeout_event,
|
|
234 magic_event,
|
|
235 magic_eval_event,
|
|
236 eval_event,
|
|
237 misc_user_event,
|
|
238 dead_event
|
|
239 } emacs_event_type;
|
|
240
|
|
241 #define first_event_type empty_event
|
|
242 #define last_event_type dead_event
|
|
243
|
771
|
244 #ifdef MULE
|
|
245
|
|
246 enum alternative_key_chars
|
|
247 {
|
|
248 KEYCHAR_CURRENT_LANGENV,
|
|
249 KEYCHAR_DEFAULT_USER,
|
|
250 KEYCHAR_DEFAULT_SYSTEM,
|
|
251 KEYCHAR_UNDERLYING_VIRTUAL_KEY_CURRENT_LANGENV,
|
|
252 KEYCHAR_UNDERLYING_VIRTUAL_KEY_DEFAULT_USER,
|
|
253 KEYCHAR_UNDERLYING_VIRTUAL_KEY_DEFAULT_SYSTEM,
|
|
254 KEYCHAR_QWERTY,
|
|
255 KEYCHAR_LAST
|
|
256 };
|
|
257
|
|
258 #endif /* MULE */
|
428
|
259
|
|
260 struct key_data
|
|
261 {
|
771
|
262 /* What keysym this is; a character or a symbol. */
|
|
263 Lisp_Object keysym;
|
|
264 /* Modifiers held down when key was pressed: control, meta, etc.
|
|
265 Also includes buttons. For many keys, Shift is not a bit; that
|
|
266 is implicit in the keyboard layout. */
|
|
267 int modifiers;
|
|
268 #ifdef MULE
|
|
269 /* Alternate character interpretations for this key in different
|
|
270 keyboard layouts. This deals with the problem of pressing C-x in
|
|
271 the Russian layout (the so-called "Russian C-x problem"), for
|
|
272 example: `x' gets mapped to a Cyrillic character, so what do we
|
|
273 do? For that matter, what about `C-x b'? What we do is look the
|
|
274 key up in the default locales (current language environment, user
|
|
275 default, system default), then check to see if the underlying
|
|
276 virtual key is alphabetic in the same three defaults, then
|
|
277 finally check US ASCII. We ignore the underlying virtual key for
|
|
278 the current layout to avoid the problem of a French speaker
|
|
279 (AZERTY layout) who temporarily switches to Russian: The virtual
|
|
280 keys underlying Russian are US-ASCII, so what the French speaker
|
|
281 things of as C-a (the key just to the right of TAB) appears as
|
|
282 C-q. (#### We should probably ignore the current char and look
|
|
283 *ONLY* in alt_keychars for all control keys. What about the
|
|
284 English speaker who temporarily switches to the French layout and
|
|
285 finds C-q mapped to C-a?) */
|
|
286 Emchar alt_keychars[KEYCHAR_LAST];
|
|
287 #endif /* MULE */
|
428
|
288 };
|
|
289
|
|
290 struct button_data
|
|
291 {
|
771
|
292 /* What button went down or up. */
|
|
293 int button;
|
|
294 /* Bucky-bits on that button: shift, control, meta, etc. Also
|
|
295 includes other buttons (not the one pressed). */
|
|
296 int modifiers;
|
|
297 /* Where it was at the button-state-change (in pixels). */
|
|
298 int x, y;
|
428
|
299 };
|
|
300
|
|
301 struct motion_data
|
|
302 {
|
771
|
303 /* Where it was after it moved (in pixels). */
|
|
304 int x, y;
|
|
305 /* Bucky-bits down when the motion was detected. */
|
|
306 int modifiers;
|
428
|
307 };
|
|
308
|
|
309 struct process_data
|
|
310 {
|
771
|
311 /* the XEmacs "process" object in question */
|
|
312 Lisp_Object process;
|
428
|
313 };
|
|
314
|
|
315 struct timeout_data
|
|
316 {
|
771
|
317 /*
|
|
318 interval_id The ID returned when the associated call to
|
|
319 add_timeout_cb() was made
|
|
320 ------ the rest of the fields are filled in by XEmacs -----
|
|
321 id_number The XEmacs timeout ID for this timeout (more
|
|
322 than one timeout event can have the same value
|
|
323 here, since XEmacs timeouts, as opposed to
|
|
324 add_timeout_cb() timeouts, can resignal
|
|
325 themselves)
|
|
326 function An elisp function to call when this timeout is
|
|
327 processed.
|
|
328 object The object passed to that function.
|
|
329 */
|
|
330 int interval_id;
|
|
331 int id_number;
|
|
332 Lisp_Object function;
|
|
333 Lisp_Object object;
|
428
|
334 };
|
|
335
|
|
336 struct eval_data
|
|
337 {
|
771
|
338 /* This kind of event is used internally; sometimes the window system
|
|
339 interface would like to inform XEmacs of some user action (such as
|
|
340 focusing on another frame) but needs that to happen synchronously
|
|
341 with the other user input, like keypresses. This is useful when
|
|
342 events are reported through callbacks rather than in the standard
|
|
343 event stream.
|
|
344
|
|
345 function An elisp function to call with this event object.
|
|
346 object Argument of function.
|
|
347 */
|
|
348 Lisp_Object function;
|
|
349 Lisp_Object object;
|
428
|
350 };
|
|
351
|
|
352 struct misc_user_data
|
|
353 {
|
771
|
354 /* #### The misc-user type is serious junk. It should be separated
|
|
355 out into different events. There's no reason to create
|
|
356 sub-subtypes of events.
|
|
357
|
|
358 function An elisp function to call with this event object.
|
|
359 object Argument of function.
|
|
360 button What button went down or up.
|
|
361 modifiers Bucky-bits on that button: shift, control, meta, etc.
|
|
362 x, y Where it was at the button-state-change (in pixels).
|
|
363 This is similar to an eval_event, except that it is
|
|
364 generated by user actions: selections in the
|
|
365 menubar, scrollbar actions, or drag and drop actions.
|
|
366 It is a "command" event, like key and mouse presses
|
|
367 (and unlike mouse motion, process output, and enter
|
|
368 and leave window hooks). In many ways, eval_events
|
|
369 are not the same as keypresses or misc_user_events.
|
|
370 The button, modifiers, x, and y parts are only used
|
|
371 by the XEmacs Drag'n'Drop system. Don't depend on their
|
|
372 values for other types of misc_user_events.
|
|
373 */
|
|
374 Lisp_Object function;
|
|
375 Lisp_Object object;
|
|
376 int button;
|
|
377 int modifiers;
|
|
378 int x, y;
|
428
|
379 };
|
|
380
|
|
381 struct magic_eval_data
|
|
382 {
|
771
|
383 /* This is like an eval event but its contents are not
|
|
384 Lisp-accessible. This allows for "internal eval events" that call
|
|
385 non-Lisp-accessible functions. Externally, a magic_eval_event just
|
|
386 appears as a magic_event; the Lisp programmer need not know
|
|
387 anything more.
|
|
388
|
|
389 internal_function An unexported function to call with this event
|
|
390 object. This allows eval events to call internal
|
|
391 functions. For a normal eval event, this field
|
|
392 will always be 0.
|
|
393 object Argument of function.
|
|
394
|
|
395 */
|
|
396 void (*internal_function) (Lisp_Object);
|
|
397 Lisp_Object object;
|
428
|
398 };
|
|
399
|
|
400 #if defined (HAVE_X_WINDOWS) && defined(emacs)
|
|
401 # include <X11/Xlib.h>
|
|
402 #endif
|
|
403
|
462
|
404 #ifdef HAVE_GTK
|
|
405 #include <gdk/gdk.h>
|
|
406 #endif
|
|
407
|
428
|
408 union magic_data
|
|
409 {
|
771
|
410 /* No user-serviceable parts within. This is for things like
|
|
411 KeymapNotify and ExposeRegion events and so on that XEmacs itself
|
|
412 doesn't care about, but which it must do something with for proper
|
|
413 interaction with the window system.
|
|
414
|
|
415 Magic_events are handled somewhat asynchronously, just like
|
|
416 subprocess filters. However, occasionally a magic_event needs to
|
|
417 be handled synchronously; in that case, the asynchronous handling
|
|
418 of the magic_event will push an eval_event back onto the queue,
|
|
419 which will be handled synchronously later. This is one of the
|
|
420 reasons why eval_events exist; I'm not entirely happy with this
|
|
421 aspect of this event model.
|
|
422 */
|
|
423
|
462
|
424 #ifdef HAVE_GTK
|
771
|
425 GdkEvent underlying_gdk_event;
|
462
|
426 #endif
|
428
|
427 #ifdef HAVE_X_WINDOWS
|
771
|
428 XEvent underlying_x_event;
|
428
|
429 #endif
|
|
430 #ifdef HAVE_MS_WINDOWS
|
771
|
431 int underlying_mswindows_event;
|
428
|
432 #endif
|
|
433 };
|
|
434
|
|
435 struct Lisp_Timeout
|
|
436 {
|
432
|
437 struct lcrecord_header header;
|
428
|
438 int id; /* Id we use to identify the timeout over its lifetime */
|
|
439 int interval_id; /* Id for this particular interval; this may
|
771
|
440 be different each time the timeout is
|
|
441 signalled.*/
|
428
|
442 Lisp_Object function, object; /* Function and object associated
|
771
|
443 with timeout. */
|
428
|
444 EMACS_TIME next_signal_time; /* Absolute time when the timeout
|
771
|
445 is next going to be signalled. */
|
428
|
446 unsigned int resignal_msecs; /* How far after the next timeout
|
771
|
447 should the one after that
|
|
448 occur? */
|
428
|
449 };
|
440
|
450 typedef struct Lisp_Timeout Lisp_Timeout;
|
428
|
451
|
440
|
452 DECLARE_LRECORD (timeout, Lisp_Timeout);
|
|
453 #define XTIMEOUT(x) XRECORD (x, timeout, Lisp_Timeout)
|
617
|
454 #define wrap_timeout(p) wrap_record (p, timeout)
|
428
|
455 #define TIMEOUTP(x) RECORDP (x, timeout)
|
|
456 #define CHECK_TIMEOUT(x) CHECK_RECORD (x, timeout)
|
|
457 #define CONCHECK_TIMEOUT(x) CONCHECK_RECORD (x, timeout)
|
|
458
|
|
459 struct Lisp_Event
|
|
460 {
|
|
461 /* header->next (aka XEVENT_NEXT ()) is used as follows:
|
|
462 - For dead events, this is the next dead one.
|
|
463 - For events on the command_event_queue, the next one on the queue.
|
|
464 - Likewise for events chained in the command builder.
|
|
465 - Otherwise it's Qnil.
|
|
466 */
|
|
467 struct lrecord_header lheader;
|
771
|
468 Lisp_Object next;
|
|
469 emacs_event_type event_type;
|
|
470
|
|
471 /* Where this event occurred on. This will be a frame, device,
|
|
472 console, or nil, depending on the event type. It is important
|
|
473 that an object of a more specific type than is actually generated
|
|
474 is not substituted -- e.g. there should not be a frame inserted
|
|
475 when a key-press event occurs, because events on dead channels
|
|
476 are automatically ignored.
|
|
477
|
|
478 Specifically:
|
|
479
|
|
480 -- for button and mouse-motion events, channel will be a
|
|
481 frame. (The translation to a window occurs later.)
|
|
482
|
|
483 -- for keyboard events, channel will be a console. Note that
|
|
484 fake keyboard events (generated by `character-to-event' or
|
|
485 something that calls this, such as macros) need to have the
|
|
486 selected console stored into them when the event is created.
|
|
487 This is so that the correct console-local variables (e.g. the
|
|
488 command builder) will get affected.
|
|
489
|
|
490 -- for timer, process, magic-eval, and eval events, channel will
|
|
491 be nil.
|
|
492
|
|
493 -- for misc-user events, channel will be a frame.
|
|
494
|
|
495 -- for magic events, channel will be a frame (usually) or a
|
|
496 device. */
|
|
497 Lisp_Object channel;
|
|
498
|
|
499 /* When this event occurred -- if not known, this is made up. ####
|
|
500 All timestamps should be measured as milliseconds since XEmacs
|
|
501 started. Currently they are raw server timestamps. (The X
|
|
502 protocol doesn't provide any easy way of translating between
|
|
503 server time and real process time; yuck.) */
|
|
504
|
|
505 unsigned int timestamp;
|
428
|
506 union
|
|
507 {
|
771
|
508 struct key_data key;
|
|
509 struct button_data button;
|
|
510 struct motion_data motion;
|
|
511 struct process_data process;
|
|
512 struct timeout_data timeout;
|
|
513 struct eval_data eval; /* misc_user_event no longer uses this */
|
|
514 struct misc_user_data misc; /* because it needs position information */
|
|
515 union magic_data magic;
|
|
516 struct magic_eval_data magic_eval;
|
428
|
517 } event;
|
|
518 };
|
|
519
|
440
|
520 DECLARE_LRECORD (event, Lisp_Event);
|
|
521 #define XEVENT(x) XRECORD (x, event, Lisp_Event)
|
617
|
522 #define wrap_event(p) wrap_record (p, event)
|
428
|
523 #define EVENTP(x) RECORDP (x, event)
|
|
524 #define CHECK_EVENT(x) CHECK_RECORD (x, event)
|
|
525 #define CONCHECK_EVENT(x) CONCHECK_RECORD (x, event)
|
|
526
|
|
527 DECLARE_LRECORD (command_builder, struct command_builder);
|
|
528
|
|
529 #define EVENT_CHANNEL(a) ((a)->channel)
|
|
530 #define EVENT_TYPE(a) ((a)->event_type)
|
|
531 #define XEVENT_TYPE(a) (XEVENT (a)->event_type)
|
|
532 #define EVENT_NEXT(a) ((a)->next)
|
|
533 #define XEVENT_NEXT(e) (XEVENT (e)->next)
|
|
534 #define XSET_EVENT_NEXT(e, n) do { (XEVENT (e)->next = (n)); } while (0)
|
|
535
|
|
536 #define EVENT_CHAIN_LOOP(event, chain) \
|
|
537 for (event = chain; !NILP (event); event = XEVENT_NEXT (event))
|
|
538
|
|
539 #define EVENT_LIVE_P(a) (EVENT_TYPE (a) != dead_event)
|
|
540
|
771
|
541 #define CHECK_LIVE_EVENT(x) do { \
|
|
542 CHECK_EVENT (x); \
|
|
543 if (! EVENT_LIVE_P (XEVENT (x))) \
|
|
544 dead_wrong_type_argument (Qevent_live_p, (x)); \
|
428
|
545 } while (0)
|
771
|
546 #define CONCHECK_LIVE_EVENT(x) do { \
|
|
547 CONCHECK_EVENT (x); \
|
|
548 if (! EVENT_LIVE_P (XEVENT (x))) \
|
|
549 x = wrong_type_argument (Qevent_live_p, (x)); \
|
428
|
550 } while (0)
|
|
551
|
|
552
|
|
553 EXFUN (Fcharacter_to_event, 4);
|
|
554 EXFUN (Fdeallocate_event, 1);
|
|
555 EXFUN (Fevent_glyph_extent, 1);
|
|
556 EXFUN (Fevent_modeline_position, 1);
|
|
557 EXFUN (Fevent_over_modeline_p, 1);
|
|
558 EXFUN (Fevent_over_toolbar_p, 1);
|
|
559 EXFUN (Fevent_over_vertical_divider_p, 1);
|
|
560 EXFUN (Fevent_point, 1);
|
|
561 EXFUN (Fevent_window, 1);
|
|
562 EXFUN (Fmake_event, 2);
|
|
563
|
|
564 extern Lisp_Object QKbackspace, QKdelete, QKescape, QKlinefeed, QKreturn;
|
|
565 extern Lisp_Object QKspace, QKtab, Qmouse_event_p, Vcharacter_set_property;
|
|
566 extern Lisp_Object Qcancel_mode_internal;
|
444
|
567 extern Lisp_Object Vmodifier_keys_sticky_time;
|
428
|
568
|
502
|
569 /* The modifiers XEmacs knows about; these appear in key and button events. */
|
|
570
|
771
|
571 #define XEMACS_MOD_CONTROL (1<<0)
|
|
572 #define XEMACS_MOD_META (1<<1)
|
|
573 #define XEMACS_MOD_SUPER (1<<2)
|
|
574 #define XEMACS_MOD_HYPER (1<<3)
|
|
575 #define XEMACS_MOD_ALT (1<<4)
|
|
576 #define XEMACS_MOD_SHIFT (1<<5) /* not used for dual-case characters */
|
|
577 #define XEMACS_MOD_BUTTON1 (1<<6)
|
|
578 #define XEMACS_MOD_BUTTON2 (1<<7)
|
|
579 #define XEMACS_MOD_BUTTON3 (1<<8)
|
|
580 #define XEMACS_MOD_BUTTON4 (1<<9)
|
|
581 #define XEMACS_MOD_BUTTON5 (1<<10)
|
502
|
582
|
|
583 /* Note: under X Windows, XEMACS_MOD_ALT is generated by the Alt key
|
|
584 if there are both Alt and Meta keys. If there are no Meta keys,
|
|
585 then Alt generates XEMACS_MOD_META instead.
|
428
|
586 */
|
|
587
|
|
588 /* Maybe this should be trickier */
|
|
589 #define KEYSYM(x) (intern (x))
|
|
590
|
|
591 /* from events.c */
|
793
|
592 void format_event_object (Eistring *buf, Lisp_Event *event, int brief);
|
440
|
593 void character_to_event (Emchar c, Lisp_Event *event,
|
771
|
594 struct console *con,
|
|
595 int use_console_meta_flag,
|
|
596 int do_backspace_mapping);
|
440
|
597 void zero_event (Lisp_Event *e);
|
428
|
598 void deallocate_event_chain (Lisp_Object event);
|
|
599 Lisp_Object event_chain_tail (Lisp_Object event);
|
|
600 void enqueue_event (Lisp_Object event, Lisp_Object *head, Lisp_Object *tail);
|
|
601 Lisp_Object dequeue_event (Lisp_Object *head, Lisp_Object *tail);
|
|
602 void enqueue_event_chain (Lisp_Object event_chain, Lisp_Object *head,
|
771
|
603 Lisp_Object *tail);
|
428
|
604 int event_chain_count (Lisp_Object event_chain);
|
771
|
605 Lisp_Object transfer_event_chain_pointer (Lisp_Object pointer,
|
|
606 Lisp_Object old_chain,
|
|
607 Lisp_Object new_chain);
|
428
|
608 void nth_of_key_sequence_as_event (Lisp_Object seq, int n, Lisp_Object event);
|
|
609 Lisp_Object key_sequence_to_event_chain (Lisp_Object seq);
|
|
610 Lisp_Object event_chain_find_previous (Lisp_Object event_chain,
|
771
|
611 Lisp_Object event);
|
428
|
612 Lisp_Object event_chain_nth (Lisp_Object event_chain, int n);
|
|
613 Lisp_Object copy_event_chain (Lisp_Object event_chain);
|
|
614 /* True if this is a non-internal event
|
|
615 (keyboard press, menu, scrollbar, mouse button) */
|
|
616 int command_event_p (Lisp_Object event);
|
440
|
617 void define_self_inserting_symbol (Lisp_Object, Lisp_Object);
|
|
618 Emchar event_to_character (Lisp_Event *, int, int, int);
|
428
|
619 struct console *event_console_or_selected (Lisp_Object event);
|
|
620
|
|
621 /* from event-stream.c */
|
771
|
622 Lisp_Object allocate_command_builder (Lisp_Object console, int with_echo_buf);
|
428
|
623 void enqueue_magic_eval_event (void (*fun) (Lisp_Object), Lisp_Object object);
|
440
|
624 void event_stream_next_event (Lisp_Event *event);
|
|
625 void event_stream_handle_magic_event (Lisp_Event *event);
|
788
|
626 void event_stream_format_magic_event (Lisp_Event *event, Lisp_Object pstream);
|
|
627 int event_stream_compare_magic_event (Lisp_Event *e1, Lisp_Event *e2);
|
|
628 Hashcode event_stream_hash_magic_event (Lisp_Event *e);
|
428
|
629 void event_stream_select_console (struct console *con);
|
|
630 void event_stream_unselect_console (struct console *con);
|
440
|
631 void event_stream_select_process (Lisp_Process *proc);
|
|
632 void event_stream_unselect_process (Lisp_Process *proc);
|
428
|
633 USID event_stream_create_stream_pair (void* inhandle, void* outhandle,
|
771
|
634 Lisp_Object* instream, Lisp_Object* outstream, int flags);
|
428
|
635 USID event_stream_delete_stream_pair (Lisp_Object instream, Lisp_Object outstream);
|
|
636 void event_stream_quit_p (void);
|
|
637
|
|
638 struct low_level_timeout
|
|
639 {
|
|
640 int id;
|
|
641 EMACS_TIME time;
|
|
642 struct low_level_timeout *next;
|
|
643 };
|
|
644
|
|
645 int add_low_level_timeout (struct low_level_timeout **timeout_list,
|
771
|
646 EMACS_TIME thyme);
|
428
|
647 void remove_low_level_timeout (struct low_level_timeout **timeout_list,
|
771
|
648 int id);
|
428
|
649 int get_low_level_timeout_interval (struct low_level_timeout *
|
771
|
650 timeout_list, EMACS_TIME *interval);
|
428
|
651 int pop_low_level_timeout (struct low_level_timeout **timeout_list,
|
771
|
652 EMACS_TIME *time_out);
|
428
|
653 int event_stream_generate_wakeup (unsigned int milliseconds,
|
771
|
654 unsigned int vanilliseconds,
|
|
655 Lisp_Object function,
|
|
656 Lisp_Object object,
|
|
657 int async_p);
|
593
|
658 int event_stream_resignal_wakeup (int interval_id, int async_p,
|
771
|
659 Lisp_Object *function, Lisp_Object *object);
|
428
|
660 void event_stream_disable_wakeup (int id, int async_p);
|
|
661
|
593
|
662 /* from signal.c */
|
|
663 int signal_add_async_interval_timeout (EMACS_TIME thyme);
|
|
664 void signal_remove_async_interval_timeout (int id);
|
428
|
665
|
|
666 /* from event-stream.c -- focus sanity */
|
|
667 extern int focus_follows_mouse;
|
|
668 void investigate_frame_change (void);
|
|
669
|
|
670 void emacs_handle_focus_change_preliminary (Lisp_Object frame_inp_and_dev);
|
|
671 void emacs_handle_focus_change_final (Lisp_Object frame_inp_and_dev);
|
|
672
|
|
673 Lisp_Object extract_this_command_keys_nth_mouse_event (int n);
|
|
674 Lisp_Object extract_vector_nth_mouse_event (Lisp_Object vector, int n);
|
|
675
|
|
676 void single_console_state (void);
|
|
677 void any_console_state (void);
|
|
678 int in_single_console_state (void);
|
|
679
|
|
680 extern int emacs_is_blocking;
|
|
681
|
|
682 extern volatile int sigint_happened;
|
|
683
|
|
684 #ifdef HAVE_UNIXOID_EVENT_LOOP
|
|
685 /* from event-unixoid.c */
|
|
686
|
|
687 /* Ceci n'est pas un pipe. */
|
|
688 extern int signal_event_pipe[];
|
|
689
|
|
690 void signal_fake_event (void);
|
|
691 void drain_signal_event_pipe (void);
|
|
692
|
|
693 extern int fake_event_occurred;
|
|
694
|
|
695 int event_stream_unixoid_select_console (struct console *con);
|
|
696 int event_stream_unixoid_unselect_console (struct console *con);
|
440
|
697 int event_stream_unixoid_select_process (Lisp_Process *proc);
|
|
698 int event_stream_unixoid_unselect_process (Lisp_Process *proc);
|
|
699 int read_event_from_tty_or_stream_desc (Lisp_Event *event,
|
771
|
700 struct console *con);
|
428
|
701 USID event_stream_unixoid_create_stream_pair (void* inhandle, void* outhandle,
|
771
|
702 Lisp_Object* instream,
|
|
703 Lisp_Object* outstream,
|
|
704 int flags);
|
428
|
705 USID event_stream_unixoid_delete_stream_pair (Lisp_Object instream,
|
771
|
706 Lisp_Object outstream);
|
428
|
707
|
|
708 /* Beware: this evil macro evaluates its arg many times */
|
|
709 #define FD_TO_USID(fd) ((fd)==0 ? (USID)999999 : ((fd)<0 ? USID_DONTHASH : (USID)(fd)))
|
|
710
|
|
711 #endif /* HAVE_UNIXOID_EVENT_LOOP */
|
|
712
|
|
713 /* Define this if you want the tty event stream to be used when the
|
|
714 first console is tty, even if HAVE_X_WINDOWS is defined */
|
|
715 /* #define DEBUG_TTY_EVENT_STREAM */
|
|
716
|
|
717
|
442
|
718 /* #### a hack, until accelerator shit is cleaned up */
|
|
719
|
|
720 /* This structure is what we use to encapsulate the state of a command sequence
|
|
721 being composed; key events are executed by adding themselves to the command
|
|
722 builder; if the command builder is then complete (does not still represent
|
|
723 a prefix key sequence) it executes the corresponding command.
|
|
724 */
|
|
725 struct command_builder
|
|
726 {
|
|
727 struct lcrecord_header header;
|
|
728 Lisp_Object console; /* back pointer to the console this command
|
771
|
729 builder is for */
|
|
730 #if 0
|
|
731 /* #### Not implemented: nil, or an event representing the first
|
|
732 event read after the last command completed. Threaded. */
|
442
|
733 Lisp_Object prefix_events;
|
771
|
734 #endif /* 0 */
|
|
735 /* nil, or an event chain representing the events in the current
|
|
736 keymap-lookup sequence. NOTE: All events in the chain MUST be
|
|
737 freshly allocated, with no pointers to them elsewhere. */
|
442
|
738 Lisp_Object current_events;
|
771
|
739 /* Last elt of current_events */
|
442
|
740 Lisp_Object most_current_event;
|
771
|
741 /* Last elt before function map code took over. What this means is:
|
442
|
742 All prefixes up to (but not including) this event have non-nil
|
|
743 bindings, but the prefix including this event has a nil binding.
|
|
744 Any events in the chain after this one were read solely because
|
|
745 we're part of a possible function key. If we end up with
|
|
746 something that's not part of a possible function key, we have to
|
|
747 unread all of those events. */
|
|
748 Lisp_Object last_non_munged_event;
|
|
749 /* One set of values for function-key-map, one for key-translation-map */
|
|
750 struct munging_key_translation
|
|
751 {
|
|
752 /* First event that can begin a possible function key sequence
|
|
753 (to be translated according to function-key-map). Normally
|
|
754 this is the first event in the chain. However, once we've
|
|
755 translated a sequence through function-key-map, this will point
|
|
756 to the first event after the translated sequence: we don't ever
|
|
757 want to translate any events twice through function-key-map, or
|
|
758 things could get really screwed up (e.g. if the user created a
|
|
759 translation loop). If this is nil, then the next-read event is
|
|
760 the first that can begin a function key sequence. */
|
|
761 Lisp_Object first_mungeable_event;
|
|
762 } munge_me[2];
|
|
763
|
665
|
764 Intbyte *echo_buf;
|
442
|
765 Bytecount echo_buf_length; /* size of echo_buf */
|
|
766 Bytecount echo_buf_index; /* index into echo_buf
|
771
|
767 * -1 before doing echoing for new cmd */
|
442
|
768 /* Self-insert-command is magic in that it doesn't always push an undo-
|
|
769 boundary: up to 20 consecutive self-inserts can happen before an undo-
|
|
770 boundary is pushed. This variable is that counter.
|
|
771 */
|
|
772 int self_insert_countdown;
|
|
773 };
|
|
774
|
440
|
775 #endif /* INCLUDED_events_h_ */
|