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