Mercurial > hg > xemacs-beta
annotate src/events.c @ 5139:a48ef26d87ee
Clean up prototypes for Lisp variables/symbols. Put decls for them with
the other stuff related to the file they're in. In the process, fix a few
places with incorrect initialization of symbols and variables.
-------------------- ChangeLog entries follow: --------------------
src/ChangeLog addition:
2010-03-12 Ben Wing <ben@xemacs.org>
* lisp.h:
* lisp.h (redo-symbols): Removed.
Put the Lisp variables and symbols where they belong, with other
stuff related to the file they're in.
* event-Xt.c (THIS_IS_X):
* event-Xt.c (syms_of_event_Xt):
* event-Xt.c (reinit_vars_of_event_Xt):
* event-gtk.c:
* event-gtk.c (syms_of_event_gtk):
* event-gtk.c (reinit_vars_of_event_gtk):
* event-stream.c:
* event-stream.c (syms_of_event_stream):
* event-stream.c (reinit_vars_of_event_stream):
* events.c (reinit_vars_of_events):
* events.c (vars_of_events):
`sans-modifiers' was defsymbol'ed more than once. Move it to
events-stream.c. `self-insert-command' was defsymbol'ed more than once.
Vevent_resource should be staticpro_nodump()ed as it's declared in
a reinit_*() method.
* lread.c (vars_of_lread):
Vfile_domain wasn't staticpro'ed.
* minibuf.c:
* minibuf.c (reinit_complex_vars_of_minibuf):
Vminibuffer_zero and Vecho_area_buffer weren't staticpro'ed.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Fri, 12 Mar 2010 20:23:50 -0600 |
parents | 79564cbad5f3 |
children | e5380fdaf8f1 |
rev | line source |
---|---|
428 | 1 /* Events: printing them, converting them to and from characters. |
2 Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. | |
3 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. | |
5046 | 4 Copyright (C) 2001, 2002, 2005, 2010 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 | |
25 /* This file has been Mule-ized. */ | |
26 | |
27 #include <config.h> | |
28 #include "lisp.h" | |
29 #include "buffer.h" | |
30 #include "console.h" | |
31 #include "device.h" | |
788 | 32 #include "extents.h" |
428 | 33 #include "events.h" |
872 | 34 #include "frame-impl.h" |
428 | 35 #include "glyphs.h" |
36 #include "keymap.h" /* for key_desc_list_to_event() */ | |
788 | 37 #include "lstream.h" |
428 | 38 #include "redisplay.h" |
800 | 39 #include "toolbar.h" |
428 | 40 #include "window.h" |
41 | |
872 | 42 #include "console-tty-impl.h" /* for stuff in character_to_event */ |
800 | 43 |
428 | 44 /* Where old events go when they are explicitly deallocated. |
45 The event chain here is cut loose before GC, so these will be freed | |
46 eventually. | |
47 */ | |
48 static Lisp_Object Vevent_resource; | |
49 | |
50 Lisp_Object Qeventp; | |
51 Lisp_Object Qevent_live_p; | |
52 Lisp_Object Qkey_press_event_p; | |
53 Lisp_Object Qbutton_event_p; | |
54 Lisp_Object Qmouse_event_p; | |
55 Lisp_Object Qprocess_event_p; | |
56 | |
57 Lisp_Object Qkey_press, Qbutton_press, Qbutton_release, Qmisc_user; | |
2828 | 58 Lisp_Object Qcharacter_of_keysym, Qascii_character; |
428 | 59 |
771 | 60 |
61 /************************************************************************/ | |
62 /* definition of event object */ | |
63 /************************************************************************/ | |
428 | 64 |
65 /* #### Ad-hoc hack. Should be part of define_lrecord_implementation */ | |
66 void | |
67 clear_event_resource (void) | |
68 { | |
69 Vevent_resource = Qnil; | |
70 } | |
71 | |
934 | 72 /* Make sure we lose quickly if we try to use this event */ |
73 static void | |
74 deinitialize_event (Lisp_Object ev) | |
75 { | |
76 Lisp_Event *event = XEVENT (ev); | |
3063 | 77 int i; |
78 /* Preserve the old UID for this event, for tracking it */ | |
79 unsigned int old_uid = event->lheader.uid; | |
934 | 80 |
1204 | 81 for (i = 0; i < (int) (sizeof (Lisp_Event) / sizeof (int)); i++) |
82 ((int *) event) [i] = 0xdeadbeef; /* -559038737 base 10 */ | |
83 set_lheader_implementation (&event->lheader, &lrecord_event); | |
3063 | 84 event->lheader.uid = old_uid; |
934 | 85 set_event_type (event, dead_event); |
86 SET_EVENT_CHANNEL (event, Qnil); | |
428 | 87 XSET_EVENT_NEXT (ev, Qnil); |
88 } | |
89 | |
90 /* Set everything to zero or nil so that it's predictable. */ | |
91 void | |
440 | 92 zero_event (Lisp_Event *e) |
428 | 93 { |
3063 | 94 /* Preserve the old UID for this event, for tracking it */ |
95 unsigned int old_uid = e->lheader.uid; | |
96 | |
428 | 97 xzero (*e); |
442 | 98 set_lheader_implementation (&e->lheader, &lrecord_event); |
3063 | 99 e->lheader.uid = old_uid; |
1204 | 100 set_event_type (e, empty_event); |
101 SET_EVENT_CHANNEL (e, Qnil); | |
102 SET_EVENT_NEXT (e, Qnil); | |
428 | 103 } |
104 | |
1204 | 105 static const struct memory_description key_data_description_1 [] = { |
106 { XD_LISP_OBJECT, offsetof (struct Lisp_Key_Data, keysym) }, | |
107 { XD_END } | |
108 }; | |
109 | |
110 static const struct sized_memory_description key_data_description = { | |
111 sizeof (Lisp_Key_Data), key_data_description_1 | |
112 }; | |
113 | |
114 static const struct memory_description button_data_description_1 [] = { | |
115 { XD_END } | |
116 }; | |
117 | |
118 static const struct sized_memory_description button_data_description = { | |
119 sizeof (Lisp_Button_Data), button_data_description_1 | |
120 }; | |
121 | |
122 static const struct memory_description motion_data_description_1 [] = { | |
123 { XD_END } | |
124 }; | |
125 | |
126 static const struct sized_memory_description motion_data_description = { | |
127 sizeof (Lisp_Motion_Data), motion_data_description_1 | |
128 }; | |
129 | |
130 static const struct memory_description process_data_description_1 [] = { | |
131 { XD_LISP_OBJECT, offsetof (struct Lisp_Process_Data, process) }, | |
132 { XD_END } | |
133 }; | |
134 | |
135 static const struct sized_memory_description process_data_description = { | |
136 sizeof (Lisp_Process_Data), process_data_description_1 | |
137 }; | |
138 | |
139 static const struct memory_description timeout_data_description_1 [] = { | |
140 { XD_LISP_OBJECT, offsetof (struct Lisp_Timeout_Data, function) }, | |
141 { XD_LISP_OBJECT, offsetof (struct Lisp_Timeout_Data, object) }, | |
142 { XD_END } | |
143 }; | |
144 | |
145 static const struct sized_memory_description timeout_data_description = { | |
146 sizeof (Lisp_Timeout_Data), timeout_data_description_1 | |
147 }; | |
148 | |
149 static const struct memory_description eval_data_description_1 [] = { | |
150 { XD_LISP_OBJECT, offsetof (struct Lisp_Eval_Data, function) }, | |
151 { XD_LISP_OBJECT, offsetof (struct Lisp_Eval_Data, object) }, | |
152 { XD_END } | |
153 }; | |
154 | |
155 static const struct sized_memory_description eval_data_description = { | |
156 sizeof (Lisp_Eval_Data), eval_data_description_1 | |
157 }; | |
158 | |
159 static const struct memory_description misc_user_data_description_1 [] = { | |
160 { XD_LISP_OBJECT, offsetof (struct Lisp_Misc_User_Data, function) }, | |
161 { XD_LISP_OBJECT, offsetof (struct Lisp_Misc_User_Data, object) }, | |
162 { XD_END } | |
163 }; | |
164 | |
165 static const struct sized_memory_description misc_user_data_description = { | |
166 sizeof (Lisp_Misc_User_Data), misc_user_data_description_1 | |
167 }; | |
168 | |
169 static const struct memory_description magic_eval_data_description_1 [] = { | |
170 { XD_LISP_OBJECT, offsetof (struct Lisp_Magic_Eval_Data, object) }, | |
171 { XD_END } | |
172 }; | |
173 | |
174 static const struct sized_memory_description magic_eval_data_description = { | |
175 sizeof (Lisp_Magic_Eval_Data), magic_eval_data_description_1 | |
176 }; | |
177 | |
178 static const struct memory_description magic_data_description_1 [] = { | |
179 { XD_END } | |
180 }; | |
181 | |
182 static const struct sized_memory_description magic_data_description = { | |
183 sizeof (Lisp_Magic_Data), magic_data_description_1 | |
184 }; | |
185 | |
186 static const struct memory_description event_data_description_1 [] = { | |
2551 | 187 { XD_BLOCK_ARRAY, key_press_event, 1, { &key_data_description } }, |
188 { XD_BLOCK_ARRAY, button_press_event, 1, { &button_data_description } }, | |
189 { XD_BLOCK_ARRAY, button_release_event, 1, { &button_data_description } }, | |
190 { XD_BLOCK_ARRAY, pointer_motion_event, 1, { &motion_data_description } }, | |
191 { XD_BLOCK_ARRAY, process_event, 1, { &process_data_description } }, | |
192 { XD_BLOCK_ARRAY, timeout_event, 1, { &timeout_data_description } }, | |
193 { XD_BLOCK_ARRAY, magic_event, 1, { &magic_data_description } }, | |
194 { XD_BLOCK_ARRAY, magic_eval_event, 1, { &magic_eval_data_description } }, | |
195 { XD_BLOCK_ARRAY, eval_event, 1, { &eval_data_description } }, | |
196 { XD_BLOCK_ARRAY, misc_user_event, 1, { &misc_user_data_description } }, | |
1204 | 197 { XD_END } |
198 }; | |
199 | |
200 static const struct sized_memory_description event_data_description = { | |
201 0, event_data_description_1 | |
202 }; | |
203 | |
204 static const struct memory_description event_description [] = { | |
205 { XD_INT, offsetof (struct Lisp_Event, event_type) }, | |
206 { XD_LISP_OBJECT, offsetof (struct Lisp_Event, next) }, | |
207 { XD_LISP_OBJECT, offsetof (struct Lisp_Event, channel) }, | |
208 { XD_UNION, offsetof (struct Lisp_Event, event), | |
2551 | 209 XD_INDIRECT (0, 0), { &event_data_description } }, |
1204 | 210 { XD_END } |
211 }; | |
212 | |
213 #ifdef EVENT_DATA_AS_OBJECTS | |
214 | |
215 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("key-data", key_data, | |
216 0, /*dumpable-flag*/ | |
217 0, 0, 0, 0, 0, | |
218 key_data_description, | |
219 Lisp_Key_Data); | |
220 | |
221 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("button-data", button_data, | |
222 0, /*dumpable-flag*/ | |
223 0, 0, 0, 0, 0, | |
224 button_data_description, | |
225 Lisp_Button_Data); | |
226 | |
227 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("motion-data", motion_data, | |
228 0, /*dumpable-flag*/ | |
229 0, 0, 0, 0, 0, | |
230 motion_data_description, | |
231 Lisp_Motion_Data); | |
232 | |
233 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("process-data", process_data, | |
234 0, /*dumpable-flag*/ | |
235 0, 0, 0, 0, 0, | |
236 process_data_description, | |
237 Lisp_Process_Data); | |
238 | |
239 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("timeout-data", timeout_data, | |
240 0, /*dumpable-flag*/ | |
241 0, 0, 0, 0, 0, | |
242 timeout_data_description, | |
243 Lisp_Timeout_Data); | |
244 | |
245 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("eval-data", eval_data, | |
246 0, /*dumpable-flag*/ | |
247 0, 0, 0, 0, 0, | |
248 eval_data_description, | |
249 Lisp_Eval_Data); | |
250 | |
251 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("misc-user-data", misc_user_data, | |
252 0, /*dumpable-flag*/ | |
253 0, 0, 0, 0, 0, | |
254 misc_user_data_description, | |
255 Lisp_Misc_User_Data); | |
256 | |
257 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("magic-eval-data", magic_eval_data, | |
258 0, /*dumpable-flag*/ | |
259 0, 0, 0, 0, 0, | |
260 magic_eval_data_description, | |
261 Lisp_Magic_Eval_Data); | |
262 | |
263 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("magic-data", magic_data, | |
264 0, /*dumpable-flag*/ | |
265 0, 0, 0, 0, 0, | |
266 magic_data_description, | |
267 Lisp_Magic_Data); | |
268 | |
269 #endif /* EVENT_DATA_AS_OBJECTS */ | |
270 | |
428 | 271 static Lisp_Object |
272 mark_event (Lisp_Object obj) | |
273 { | |
440 | 274 Lisp_Event *event = XEVENT (obj); |
428 | 275 |
276 switch (event->event_type) | |
277 { | |
278 case key_press_event: | |
1204 | 279 mark_object (EVENT_KEY_KEYSYM (event)); |
428 | 280 break; |
281 case process_event: | |
1204 | 282 mark_object (EVENT_PROCESS_PROCESS (event)); |
428 | 283 break; |
284 case timeout_event: | |
1204 | 285 mark_object (EVENT_TIMEOUT_FUNCTION (event)); |
286 mark_object (EVENT_TIMEOUT_OBJECT (event)); | |
428 | 287 break; |
288 case eval_event: | |
289 case misc_user_event: | |
1204 | 290 mark_object (EVENT_EVAL_FUNCTION (event)); |
291 mark_object (EVENT_EVAL_OBJECT (event)); | |
428 | 292 break; |
293 case magic_eval_event: | |
1204 | 294 mark_object (EVENT_MAGIC_EVAL_OBJECT (event)); |
428 | 295 break; |
296 case button_press_event: | |
297 case button_release_event: | |
298 case pointer_motion_event: | |
299 case magic_event: | |
300 case empty_event: | |
301 case dead_event: | |
302 break; | |
303 default: | |
2500 | 304 ABORT (); |
428 | 305 } |
306 mark_object (event->channel); | |
307 return event->next; | |
308 } | |
309 | |
310 static void | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4780
diff
changeset
|
311 print_event_1 (const Ascbyte *str, Lisp_Object obj, Lisp_Object printcharfun) |
428 | 312 { |
793 | 313 DECLARE_EISTRING_MALLOC (ei); |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4780
diff
changeset
|
314 write_ascstring (printcharfun, str); |
1204 | 315 format_event_object (ei, obj, 0); |
826 | 316 write_eistring (printcharfun, ei); |
793 | 317 eifree (ei); |
428 | 318 } |
319 | |
320 static void | |
2286 | 321 print_event (Lisp_Object obj, Lisp_Object printcharfun, |
322 int UNUSED (escapeflag)) | |
428 | 323 { |
324 if (print_readably) | |
563 | 325 printing_unreadable_object ("#<event>"); |
428 | 326 |
327 switch (XEVENT (obj)->event_type) | |
328 { | |
329 case key_press_event: | |
330 print_event_1 ("#<keypress-event ", obj, printcharfun); | |
331 break; | |
332 case button_press_event: | |
333 print_event_1 ("#<buttondown-event ", obj, printcharfun); | |
334 break; | |
335 case button_release_event: | |
336 print_event_1 ("#<buttonup-event ", obj, printcharfun); | |
337 break; | |
338 case magic_event: | |
339 case magic_eval_event: | |
340 print_event_1 ("#<magic-event ", obj, printcharfun); | |
341 break; | |
342 case pointer_motion_event: | |
343 { | |
344 Lisp_Object Vx, Vy; | |
345 Vx = Fevent_x_pixel (obj); | |
346 assert (INTP (Vx)); | |
347 Vy = Fevent_y_pixel (obj); | |
348 assert (INTP (Vy)); | |
793 | 349 write_fmt_string (printcharfun, "#<motion-event %ld, %ld", |
350 (long) XINT (Vx), (long) XINT (Vy)); | |
428 | 351 break; |
352 } | |
353 case process_event: | |
1204 | 354 write_fmt_string_lisp (printcharfun, "#<process-event %S", 1, |
355 XEVENT_PROCESS_PROCESS (obj)); | |
428 | 356 break; |
357 case timeout_event: | |
1204 | 358 write_fmt_string_lisp (printcharfun, "#<timeout-event %S", 1, |
359 XEVENT_TIMEOUT_OBJECT (obj)); | |
428 | 360 break; |
361 case empty_event: | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4780
diff
changeset
|
362 write_ascstring (printcharfun, "#<empty-event"); |
428 | 363 break; |
364 case misc_user_event: | |
1204 | 365 write_fmt_string_lisp (printcharfun, "#<misc-user-event (%S", 1, |
366 XEVENT_MISC_USER_FUNCTION (obj)); | |
367 write_fmt_string_lisp (printcharfun, " %S)", 1, | |
368 XEVENT_MISC_USER_OBJECT (obj)); | |
428 | 369 break; |
370 case eval_event: | |
1204 | 371 write_fmt_string_lisp (printcharfun, "#<eval-event (%S", 1, |
372 XEVENT_EVAL_FUNCTION (obj)); | |
373 write_fmt_string_lisp (printcharfun, " %S)", 1, | |
374 XEVENT_EVAL_OBJECT (obj)); | |
428 | 375 break; |
376 case dead_event: | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4780
diff
changeset
|
377 write_ascstring (printcharfun, "#<DEALLOCATED-EVENT"); |
428 | 378 break; |
379 default: | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4780
diff
changeset
|
380 write_ascstring (printcharfun, "#<UNKNOWN-EVENT-TYPE"); |
428 | 381 break; |
382 } | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4780
diff
changeset
|
383 write_ascstring (printcharfun, ">"); |
428 | 384 } |
385 | |
386 static int | |
4906
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4780
diff
changeset
|
387 event_equal (Lisp_Object obj1, Lisp_Object obj2, int UNUSED (depth), |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4780
diff
changeset
|
388 int UNUSED (foldcase)) |
428 | 389 { |
440 | 390 Lisp_Event *e1 = XEVENT (obj1); |
391 Lisp_Event *e2 = XEVENT (obj2); | |
428 | 392 |
393 if (e1->event_type != e2->event_type) return 0; | |
394 if (!EQ (e1->channel, e2->channel)) return 0; | |
395 /* if (e1->timestamp != e2->timestamp) return 0; */ | |
396 switch (e1->event_type) | |
397 { | |
2500 | 398 default: ABORT (); |
428 | 399 |
400 case process_event: | |
1204 | 401 return EQ (EVENT_PROCESS_PROCESS (e1), EVENT_PROCESS_PROCESS (e2)); |
428 | 402 |
403 case timeout_event: | |
1204 | 404 return (internal_equal (EVENT_TIMEOUT_FUNCTION (e1), |
405 EVENT_TIMEOUT_FUNCTION (e2), 0) && | |
406 internal_equal (EVENT_TIMEOUT_OBJECT (e1), | |
407 EVENT_TIMEOUT_OBJECT (e2), 0)); | |
428 | 408 |
409 case key_press_event: | |
1204 | 410 return (EQ (EVENT_KEY_KEYSYM (e1), EVENT_KEY_KEYSYM (e2)) && |
411 (EVENT_KEY_MODIFIERS (e1) == EVENT_KEY_MODIFIERS (e2))); | |
428 | 412 |
413 case button_press_event: | |
414 case button_release_event: | |
1204 | 415 return (EVENT_BUTTON_BUTTON (e1) == EVENT_BUTTON_BUTTON (e2) && |
416 EVENT_BUTTON_MODIFIERS (e1) == EVENT_BUTTON_MODIFIERS (e2)); | |
428 | 417 |
418 case pointer_motion_event: | |
1204 | 419 return (EVENT_MOTION_X (e1) == EVENT_MOTION_X (e2) && |
420 EVENT_MOTION_Y (e1) == EVENT_MOTION_Y (e2)); | |
428 | 421 |
422 case misc_user_event: | |
1204 | 423 return (internal_equal (EVENT_EVAL_FUNCTION (e1), |
424 EVENT_EVAL_FUNCTION (e2), 0) && | |
425 internal_equal (EVENT_EVAL_OBJECT (e1), | |
426 EVENT_EVAL_OBJECT (e2), 0) && | |
427 /* #### is this really needed for equality | |
428 | 428 or is x and y also important? */ |
1204 | 429 EVENT_MISC_USER_BUTTON (e1) == EVENT_MISC_USER_BUTTON (e2) && |
430 EVENT_MISC_USER_MODIFIERS (e1) == EVENT_MISC_USER_MODIFIERS (e2)); | |
428 | 431 |
432 case eval_event: | |
1204 | 433 return (internal_equal (EVENT_EVAL_FUNCTION (e1), |
434 EVENT_EVAL_FUNCTION (e2), 0) && | |
435 internal_equal (EVENT_EVAL_OBJECT (e1), | |
436 EVENT_EVAL_OBJECT (e2), 0)); | |
428 | 437 |
438 case magic_eval_event: | |
1204 | 439 return (EVENT_MAGIC_EVAL_INTERNAL_FUNCTION (e1) == |
440 EVENT_MAGIC_EVAL_INTERNAL_FUNCTION (e2) && | |
441 internal_equal (EVENT_MAGIC_EVAL_OBJECT (e1), | |
442 EVENT_MAGIC_EVAL_OBJECT (e2), 0)); | |
428 | 443 |
444 case magic_event: | |
788 | 445 return event_stream_compare_magic_event (e1, e2); |
428 | 446 |
447 case empty_event: /* Empty and deallocated events are equal. */ | |
448 case dead_event: | |
449 return 1; | |
450 } | |
451 } | |
452 | |
665 | 453 static Hashcode |
428 | 454 event_hash (Lisp_Object obj, int depth) |
455 { | |
440 | 456 Lisp_Event *e = XEVENT (obj); |
665 | 457 Hashcode hash; |
428 | 458 |
459 hash = HASH2 (e->event_type, LISP_HASH (e->channel)); | |
460 switch (e->event_type) | |
461 { | |
462 case process_event: | |
1204 | 463 return HASH2 (hash, LISP_HASH (EVENT_PROCESS_PROCESS (e))); |
428 | 464 |
465 case timeout_event: | |
1204 | 466 return HASH3 (hash, |
467 internal_hash (EVENT_TIMEOUT_FUNCTION (e), depth + 1), | |
468 internal_hash (EVENT_TIMEOUT_OBJECT (e), depth + 1)); | |
428 | 469 |
470 case key_press_event: | |
1204 | 471 return HASH3 (hash, LISP_HASH (EVENT_KEY_KEYSYM (e)), |
472 EVENT_KEY_MODIFIERS (e)); | |
428 | 473 |
474 case button_press_event: | |
475 case button_release_event: | |
1204 | 476 return HASH3 (hash, EVENT_BUTTON_BUTTON (e), EVENT_BUTTON_MODIFIERS (e)); |
428 | 477 |
478 case pointer_motion_event: | |
1204 | 479 return HASH3 (hash, EVENT_MOTION_X (e), EVENT_MOTION_Y (e)); |
428 | 480 |
481 case misc_user_event: | |
1204 | 482 return HASH5 (hash, |
483 internal_hash (EVENT_MISC_USER_FUNCTION (e), depth + 1), | |
484 internal_hash (EVENT_MISC_USER_OBJECT (e), depth + 1), | |
485 EVENT_MISC_USER_BUTTON (e), EVENT_MISC_USER_MODIFIERS (e)); | |
428 | 486 |
487 case eval_event: | |
1204 | 488 return HASH3 (hash, internal_hash (EVENT_EVAL_FUNCTION (e), depth + 1), |
489 internal_hash (EVENT_EVAL_OBJECT (e), depth + 1)); | |
428 | 490 |
491 case magic_eval_event: | |
492 return HASH3 (hash, | |
1204 | 493 (Hashcode) EVENT_MAGIC_EVAL_INTERNAL_FUNCTION (e), |
494 internal_hash (EVENT_MAGIC_EVAL_OBJECT (e), depth + 1)); | |
428 | 495 |
496 case magic_event: | |
788 | 497 return HASH2 (hash, event_stream_hash_magic_event (e)); |
428 | 498 |
499 case empty_event: | |
500 case dead_event: | |
501 return hash; | |
502 | |
503 default: | |
2500 | 504 ABORT (); |
428 | 505 } |
506 | |
507 return 0; /* unreached */ | |
508 } | |
934 | 509 |
510 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("event", event, | |
511 0, /*dumpable-flag*/ | |
512 mark_event, print_event, 0, event_equal, | |
1204 | 513 event_hash, event_description, |
514 Lisp_Event); | |
428 | 515 |
516 DEFUN ("make-event", Fmake_event, 0, 2, 0, /* | |
517 Return a new event of type TYPE, with properties described by PLIST. | |
518 | |
519 TYPE is a symbol, either `empty', `key-press', `button-press', | |
520 `button-release', `misc-user' or `motion'. If TYPE is nil, it | |
521 defaults to `empty'. | |
522 | |
523 PLIST is a property list, the properties being compatible to those | |
524 returned by `event-properties'. The following properties are | |
525 allowed: | |
526 | |
527 channel -- The event channel, a frame or a console. For | |
528 button-press, button-release, misc-user and motion events, | |
529 this must be a frame. For key-press events, it must be | |
530 a console. If channel is unspecified, it will be set to | |
531 the selected frame or selected console, as appropriate. | |
532 key -- The event key, a symbol or character. Allowed only for | |
533 keypress events. | |
534 button -- The event button, integer 1, 2 or 3. Allowed for | |
535 button-press, button-release and misc-user events. | |
536 modifiers -- The event modifiers, a list of modifier symbols. Allowed | |
537 for key-press, button-press, button-release, motion and | |
538 misc-user events. | |
539 function -- Function. Allowed for misc-user events only. | |
540 object -- An object, function's parameter. Allowed for misc-user | |
541 events only. | |
542 x -- The event X coordinate, an integer. This is relative | |
543 to the left of CHANNEL's root window. Allowed for | |
544 motion, button-press, button-release and misc-user events. | |
545 y -- The event Y coordinate, an integer. This is relative | |
546 to the top of CHANNEL's root window. Allowed for | |
547 motion, button-press, button-release and misc-user events. | |
548 timestamp -- The event timestamp, a non-negative integer. Allowed for | |
549 all types of events. If unspecified, it will be set to 0 | |
550 by default. | |
551 | |
552 For event type `empty', PLIST must be nil. | |
553 `button-release', or `motion'. If TYPE is left out, it defaults to | |
554 `empty'. | |
555 PLIST is a list of properties, as returned by `event-properties'. Not | |
556 all properties are allowed for all kinds of events, and some are | |
557 required. | |
558 | |
559 WARNING: the event object returned may be a reused one; see the function | |
560 `deallocate-event'. | |
561 */ | |
562 (type, plist)) | |
563 { | |
564 Lisp_Object event = Qnil; | |
440 | 565 Lisp_Event *e; |
428 | 566 EMACS_INT coord_x = 0, coord_y = 0; |
567 struct gcpro gcpro1; | |
568 | |
569 GCPRO1 (event); | |
570 | |
571 if (NILP (type)) | |
572 type = Qempty; | |
573 | |
574 if (!NILP (Vevent_resource)) | |
575 { | |
576 event = Vevent_resource; | |
577 Vevent_resource = XEVENT_NEXT (event); | |
578 } | |
579 else | |
580 { | |
581 event = allocate_event (); | |
582 } | |
583 e = XEVENT (event); | |
584 zero_event (e); | |
585 | |
586 if (EQ (type, Qempty)) | |
587 { | |
588 /* For empty event, we return immediately, without processing | |
589 PLIST. In fact, processing PLIST would be wrong, because the | |
590 sanitizing process would fill in the properties | |
591 (e.g. CHANNEL), which we don't want in empty events. */ | |
934 | 592 set_event_type (e, empty_event); |
428 | 593 if (!NILP (plist)) |
563 | 594 invalid_operation ("Cannot set properties of empty event", plist); |
428 | 595 UNGCPRO; |
596 return event; | |
597 } | |
598 else if (EQ (type, Qkey_press)) | |
599 { | |
934 | 600 set_event_type (e, key_press_event); |
1204 | 601 SET_EVENT_KEY_KEYSYM (e, Qunbound); |
428 | 602 } |
603 else if (EQ (type, Qbutton_press)) | |
934 | 604 set_event_type (e, button_press_event); |
428 | 605 else if (EQ (type, Qbutton_release)) |
934 | 606 set_event_type (e, button_release_event); |
428 | 607 else if (EQ (type, Qmotion)) |
934 | 608 set_event_type (e, pointer_motion_event); |
428 | 609 else if (EQ (type, Qmisc_user)) |
610 { | |
934 | 611 set_event_type (e, misc_user_event); |
1204 | 612 SET_EVENT_MISC_USER_FUNCTION (e, Qnil); |
613 SET_EVENT_MISC_USER_OBJECT (e, Qnil); | |
428 | 614 } |
615 else | |
616 { | |
617 /* Not allowed: Qprocess, Qtimeout, Qmagic, Qeval, Qmagic_eval. */ | |
563 | 618 invalid_constant ("Invalid event type", type); |
428 | 619 } |
620 | |
621 EVENT_CHANNEL (e) = Qnil; | |
622 | |
623 plist = Fcopy_sequence (plist); | |
624 Fcanonicalize_plist (plist, Qnil); | |
625 | |
442 | 626 #define WRONG_EVENT_TYPE_FOR_PROPERTY(event_type, prop) \ |
563 | 627 invalid_argument_2 ("Invalid property for event type", prop, event_type) |
428 | 628 |
442 | 629 { |
630 EXTERNAL_PROPERTY_LIST_LOOP_3 (keyword, value, plist) | |
631 { | |
632 if (EQ (keyword, Qchannel)) | |
633 { | |
1204 | 634 if (EVENT_TYPE (e) == key_press_event) |
442 | 635 { |
636 if (!CONSOLEP (value)) | |
637 value = wrong_type_argument (Qconsolep, value); | |
638 } | |
639 else | |
640 { | |
641 if (!FRAMEP (value)) | |
642 value = wrong_type_argument (Qframep, value); | |
643 } | |
644 EVENT_CHANNEL (e) = value; | |
645 } | |
646 else if (EQ (keyword, Qkey)) | |
647 { | |
1204 | 648 switch (EVENT_TYPE (e)) |
442 | 649 { |
650 case key_press_event: | |
651 if (!SYMBOLP (value) && !CHARP (value)) | |
563 | 652 invalid_argument ("Invalid event key", value); |
1204 | 653 SET_EVENT_KEY_KEYSYM (e, value); |
442 | 654 break; |
655 default: | |
656 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword); | |
657 break; | |
658 } | |
659 } | |
660 else if (EQ (keyword, Qbutton)) | |
661 { | |
662 CHECK_NATNUM (value); | |
663 check_int_range (XINT (value), 0, 7); | |
428 | 664 |
1204 | 665 switch (EVENT_TYPE (e)) |
442 | 666 { |
667 case button_press_event: | |
668 case button_release_event: | |
1204 | 669 SET_EVENT_BUTTON_BUTTON (e, XINT (value)); |
442 | 670 break; |
671 case misc_user_event: | |
1204 | 672 SET_EVENT_MISC_USER_BUTTON (e, XINT (value)); |
442 | 673 break; |
674 default: | |
675 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword); | |
676 break; | |
677 } | |
678 } | |
679 else if (EQ (keyword, Qmodifiers)) | |
680 { | |
681 int modifiers = 0; | |
428 | 682 |
442 | 683 EXTERNAL_LIST_LOOP_2 (sym, value) |
684 { | |
685 if (EQ (sym, Qcontrol)) modifiers |= XEMACS_MOD_CONTROL; | |
686 else if (EQ (sym, Qmeta)) modifiers |= XEMACS_MOD_META; | |
687 else if (EQ (sym, Qsuper)) modifiers |= XEMACS_MOD_SUPER; | |
688 else if (EQ (sym, Qhyper)) modifiers |= XEMACS_MOD_HYPER; | |
689 else if (EQ (sym, Qalt)) modifiers |= XEMACS_MOD_ALT; | |
690 else if (EQ (sym, Qsymbol)) modifiers |= XEMACS_MOD_ALT; | |
691 else if (EQ (sym, Qshift)) modifiers |= XEMACS_MOD_SHIFT; | |
692 else if (EQ (sym, Qbutton1)) modifiers |= XEMACS_MOD_BUTTON1; | |
693 else if (EQ (sym, Qbutton2)) modifiers |= XEMACS_MOD_BUTTON2; | |
694 else if (EQ (sym, Qbutton3)) modifiers |= XEMACS_MOD_BUTTON3; | |
695 else if (EQ (sym, Qbutton4)) modifiers |= XEMACS_MOD_BUTTON4; | |
696 else if (EQ (sym, Qbutton5)) modifiers |= XEMACS_MOD_BUTTON5; | |
697 else | |
563 | 698 invalid_constant ("Invalid key modifier", sym); |
442 | 699 } |
428 | 700 |
1204 | 701 switch (EVENT_TYPE (e)) |
442 | 702 { |
703 case key_press_event: | |
1204 | 704 SET_EVENT_KEY_MODIFIERS (e, modifiers); |
442 | 705 break; |
706 case button_press_event: | |
707 case button_release_event: | |
1204 | 708 SET_EVENT_BUTTON_MODIFIERS (e, modifiers); |
442 | 709 break; |
710 case pointer_motion_event: | |
1204 | 711 SET_EVENT_MOTION_MODIFIERS (e, modifiers); |
442 | 712 break; |
713 case misc_user_event: | |
1204 | 714 SET_EVENT_MISC_USER_MODIFIERS (e, modifiers); |
442 | 715 break; |
716 default: | |
717 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword); | |
718 break; | |
719 } | |
720 } | |
721 else if (EQ (keyword, Qx)) | |
722 { | |
1204 | 723 switch (EVENT_TYPE (e)) |
442 | 724 { |
725 case pointer_motion_event: | |
726 case button_press_event: | |
727 case button_release_event: | |
728 case misc_user_event: | |
729 /* Allow negative values, so we can specify toolbar | |
730 positions. */ | |
731 CHECK_INT (value); | |
732 coord_x = XINT (value); | |
733 break; | |
734 default: | |
735 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword); | |
736 break; | |
737 } | |
738 } | |
739 else if (EQ (keyword, Qy)) | |
740 { | |
1204 | 741 switch (EVENT_TYPE (e)) |
442 | 742 { |
743 case pointer_motion_event: | |
744 case button_press_event: | |
745 case button_release_event: | |
746 case misc_user_event: | |
747 /* Allow negative values; see above. */ | |
748 CHECK_INT (value); | |
749 coord_y = XINT (value); | |
750 break; | |
751 default: | |
752 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword); | |
753 break; | |
754 } | |
755 } | |
756 else if (EQ (keyword, Qtimestamp)) | |
757 { | |
758 CHECK_NATNUM (value); | |
934 | 759 SET_EVENT_TIMESTAMP (e, XINT (value)); |
442 | 760 } |
761 else if (EQ (keyword, Qfunction)) | |
762 { | |
1204 | 763 switch (EVENT_TYPE (e)) |
442 | 764 { |
765 case misc_user_event: | |
1204 | 766 SET_EVENT_MISC_USER_FUNCTION (e, value); |
442 | 767 break; |
768 default: | |
769 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword); | |
770 break; | |
771 } | |
772 } | |
773 else if (EQ (keyword, Qobject)) | |
774 { | |
1204 | 775 switch (EVENT_TYPE (e)) |
442 | 776 { |
777 case misc_user_event: | |
1204 | 778 SET_EVENT_MISC_USER_OBJECT (e, value); |
442 | 779 break; |
780 default: | |
781 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword); | |
782 break; | |
783 } | |
784 } | |
785 else | |
563 | 786 invalid_constant_2 ("Invalid property", keyword, value); |
442 | 787 } |
788 } | |
428 | 789 |
790 /* Insert the channel, if missing. */ | |
791 if (NILP (EVENT_CHANNEL (e))) | |
792 { | |
934 | 793 if (EVENT_TYPE (e) == key_press_event) |
428 | 794 EVENT_CHANNEL (e) = Vselected_console; |
795 else | |
796 EVENT_CHANNEL (e) = Fselected_frame (Qnil); | |
797 } | |
798 | |
799 /* Fevent_properties, Fevent_x_pixel, etc. work with pixels relative | |
800 to the frame, so we must adjust accordingly. */ | |
801 if (FRAMEP (EVENT_CHANNEL (e))) | |
802 { | |
803 coord_x += FRAME_REAL_LEFT_TOOLBAR_WIDTH (XFRAME (EVENT_CHANNEL (e))); | |
804 coord_y += FRAME_REAL_TOP_TOOLBAR_HEIGHT (XFRAME (EVENT_CHANNEL (e))); | |
805 | |
806 switch (e->event_type) | |
807 { | |
808 case pointer_motion_event: | |
1204 | 809 SET_EVENT_MOTION_X (e, coord_x); |
810 SET_EVENT_MOTION_Y (e, coord_y); | |
428 | 811 break; |
812 case button_press_event: | |
813 case button_release_event: | |
1204 | 814 SET_EVENT_BUTTON_X (e, coord_x); |
815 SET_EVENT_BUTTON_Y (e, coord_y); | |
428 | 816 break; |
817 case misc_user_event: | |
1204 | 818 SET_EVENT_MISC_USER_X (e, coord_x); |
819 SET_EVENT_MISC_USER_Y (e, coord_y); | |
428 | 820 break; |
821 default: | |
2500 | 822 ABORT (); |
428 | 823 } |
824 } | |
825 | |
826 /* Finally, do some more validation. */ | |
1204 | 827 switch (EVENT_TYPE (e)) |
428 | 828 { |
829 case key_press_event: | |
1204 | 830 if (UNBOUNDP (EVENT_KEY_KEYSYM (e))) |
563 | 831 sferror ("A key must be specified to make a keypress event", |
442 | 832 plist); |
428 | 833 break; |
834 case button_press_event: | |
1204 | 835 if (!EVENT_BUTTON_BUTTON (e)) |
563 | 836 sferror |
442 | 837 ("A button must be specified to make a button-press event", |
838 plist); | |
428 | 839 break; |
840 case button_release_event: | |
1204 | 841 if (!EVENT_BUTTON_BUTTON (e)) |
563 | 842 sferror |
442 | 843 ("A button must be specified to make a button-release event", |
844 plist); | |
428 | 845 break; |
846 case misc_user_event: | |
1204 | 847 if (NILP (EVENT_MISC_USER_FUNCTION (e))) |
563 | 848 sferror ("A function must be specified to make a misc-user event", |
442 | 849 plist); |
428 | 850 break; |
851 default: | |
852 break; | |
853 } | |
854 | |
855 UNGCPRO; | |
856 return event; | |
857 } | |
858 | |
859 DEFUN ("deallocate-event", Fdeallocate_event, 1, 1, 0, /* | |
860 Allow the given event structure to be reused. | |
861 You MUST NOT use this event object after calling this function with it. | |
862 You will lose. It is not necessary to call this function, as event | |
863 objects are garbage-collected like all other objects; however, it may | |
864 be more efficient to explicitly deallocate events when you are sure | |
865 that it is safe to do so. | |
866 */ | |
867 (event)) | |
868 { | |
869 CHECK_EVENT (event); | |
870 | |
871 if (XEVENT_TYPE (event) == dead_event) | |
563 | 872 invalid_argument ("this event is already deallocated!", Qunbound); |
428 | 873 |
874 assert (XEVENT_TYPE (event) <= last_event_type); | |
875 | |
876 #if 0 | |
877 { | |
878 int i, len; | |
879 | |
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
880 assert (!(EQ (event, Vlast_command_event) || |
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
881 EQ (event, Vlast_input_event) || |
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
882 EQ (event, Vunread_command_event))); |
428 | 883 |
884 len = XVECTOR_LENGTH (Vthis_command_keys); | |
885 for (i = 0; i < len; i++) | |
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
886 assert (!EQ (event, XVECTOR_DATA (Vthis_command_keys) [i])); |
428 | 887 if (!NILP (Vrecent_keys_ring)) |
888 { | |
889 int recent_ring_len = XVECTOR_LENGTH (Vrecent_keys_ring); | |
890 for (i = 0; i < recent_ring_len; i++) | |
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
891 assert (!EQ (event, XVECTOR_DATA (Vrecent_keys_ring) [i])); |
428 | 892 } |
893 } | |
894 #endif /* 0 */ | |
895 | |
896 assert (!EQ (event, Vevent_resource)); | |
897 deinitialize_event (event); | |
898 #ifndef ALLOC_NO_POOLS | |
899 XSET_EVENT_NEXT (event, Vevent_resource); | |
900 Vevent_resource = event; | |
901 #endif | |
902 return Qnil; | |
903 } | |
904 | |
905 DEFUN ("copy-event", Fcopy_event, 1, 2, 0, /* | |
444 | 906 Make a copy of the event object EVENT1. |
907 If a second event argument EVENT2 is given, EVENT1 is copied into | |
908 EVENT2 and EVENT2 is returned. If EVENT2 is not supplied (or is nil) | |
909 then a new event will be made as with `make-event'. See also the | |
910 function `deallocate-event'. | |
428 | 911 */ |
912 (event1, event2)) | |
913 { | |
914 CHECK_LIVE_EVENT (event1); | |
915 if (NILP (event2)) | |
916 event2 = Fmake_event (Qnil, Qnil); | |
430 | 917 else |
918 { | |
919 CHECK_LIVE_EVENT (event2); | |
920 if (EQ (event1, event2)) | |
563 | 921 return signal_continuable_error_2 |
922 (Qinvalid_argument, | |
923 "copy-event called with `eq' events", event1, event2); | |
430 | 924 } |
428 | 925 |
926 assert (XEVENT_TYPE (event1) <= last_event_type); | |
927 assert (XEVENT_TYPE (event2) <= last_event_type); | |
928 | |
934 | 929 XSET_EVENT_TYPE (event2, XEVENT_TYPE (event1)); |
930 XSET_EVENT_CHANNEL (event2, XEVENT_CHANNEL (event1)); | |
931 XSET_EVENT_TIMESTAMP (event2, XEVENT_TIMESTAMP (event1)); | |
1204 | 932 |
933 #ifdef EVENT_DATA_AS_OBJECTS | |
934 copy_lisp_object (XEVENT_DATA (event2), XEVENT_DATA (event1)); | |
935 #else | |
936 XEVENT (event2)->event = XEVENT (event1)->event; | |
937 #endif | |
934 | 938 return event2; |
428 | 939 } |
940 | |
941 | |
771 | 942 /************************************************************************/ |
943 /* event chain functions */ | |
944 /************************************************************************/ | |
428 | 945 |
946 /* Given a chain of events (or possibly nil), deallocate them all. */ | |
947 | |
948 void | |
949 deallocate_event_chain (Lisp_Object event_chain) | |
950 { | |
951 while (!NILP (event_chain)) | |
952 { | |
953 Lisp_Object next = XEVENT_NEXT (event_chain); | |
954 Fdeallocate_event (event_chain); | |
955 event_chain = next; | |
956 } | |
957 } | |
958 | |
959 /* Return the last event in a chain. | |
960 NOTE: You cannot pass nil as a value here! The routine will | |
961 abort if you do. */ | |
962 | |
963 Lisp_Object | |
964 event_chain_tail (Lisp_Object event_chain) | |
965 { | |
966 while (1) | |
967 { | |
968 Lisp_Object next = XEVENT_NEXT (event_chain); | |
969 if (NILP (next)) | |
970 return event_chain; | |
971 event_chain = next; | |
972 } | |
973 } | |
974 | |
975 /* Enqueue a single event onto the end of a chain of events. | |
976 HEAD points to the first event in the chain, TAIL to the last event. | |
977 If the chain is empty, both values should be nil. */ | |
978 | |
979 void | |
980 enqueue_event (Lisp_Object event, Lisp_Object *head, Lisp_Object *tail) | |
981 { | |
982 assert (NILP (XEVENT_NEXT (event))); | |
983 assert (!EQ (*tail, event)); | |
984 | |
985 if (!NILP (*tail)) | |
986 XSET_EVENT_NEXT (*tail, event); | |
987 else | |
988 *head = event; | |
989 *tail = event; | |
990 | |
991 assert (!EQ (event, XEVENT_NEXT (event))); | |
992 } | |
993 | |
994 /* Remove an event off the head of a chain of events and return it. | |
995 HEAD points to the first event in the chain, TAIL to the last event. */ | |
996 | |
997 Lisp_Object | |
998 dequeue_event (Lisp_Object *head, Lisp_Object *tail) | |
999 { | |
1000 Lisp_Object event; | |
1001 | |
1002 event = *head; | |
1003 *head = XEVENT_NEXT (event); | |
1004 XSET_EVENT_NEXT (event, Qnil); | |
1005 if (NILP (*head)) | |
1006 *tail = Qnil; | |
1007 return event; | |
1008 } | |
1009 | |
1010 /* Enqueue a chain of events (or possibly nil) onto the end of another | |
1011 chain of events. HEAD points to the first event in the chain being | |
1012 queued onto, TAIL to the last event. If the chain is empty, both values | |
1013 should be nil. */ | |
1014 | |
1015 void | |
1016 enqueue_event_chain (Lisp_Object event_chain, Lisp_Object *head, | |
1017 Lisp_Object *tail) | |
1018 { | |
1019 if (NILP (event_chain)) | |
1020 return; | |
1021 | |
1022 if (NILP (*head)) | |
1023 { | |
1024 *head = event_chain; | |
1025 *tail = event_chain; | |
1026 } | |
1027 else | |
1028 { | |
1029 XSET_EVENT_NEXT (*tail, event_chain); | |
1030 *tail = event_chain_tail (event_chain); | |
1031 } | |
1032 } | |
1033 | |
1204 | 1034 /* Map a function over each event in the chain. If the function returns |
1035 non-zero, remove the event just processed. Return the total number of | |
1036 items removed. | |
1037 | |
1038 NOTE: | |
1039 | |
1040 If you want a simple mapping over an event chain, with no intention to | |
1041 add or remove items, just use EVENT_CHAIN_LOOP(). | |
1042 */ | |
1043 | |
1044 int | |
1045 map_event_chain_remove (int (*fn) (Lisp_Object ev, void *user_data), | |
1046 Lisp_Object *head, Lisp_Object *tail, | |
1047 void *user_data, int flags) | |
1048 { | |
1049 Lisp_Object event; | |
1050 Lisp_Object previous_event = Qnil; | |
1051 int count = 0; | |
1052 | |
1053 EVENT_CHAIN_LOOP (event, *head) | |
1054 { | |
1055 if (fn (event, user_data)) | |
1056 { | |
1057 if (NILP (previous_event)) | |
1058 dequeue_event (head, tail); | |
1059 else | |
1060 { | |
1061 XSET_EVENT_NEXT (previous_event, XEVENT_NEXT (event)); | |
1062 if (EQ (*tail, event)) | |
1063 *tail = previous_event; | |
1064 } | |
1065 | |
1066 if (flags & MECR_DEALLOCATE_EVENT) | |
1067 Fdeallocate_event (event); | |
1068 count++; | |
1069 } | |
1070 else | |
1071 previous_event = event; | |
1072 } | |
1073 return count; | |
1074 } | |
1075 | |
428 | 1076 /* Return the number of events (possibly 0) on an event chain. */ |
1077 | |
1078 int | |
1079 event_chain_count (Lisp_Object event_chain) | |
1080 { | |
1081 Lisp_Object event; | |
1082 int n = 0; | |
1083 | |
1084 EVENT_CHAIN_LOOP (event, event_chain) | |
1085 n++; | |
1086 | |
1087 return n; | |
1088 } | |
1089 | |
1090 /* Find the event before EVENT in an event chain. This aborts | |
1091 if the event is not in the chain. */ | |
1092 | |
1093 Lisp_Object | |
1094 event_chain_find_previous (Lisp_Object event_chain, Lisp_Object event) | |
1095 { | |
1096 Lisp_Object previous = Qnil; | |
1097 | |
1098 while (!NILP (event_chain)) | |
1099 { | |
1100 if (EQ (event_chain, event)) | |
1101 return previous; | |
1102 previous = event_chain; | |
1103 event_chain = XEVENT_NEXT (event_chain); | |
1104 } | |
1105 | |
2500 | 1106 ABORT (); |
428 | 1107 return Qnil; |
1108 } | |
1109 | |
1110 Lisp_Object | |
1111 event_chain_nth (Lisp_Object event_chain, int n) | |
1112 { | |
1113 Lisp_Object event; | |
1114 EVENT_CHAIN_LOOP (event, event_chain) | |
1115 { | |
1116 if (!n) | |
1117 return event; | |
1118 n--; | |
1119 } | |
1120 return Qnil; | |
1121 } | |
1122 | |
771 | 1123 /* Return a freshly allocated copy of all events in the given chain. */ |
1124 | |
428 | 1125 Lisp_Object |
1126 copy_event_chain (Lisp_Object event_chain) | |
1127 { | |
1128 Lisp_Object new_chain = Qnil; | |
1129 Lisp_Object new_chain_tail = Qnil; | |
1130 Lisp_Object event; | |
1131 | |
1132 EVENT_CHAIN_LOOP (event, event_chain) | |
1133 { | |
1134 Lisp_Object copy = Fcopy_event (event, Qnil); | |
1135 enqueue_event (copy, &new_chain, &new_chain_tail); | |
1136 } | |
1137 | |
1138 return new_chain; | |
1139 } | |
1140 | |
771 | 1141 /* Given a pointer (maybe nil) into an old chain (also maybe nil, if |
1142 pointer is nil) and a new chain which is a copy of the old, return | |
1143 the corresponding new pointer. */ | |
1144 Lisp_Object | |
1145 transfer_event_chain_pointer (Lisp_Object pointer, Lisp_Object old_chain, | |
1146 Lisp_Object new_chain) | |
1147 { | |
1148 if (NILP (pointer)) | |
1149 return Qnil; | |
1150 assert (!NILP (old_chain)); | |
800 | 1151 #ifdef ERROR_CHECK_STRUCTURES |
771 | 1152 /* make sure we're actually in the chain */ |
1153 event_chain_find_previous (old_chain, pointer); | |
1154 assert (event_chain_count (old_chain) == event_chain_count (new_chain)); | |
800 | 1155 #endif /* ERROR_CHECK_STRUCTURES */ |
771 | 1156 return event_chain_nth (new_chain, |
1157 event_chain_count (old_chain) - | |
1158 event_chain_count (pointer)); | |
1159 } | |
1160 | |
428 | 1161 |
771 | 1162 /************************************************************************/ |
1163 /* higher level functions */ | |
1164 /************************************************************************/ | |
428 | 1165 |
1166 Lisp_Object QKbackspace, QKtab, QKlinefeed, QKreturn, QKescape, | |
1167 QKspace, QKdelete; | |
1168 | |
1169 int | |
1170 command_event_p (Lisp_Object event) | |
1171 { | |
1172 switch (XEVENT_TYPE (event)) | |
1173 { | |
1174 case key_press_event: | |
1175 case button_press_event: | |
1176 case button_release_event: | |
1177 case misc_user_event: | |
1178 return 1; | |
1179 default: | |
1180 return 0; | |
1181 } | |
1182 } | |
1183 | |
4780
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1184 /* META_BEHAVIOR can be one of the following values, defined in events.h: |
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1185 |
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1186 high_bit_is_meta |
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1187 use_console_meta_flag |
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1188 latin_1_maps_to_itself |
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1189 |
1204 | 1190 DO_BACKSPACE_MAPPING means that if CON is a TTY, and C is a the TTY's |
1191 backspace character, the event will have keysym `backspace' instead of | |
1192 '(control h). It is clearly correct to do this conversion is the | |
1193 character was just read from a TTY, clearly incorrect inside of | |
1194 define-key, which must be able to handle all consoles. #### What about | |
1195 in other circumstances? #### Should the user have access to this flag? | |
1196 | |
1197 #### We need to go through and review all the flags in | |
1198 character_to_event() and event_to_character() and figure out exactly | |
1199 under what circumstances they should or should not be set, then go | |
1200 through and review all callers of character_to_event(), | |
1201 Fcharacter_to_event(), event_to_character(), and Fevent_to_character() | |
1202 and check that they are passing the correct flags in for their varied | |
1203 circumstances. | |
1204 | |
1205 #### Some of this garbage, and some of the flags, could go away if we | |
1206 implemented the suggestion, originally from event-Xt.c: | |
1207 | |
2828 | 1208 [[ The way that keysym correspondence to characters should work: |
1204 | 1209 - a Lisp_Event should contain a keysym AND a character slot. |
1210 - keybindings are tried with the keysym. If no binding can be found, | |
2828 | 1211 and there is a corresponding character, call self-insert-command. ]] |
1212 | |
1213 That's an X-specific way of thinking. All the other platforms--even | |
1214 the TTY, make sure you've done (set-input-mode t nil 1) and set your | |
1215 console coding system appropriately when checking--just use | |
1216 characters as emacs keysyms, and, together with defaulting to | |
1217 self-insert-command if an unbound key with a character correspondence | |
1218 is typed, that works fine for them. (Yes, this ignores GTK.) | |
1219 | |
1220 [[ [... snipping other suggestions which I've implemented.] | |
1221 Nuke the Qascii_character property. ]] | |
1204 | 1222 |
2828 | 1223 Well, we've renamed it anyway--it was badly named. |
1224 Qcharacter_of_keysym, here we go. It's really only with X11 that how | |
1225 to map between adiaeresis and (int-to-char #xE4), or ellipsis and | |
1226 whatever, becomes an issue, and IMO the property approach to this is | |
1227 fine. Aidan Kehoe, 2005-05-15. | |
1204 | 1228 |
2828 | 1229 [[ This would apparently solve a lot of different problems. ]] |
1230 | |
1231 I'd be interested to know what's left. Removing the allow-meta | |
1232 argument from event-to-character would be a Good Thing, IMO, but | |
1233 beyond that, I'm not sure what else there is to do wrt. key | |
1234 mappings. Of course, feedback from users of the Russian C-x facility | |
1235 is still needed. */ | |
428 | 1236 |
1237 void | |
867 | 1238 character_to_event (Ichar c, Lisp_Event *event, struct console *con, |
4780
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1239 character_to_event_meta_behavior meta_behavior, |
2340 | 1240 int USED_IF_TTY (do_backspace_mapping)) |
428 | 1241 { |
1242 Lisp_Object k = Qnil; | |
442 | 1243 int m = 0; |
934 | 1244 if (EVENT_TYPE (event) == dead_event) |
563 | 1245 invalid_argument ("character-to-event called with a deallocated event!", Qunbound); |
428 | 1246 |
1247 #ifndef MULE | |
1248 c &= 255; | |
1249 #endif | |
4780
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1250 if (meta_behavior != latin_1_maps_to_itself && c > 127 && c <= 255) |
428 | 1251 { |
1252 int meta_flag = 1; | |
4780
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1253 if (meta_behavior == use_console_meta_flag && CONSOLE_TTY_P (con)) |
428 | 1254 meta_flag = TTY_FLAGS (con).meta_key; |
1255 switch (meta_flag) | |
1256 { | |
1257 case 0: /* ignore top bit; it's parity */ | |
1258 c -= 128; | |
1259 break; | |
1260 case 1: /* top bit is meta */ | |
1261 c -= 128; | |
442 | 1262 m = XEMACS_MOD_META; |
428 | 1263 break; |
1264 default: /* this is a real character */ | |
1265 break; | |
1266 } | |
1267 } | |
442 | 1268 if (c < ' ') c += '@', m |= XEMACS_MOD_CONTROL; |
1269 if (m & XEMACS_MOD_CONTROL) | |
428 | 1270 { |
1271 switch (c) | |
1272 { | |
442 | 1273 case 'I': k = QKtab; m &= ~XEMACS_MOD_CONTROL; break; |
1274 case 'J': k = QKlinefeed; m &= ~XEMACS_MOD_CONTROL; break; | |
1275 case 'M': k = QKreturn; m &= ~XEMACS_MOD_CONTROL; break; | |
1276 case '[': k = QKescape; m &= ~XEMACS_MOD_CONTROL; break; | |
428 | 1277 default: |
1204 | 1278 #if defined (HAVE_TTY) |
428 | 1279 if (do_backspace_mapping && |
1280 CHARP (con->tty_erase_char) && | |
1281 c - '@' == XCHAR (con->tty_erase_char)) | |
1282 { | |
1283 k = QKbackspace; | |
442 | 1284 m &= ~XEMACS_MOD_CONTROL; |
428 | 1285 } |
1204 | 1286 #endif /* defined (HAVE_TTY) */ |
428 | 1287 break; |
1288 } | |
1289 if (c >= 'A' && c <= 'Z') c -= 'A'-'a'; | |
1290 } | |
1204 | 1291 #if defined (HAVE_TTY) |
428 | 1292 else if (do_backspace_mapping && |
1293 CHARP (con->tty_erase_char) && c == XCHAR (con->tty_erase_char)) | |
1294 k = QKbackspace; | |
1204 | 1295 #endif /* defined (HAVE_TTY) */ |
428 | 1296 else if (c == 127) |
1297 k = QKdelete; | |
1298 else if (c == ' ') | |
1299 k = QKspace; | |
1300 | |
934 | 1301 set_event_type (event, key_press_event); |
1302 SET_EVENT_TIMESTAMP_ZERO (event); /* #### */ | |
1303 SET_EVENT_CHANNEL (event, wrap_console (con)); | |
1204 | 1304 SET_EVENT_KEY_KEYSYM (event, (!NILP (k) ? k : make_char (c))); |
1305 SET_EVENT_KEY_MODIFIERS (event, m); | |
428 | 1306 } |
1307 | |
867 | 1308 Ichar |
1204 | 1309 event_to_character (Lisp_Object event, |
428 | 1310 int allow_extra_modifiers, |
2828 | 1311 int allow_meta) |
428 | 1312 { |
867 | 1313 Ichar c = 0; |
428 | 1314 Lisp_Object code; |
1315 | |
1204 | 1316 if (XEVENT_TYPE (event) != key_press_event) |
428 | 1317 { |
1204 | 1318 assert (XEVENT_TYPE (event) != dead_event); |
428 | 1319 return -1; |
1320 } | |
1321 if (!allow_extra_modifiers && | |
2828 | 1322 XEVENT_KEY_MODIFIERS (event) & |
1323 (XEMACS_MOD_SUPER|XEMACS_MOD_HYPER|XEMACS_MOD_ALT)) | |
428 | 1324 return -1; |
1204 | 1325 if (CHAR_OR_CHAR_INTP (XEVENT_KEY_KEYSYM (event))) |
1326 c = XCHAR_OR_CHAR_INT (XEVENT_KEY_KEYSYM (event)); | |
1327 else if (!SYMBOLP (XEVENT_KEY_KEYSYM (event))) | |
2500 | 1328 ABORT (); |
1204 | 1329 else if (CHAR_OR_CHAR_INTP (code = Fget (XEVENT_KEY_KEYSYM (event), |
2828 | 1330 Qcharacter_of_keysym, Qnil))) |
428 | 1331 c = XCHAR_OR_CHAR_INT (code); |
1332 else | |
2828 | 1333 { |
1334 Lisp_Object thekeysym = XEVENT_KEY_KEYSYM (event); | |
1335 | |
1336 if (CHAR_OR_CHAR_INTP (code = Fget (thekeysym, Qascii_character, Qnil))) | |
1337 { | |
1338 c = XCHAR_OR_CHAR_INT (code); | |
1339 warn_when_safe(Qkey_mapping, Qwarning, | |
1340 "Obsolete key binding technique.\n" | |
428 | 1341 |
2828 | 1342 "Some code you're using bound %s to `self-insert-command' and messed around\n" |
1343 "with its `ascii-character' property. Doing this is deprecated, and the code\n" | |
1344 "should be updated to use the `set-character-of-keysym' interface.\n" | |
1345 "If you're the one updating the code, first check if there's still a need\n" | |
1346 "for it; we support many more X11 keysyms out of the box now than we did\n" | |
1347 "in the past. ", XSTRING_DATA(XSYMBOL_NAME(thekeysym))); | |
1348 /* Only show the warning once for each keysym. */ | |
1349 Fput(thekeysym, Qcharacter_of_keysym, code); | |
1350 } | |
1351 else | |
1352 { | |
1353 return -1; | |
1354 } | |
1355 } | |
1204 | 1356 if (XEVENT_KEY_MODIFIERS (event) & XEMACS_MOD_CONTROL) |
428 | 1357 { |
1358 if (c >= 'a' && c <= 'z') | |
1359 c -= ('a' - 'A'); | |
1360 else | |
1361 /* reject Control-Shift- keys */ | |
1362 if (c >= 'A' && c <= 'Z' && !allow_extra_modifiers) | |
1363 return -1; | |
1364 | |
1365 if (c >= '@' && c <= '_') | |
1366 c -= '@'; | |
1367 else if (c == ' ') /* C-space and C-@ are the same. */ | |
1368 c = 0; | |
1369 else | |
1370 /* reject keys that can't take Control- modifiers */ | |
1371 if (! allow_extra_modifiers) return -1; | |
1372 } | |
1373 | |
1204 | 1374 if (XEVENT_KEY_MODIFIERS (event) & XEMACS_MOD_META) |
428 | 1375 { |
1376 if (! allow_meta) return -1; | |
1204 | 1377 if (c >= 128) return -1; /* don't allow M-oslash (overlap) */ |
428 | 1378 c |= 0200; |
1379 } | |
1380 return c; | |
1381 } | |
1382 | |
2862 | 1383 DEFUN ("event-to-character", Fevent_to_character, 1, 4, 0, /* |
2828 | 1384 Return the closest character approximation to the given event object. |
428 | 1385 If the event isn't a keypress, this returns nil. |
1386 If the ALLOW-EXTRA-MODIFIERS argument is non-nil, then this is lenient in | |
1387 its translation; it will ignore modifier keys other than control and meta, | |
1388 and will ignore the shift modifier on those characters which have no | |
1389 shifted ASCII equivalent (Control-Shift-A for example, will be mapped to | |
1390 the same ASCII code as Control-A). | |
1391 If the ALLOW-META argument is non-nil, then the Meta modifier will be | |
1392 represented by turning on the high bit of the byte returned; otherwise, nil | |
1393 will be returned for events containing the Meta modifier. | |
1204 | 1394 Note that ALLOW-META may cause ambiguity between meta characters and |
1395 Latin-1 characters. | |
2862 | 1396 ALLOW-NON-ASCII is unused, and retained for compatibility. |
428 | 1397 */ |
2862 | 1398 (event, allow_extra_modifiers, allow_meta, UNUSED(allow_non_ascii))) |
428 | 1399 { |
867 | 1400 Ichar c; |
428 | 1401 CHECK_LIVE_EVENT (event); |
1204 | 1402 c = event_to_character (event, |
428 | 1403 !NILP (allow_extra_modifiers), |
2828 | 1404 !NILP (allow_meta)); |
428 | 1405 return c < 0 ? Qnil : make_char (c); |
1406 } | |
1407 | |
1408 DEFUN ("character-to-event", Fcharacter_to_event, 1, 4, 0, /* | |
444 | 1409 Convert KEY-DESCRIPTION into an event structure, replete with bucky bits. |
428 | 1410 |
444 | 1411 KEY-DESCRIPTION is the first argument, and the event to fill in is the |
1412 second. This function contains knowledge about what various kinds of | |
1413 arguments ``mean'' -- for example, the number 9 is converted to the | |
1414 character ``Tab'', not the distinct character ``Control-I''. | |
428 | 1415 |
3025 | 1416 KEY-DESCRIPTION can be an integer, a character, a symbol such as `clear', |
444 | 1417 or a list such as '(control backspace). |
1418 | |
1419 If the optional second argument EVENT is an event, it is modified and | |
1420 returned; otherwise, a new event object is created and returned. | |
428 | 1421 |
1422 Optional third arg CONSOLE is the console to store in the event, and | |
1423 defaults to the selected console. | |
1424 | |
444 | 1425 If KEY-DESCRIPTION is an integer or character, the high bit may be |
1204 | 1426 interpreted as the meta key. (This is done for backward compatibility in |
1427 lots of places -- specifically, because lots of Lisp code uses specs like | |
1428 ?\M-d and "\M-d" in key code, expecting this to work; yet these are in | |
1429 reality converted directly to 8-bit characters by the Lisp reader.) If | |
1430 USE-CONSOLE-META-FLAG is nil or CONSOLE is not a TTY, this will always be | |
1431 the case. If USE-CONSOLE-META-FLAG is non-nil and CONSOLE is a TTY, the | |
1432 `meta' flag for CONSOLE affects whether the high bit is interpreted as a | |
1433 meta key. (See `set-input-mode'.) Don't set this flag to non-nil unless | |
1434 you know what you're doing (more specifically, only if the character came | |
1435 directly from a TTY, not from the user). If you don't want this silly meta | |
1436 interpretation done, you should pass in a list containing the character. | |
428 | 1437 |
1438 Beware that character-to-event and event-to-character are not strictly | |
1439 inverse functions, since events contain much more information than the | |
444 | 1440 Lisp character object type can encode. |
428 | 1441 */ |
4780
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1442 (keystroke, event, console, use_console_meta_flag_)) |
428 | 1443 { |
1444 struct console *con = decode_console (console); | |
1445 if (NILP (event)) | |
1446 event = Fmake_event (Qnil, Qnil); | |
1447 else | |
1448 CHECK_LIVE_EVENT (event); | |
444 | 1449 if (CONSP (keystroke) || SYMBOLP (keystroke)) |
1450 key_desc_list_to_event (keystroke, event, 1); | |
428 | 1451 else |
1452 { | |
444 | 1453 CHECK_CHAR_COERCE_INT (keystroke); |
1454 character_to_event (XCHAR (keystroke), XEVENT (event), con, | |
4780
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1455 (NILP (use_console_meta_flag_) ? |
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1456 high_bit_is_meta : use_console_meta_flag), 1); |
428 | 1457 } |
1458 return event; | |
1459 } | |
1460 | |
1461 void | |
1462 nth_of_key_sequence_as_event (Lisp_Object seq, int n, Lisp_Object event) | |
1463 { | |
1464 assert (STRINGP (seq) || VECTORP (seq)); | |
1465 assert (n < XINT (Flength (seq))); | |
1466 | |
1467 if (STRINGP (seq)) | |
1468 { | |
867 | 1469 Ichar ch = string_ichar (seq, n); |
428 | 1470 Fcharacter_to_event (make_char (ch), event, Qnil, Qnil); |
1471 } | |
1472 else | |
1473 { | |
1474 Lisp_Object keystroke = XVECTOR_DATA (seq)[n]; | |
1475 if (EVENTP (keystroke)) | |
1476 Fcopy_event (keystroke, event); | |
1477 else | |
1478 Fcharacter_to_event (keystroke, event, Qnil, Qnil); | |
1479 } | |
1480 } | |
1481 | |
1482 Lisp_Object | |
1483 key_sequence_to_event_chain (Lisp_Object seq) | |
1484 { | |
1485 int len = XINT (Flength (seq)); | |
1486 int i; | |
1487 Lisp_Object head = Qnil, tail = Qnil; | |
1488 | |
1489 for (i = 0; i < len; i++) | |
1490 { | |
1491 Lisp_Object event = Fmake_event (Qnil, Qnil); | |
1492 nth_of_key_sequence_as_event (seq, i, event); | |
1493 enqueue_event (event, &head, &tail); | |
1494 } | |
1495 | |
1496 return head; | |
1497 } | |
1498 | |
934 | 1499 |
793 | 1500 /* Concatenate a string description of EVENT onto the end of BUF. If |
1501 BRIEF, use short forms for keys, e.g. C- instead of control-. */ | |
1502 | |
934 | 1503 void |
1504 format_event_object (Eistring *buf, Lisp_Object event, int brief) | |
428 | 1505 { |
1506 int mouse_p = 0; | |
1507 int mod = 0; | |
1508 Lisp_Object key; | |
1509 | |
1204 | 1510 switch (XEVENT_TYPE (event)) |
428 | 1511 { |
1512 case key_press_event: | |
1513 { | |
1204 | 1514 mod = XEVENT_KEY_MODIFIERS (event); |
1515 key = XEVENT_KEY_KEYSYM (event); | |
428 | 1516 /* Hack. */ |
1517 if (! brief && CHARP (key) && | |
793 | 1518 mod & (XEMACS_MOD_CONTROL | XEMACS_MOD_META | XEMACS_MOD_SUPER | |
1519 XEMACS_MOD_HYPER)) | |
428 | 1520 { |
1521 int k = XCHAR (key); | |
1522 if (k >= 'a' && k <= 'z') | |
1523 key = make_char (k - ('a' - 'A')); | |
1524 else if (k >= 'A' && k <= 'Z') | |
442 | 1525 mod |= XEMACS_MOD_SHIFT; |
428 | 1526 } |
1527 break; | |
1528 } | |
1529 case button_release_event: | |
1530 mouse_p++; | |
1531 /* Fall through */ | |
1532 case button_press_event: | |
1533 { | |
1534 mouse_p++; | |
1204 | 1535 mod = XEVENT_BUTTON_MODIFIERS (event); |
1536 key = make_char (XEVENT_BUTTON_BUTTON (event) + '0'); | |
428 | 1537 break; |
1538 } | |
1539 case magic_event: | |
1540 { | |
788 | 1541 Lisp_Object stream; |
1542 struct gcpro gcpro1; | |
1543 GCPRO1 (stream); | |
428 | 1544 |
788 | 1545 stream = make_resizing_buffer_output_stream (); |
1204 | 1546 event_stream_format_magic_event (XEVENT (event), stream); |
788 | 1547 Lstream_flush (XLSTREAM (stream)); |
793 | 1548 eicat_raw (buf, resizing_buffer_stream_ptr (XLSTREAM (stream)), |
1549 Lstream_byte_count (XLSTREAM (stream))); | |
788 | 1550 Lstream_delete (XLSTREAM (stream)); |
1551 UNGCPRO; | |
428 | 1552 return; |
1553 } | |
2421 | 1554 case magic_eval_event: eicat_ascii (buf, "magic-eval"); return; |
1555 case pointer_motion_event: eicat_ascii (buf, "motion"); return; | |
1556 case misc_user_event: eicat_ascii (buf, "misc-user"); return; | |
1557 case eval_event: eicat_ascii (buf, "eval"); return; | |
1558 case process_event: eicat_ascii (buf, "process"); return; | |
1559 case timeout_event: eicat_ascii (buf, "timeout"); return; | |
1560 case empty_event: eicat_ascii (buf, "empty"); return; | |
1561 case dead_event: eicat_ascii (buf, "DEAD-EVENT"); return; | |
428 | 1562 default: |
2500 | 1563 ABORT (); |
442 | 1564 return; |
428 | 1565 } |
793 | 1566 #define modprint(x,y) \ |
2421 | 1567 do { if (brief) eicat_ascii (buf, (y)); else eicat_ascii (buf, (x)); } while (0) |
442 | 1568 if (mod & XEMACS_MOD_CONTROL) modprint ("control-", "C-"); |
1569 if (mod & XEMACS_MOD_META) modprint ("meta-", "M-"); | |
1570 if (mod & XEMACS_MOD_SUPER) modprint ("super-", "S-"); | |
1571 if (mod & XEMACS_MOD_HYPER) modprint ("hyper-", "H-"); | |
1572 if (mod & XEMACS_MOD_ALT) modprint ("alt-", "A-"); | |
1573 if (mod & XEMACS_MOD_SHIFT) modprint ("shift-", "Sh-"); | |
428 | 1574 if (mouse_p) |
1575 { | |
2421 | 1576 eicat_ascii (buf, "button"); |
428 | 1577 --mouse_p; |
1578 } | |
1579 | |
1580 #undef modprint | |
1581 | |
1582 if (CHARP (key)) | |
793 | 1583 eicat_ch (buf, XCHAR (key)); |
428 | 1584 else if (SYMBOLP (key)) |
1585 { | |
2367 | 1586 const Ascbyte *str = 0; |
428 | 1587 if (brief) |
1588 { | |
1589 if (EQ (key, QKlinefeed)) str = "LFD"; | |
1590 else if (EQ (key, QKtab)) str = "TAB"; | |
1591 else if (EQ (key, QKreturn)) str = "RET"; | |
1592 else if (EQ (key, QKescape)) str = "ESC"; | |
1593 else if (EQ (key, QKdelete)) str = "DEL"; | |
1594 else if (EQ (key, QKspace)) str = "SPC"; | |
1595 else if (EQ (key, QKbackspace)) str = "BS"; | |
1596 } | |
1597 if (str) | |
2421 | 1598 eicat_ascii (buf, str); |
428 | 1599 else |
793 | 1600 eicat_lstr (buf, XSYMBOL (key)->name); |
428 | 1601 } |
1602 else | |
2500 | 1603 ABORT (); |
428 | 1604 if (mouse_p) |
2421 | 1605 eicat_ascii (buf, "up"); |
428 | 1606 } |
1607 | |
1204 | 1608 void |
1609 upshift_event (Lisp_Object event) | |
1610 { | |
1611 Lisp_Object keysym = XEVENT_KEY_KEYSYM (event); | |
1612 Ichar c = 0; | |
1613 | |
1614 if (CHAR_OR_CHAR_INTP (keysym) | |
1615 && ((c = XCHAR_OR_CHAR_INT (keysym)), | |
1616 c >= 'a' && c <= 'z')) | |
1617 XSET_EVENT_KEY_KEYSYM (event, make_char (c + 'A' - 'a')); | |
1618 else | |
1619 if (!(XEVENT_KEY_MODIFIERS (event) & XEMACS_MOD_SHIFT)) | |
1620 XSET_EVENT_KEY_MODIFIERS | |
1621 (event, XEVENT_KEY_MODIFIERS (event) |= XEMACS_MOD_SHIFT); | |
1622 } | |
1623 | |
1624 void | |
1625 downshift_event (Lisp_Object event) | |
1626 { | |
1627 Lisp_Object keysym = XEVENT_KEY_KEYSYM (event); | |
1628 Ichar c = 0; | |
1629 | |
1630 if (XEVENT_KEY_MODIFIERS (event) & XEMACS_MOD_SHIFT) | |
1631 XSET_EVENT_KEY_MODIFIERS | |
1632 (event, XEVENT_KEY_MODIFIERS (event) & ~XEMACS_MOD_SHIFT); | |
1633 else if (CHAR_OR_CHAR_INTP (keysym) | |
1634 && ((c = XCHAR_OR_CHAR_INT (keysym)), | |
1635 c >= 'A' && c <= 'Z')) | |
1636 XSET_EVENT_KEY_KEYSYM (event, make_char (c + 'a' - 'A')); | |
1637 } | |
1638 | |
1639 int | |
1640 event_upshifted_p (Lisp_Object event) | |
1641 { | |
1642 Lisp_Object keysym = XEVENT_KEY_KEYSYM (event); | |
1643 Ichar c = 0; | |
1644 | |
1645 if ((XEVENT_KEY_MODIFIERS (event) & XEMACS_MOD_SHIFT) | |
1646 || (CHAR_OR_CHAR_INTP (keysym) | |
1647 && ((c = XCHAR_OR_CHAR_INT (keysym)), | |
1648 c >= 'A' && c <= 'Z'))) | |
1649 return 1; | |
1650 else | |
1651 return 0; | |
1652 } | |
934 | 1653 |
428 | 1654 DEFUN ("eventp", Feventp, 1, 1, 0, /* |
1655 True if OBJECT is an event object. | |
1656 */ | |
1657 (object)) | |
1658 { | |
1659 return EVENTP (object) ? Qt : Qnil; | |
1660 } | |
1661 | |
1662 DEFUN ("event-live-p", Fevent_live_p, 1, 1, 0, /* | |
1663 True if OBJECT is an event object that has not been deallocated. | |
1664 */ | |
1665 (object)) | |
1666 { | |
934 | 1667 return EVENTP (object) && XEVENT_TYPE (object) != dead_event ? |
1668 Qt : Qnil; | |
428 | 1669 } |
1670 | |
1671 #if 0 /* debugging functions */ | |
1672 | |
826 | 1673 DEFUN ("event-next", Fevent_next, 1, 1, 0, /* |
428 | 1674 Return the event object's `next' event, or nil if it has none. |
1675 The `next-event' field is changed by calling `set-next-event'. | |
1676 */ | |
1677 (event)) | |
1678 { | |
440 | 1679 Lisp_Event *e; |
428 | 1680 CHECK_LIVE_EVENT (event); |
1681 | |
1682 return XEVENT_NEXT (event); | |
1683 } | |
1684 | |
826 | 1685 DEFUN ("set-event-next", Fset_event_next, 2, 2, 0, /* |
428 | 1686 Set the `next event' of EVENT to NEXT-EVENT. |
1687 NEXT-EVENT must be an event object or nil. | |
1688 */ | |
1689 (event, next_event)) | |
1690 { | |
1691 Lisp_Object ev; | |
1692 | |
1693 CHECK_LIVE_EVENT (event); | |
1694 if (NILP (next_event)) | |
1695 { | |
1696 XSET_EVENT_NEXT (event, Qnil); | |
1697 return Qnil; | |
1698 } | |
1699 | |
1700 CHECK_LIVE_EVENT (next_event); | |
1701 | |
1702 EVENT_CHAIN_LOOP (ev, XEVENT_NEXT (event)) | |
1703 { | |
1704 QUIT; | |
1705 if (EQ (ev, event)) | |
563 | 1706 invalid_operation_2 ("Cyclic event-next", event, next_event); |
428 | 1707 } |
1708 XSET_EVENT_NEXT (event, next_event); | |
1709 return next_event; | |
1710 } | |
1711 | |
1712 #endif /* 0 */ | |
1713 | |
1714 DEFUN ("event-type", Fevent_type, 1, 1, 0, /* | |
1715 Return the type of EVENT. | |
1716 This will be a symbol; one of | |
1717 | |
1718 key-press A key was pressed. | |
1719 button-press A mouse button was pressed. | |
1720 button-release A mouse button was released. | |
1721 misc-user Some other user action happened; typically, this is | |
1722 a menu selection or scrollbar action. | |
1723 motion The mouse moved. | |
1724 process Input is available from a subprocess. | |
1725 timeout A timeout has expired. | |
1726 eval This causes a specified action to occur when dispatched. | |
1727 magic Some window-system-specific event has occurred. | |
1728 empty The event has been allocated but not assigned. | |
1729 | |
1730 */ | |
1731 (event)) | |
1732 { | |
1733 CHECK_LIVE_EVENT (event); | |
934 | 1734 switch (XEVENT_TYPE (event)) |
428 | 1735 { |
1736 case key_press_event: return Qkey_press; | |
1737 case button_press_event: return Qbutton_press; | |
1738 case button_release_event: return Qbutton_release; | |
1739 case misc_user_event: return Qmisc_user; | |
1740 case pointer_motion_event: return Qmotion; | |
1741 case process_event: return Qprocess; | |
1742 case timeout_event: return Qtimeout; | |
1743 case eval_event: return Qeval; | |
1744 case magic_event: | |
1745 case magic_eval_event: | |
1746 return Qmagic; | |
1747 | |
1748 case empty_event: | |
1749 return Qempty; | |
1750 | |
1751 default: | |
2500 | 1752 ABORT (); |
428 | 1753 return Qnil; |
1754 } | |
1755 } | |
1756 | |
1757 DEFUN ("event-timestamp", Fevent_timestamp, 1, 1, 0, /* | |
1758 Return the timestamp of the event object EVENT. | |
442 | 1759 Timestamps are measured in milliseconds since the start of the window system. |
1760 They are NOT related to any current time measurement. | |
1761 They should be compared with `event-timestamp<'. | |
1762 See also `current-event-timestamp'. | |
428 | 1763 */ |
1764 (event)) | |
1765 { | |
1766 CHECK_LIVE_EVENT (event); | |
1767 /* This junk is so that timestamps don't get to be negative, but contain | |
1768 as many bits as this particular emacs will allow. | |
1769 */ | |
2039 | 1770 return make_int (EMACS_INT_MAX & XEVENT_TIMESTAMP (event)); |
428 | 1771 } |
1772 | |
2039 | 1773 #define TIMESTAMP_HALFSPACE (1L << (INT_VALBITS - 2)) |
442 | 1774 |
1775 DEFUN ("event-timestamp<", Fevent_timestamp_lessp, 2, 2, 0, /* | |
1776 Return true if timestamp TIME1 is earlier than timestamp TIME2. | |
1777 This correctly handles timestamp wrap. | |
1778 See also `event-timestamp' and `current-event-timestamp'. | |
1779 */ | |
1780 (time1, time2)) | |
1781 { | |
1782 EMACS_INT t1, t2; | |
1783 | |
1784 CHECK_NATNUM (time1); | |
1785 CHECK_NATNUM (time2); | |
1786 t1 = XINT (time1); | |
1787 t2 = XINT (time2); | |
1788 | |
1789 if (t1 < t2) | |
1790 return t2 - t1 < TIMESTAMP_HALFSPACE ? Qt : Qnil; | |
1791 else | |
1792 return t1 - t2 < TIMESTAMP_HALFSPACE ? Qnil : Qt; | |
1793 } | |
1794 | |
934 | 1795 #define CHECK_EVENT_TYPE(e,t1,sym) do { \ |
1796 CHECK_LIVE_EVENT (e); \ | |
1797 if (XEVENT_TYPE (e) != (t1)) \ | |
1798 e = wrong_type_argument (sym,e); \ | |
1799 } while (0) | |
1800 | |
1801 #define CHECK_EVENT_TYPE2(e,t1,t2,sym) do { \ | |
1802 CHECK_LIVE_EVENT (e); \ | |
1803 { \ | |
1804 emacs_event_type CET_type = XEVENT_TYPE (e); \ | |
1805 if (CET_type != (t1) && \ | |
1806 CET_type != (t2)) \ | |
1807 e = wrong_type_argument (sym,e); \ | |
1808 } \ | |
1809 } while (0) | |
1810 | |
1811 #define CHECK_EVENT_TYPE3(e,t1,t2,t3,sym) do { \ | |
1812 CHECK_LIVE_EVENT (e); \ | |
1813 { \ | |
1814 emacs_event_type CET_type = XEVENT_TYPE (e); \ | |
1815 if (CET_type != (t1) && \ | |
1816 CET_type != (t2) && \ | |
1817 CET_type != (t3)) \ | |
1818 e = wrong_type_argument (sym,e); \ | |
1819 } \ | |
1820 } while (0) | |
428 | 1821 |
1822 DEFUN ("event-key", Fevent_key, 1, 1, 0, /* | |
1823 Return the Keysym of the key-press event EVENT. | |
1824 This will be a character if the event is associated with one, else a symbol. | |
1825 */ | |
1826 (event)) | |
1827 { | |
1828 CHECK_EVENT_TYPE (event, key_press_event, Qkey_press_event_p); | |
1204 | 1829 return XEVENT_KEY_KEYSYM (event); |
428 | 1830 } |
1831 | |
1832 DEFUN ("event-button", Fevent_button, 1, 1, 0, /* | |
444 | 1833 Return the button-number of the button-press or button-release event EVENT. |
428 | 1834 */ |
1835 (event)) | |
1836 { | |
1837 CHECK_EVENT_TYPE3 (event, button_press_event, button_release_event, | |
1838 misc_user_event, Qbutton_event_p); | |
1839 #ifdef HAVE_WINDOW_SYSTEM | |
1204 | 1840 if (XEVENT_TYPE (event) == misc_user_event) |
1841 return make_int (XEVENT_MISC_USER_BUTTON (event)); | |
934 | 1842 else |
1204 | 1843 return make_int (XEVENT_BUTTON_BUTTON (event)); |
428 | 1844 #else /* !HAVE_WINDOW_SYSTEM */ |
1845 return Qzero; | |
1846 #endif /* !HAVE_WINDOW_SYSTEM */ | |
1847 } | |
1848 | |
1849 DEFUN ("event-modifier-bits", Fevent_modifier_bits, 1, 1, 0, /* | |
442 | 1850 Return a number representing the modifier keys and buttons which were down |
428 | 1851 when the given mouse or keyboard event was produced. |
442 | 1852 See also the function `event-modifiers'. |
428 | 1853 */ |
1854 (event)) | |
1855 { | |
1856 again: | |
1857 CHECK_LIVE_EVENT (event); | |
934 | 1858 switch (XEVENT_TYPE (event)) |
1859 { | |
1860 case key_press_event: | |
1204 | 1861 return make_int (XEVENT_KEY_MODIFIERS (event)); |
934 | 1862 case button_press_event: |
1863 case button_release_event: | |
1204 | 1864 return make_int (XEVENT_BUTTON_MODIFIERS (event)); |
934 | 1865 case pointer_motion_event: |
1204 | 1866 return make_int (XEVENT_MOTION_MODIFIERS (event)); |
934 | 1867 case misc_user_event: |
1204 | 1868 return make_int (XEVENT_MISC_USER_MODIFIERS (event)); |
934 | 1869 default: |
1870 event = wrong_type_argument (intern ("key-or-mouse-event-p"), event); | |
1871 goto again; | |
1872 } | |
428 | 1873 } |
1874 | |
1875 DEFUN ("event-modifiers", Fevent_modifiers, 1, 1, 0, /* | |
442 | 1876 Return a list of symbols, the names of the modifier keys and buttons |
428 | 1877 which were down when the given mouse or keyboard event was produced. |
442 | 1878 See also the function `event-modifier-bits'. |
1879 | |
1880 The possible symbols in the list are | |
1881 | |
1882 `shift': The Shift key. Will not appear, in general, on key events | |
1883 where the keysym is an ASCII character, because using Shift | |
1884 on such a character converts it into another character rather | |
1885 than actually just adding a Shift modifier. | |
1886 | |
1887 `control': The Control key. | |
1888 | |
1889 `meta': The Meta key. On PC's and PC-style keyboards, this is generally | |
1890 labelled \"Alt\"; Meta is a holdover from early Lisp Machines and | |
1891 such, propagated through the X Window System. On Sun keyboards, | |
1892 this key is labelled with a diamond. | |
1893 | |
1894 `alt': The \"Alt\" key. Alt is in quotes because this does not refer | |
1895 to what it obviously should refer to, namely the Alt key on PC | |
1896 keyboards. Instead, it refers to the key labelled Alt on Sun | |
1897 keyboards, and to no key at all on PC keyboards. | |
1898 | |
1899 `super': The Super key. Most keyboards don't have any such key, but | |
1900 under X Windows using `xmodmap' you can assign any key (such as | |
1901 an underused right-shift, right-control, or right-alt key) to | |
1902 this key modifier. No support currently exists under MS Windows | |
1903 for generating these modifiers. | |
1904 | |
1905 `hyper': The Hyper key. Works just like the Super key. | |
1906 | |
1907 `button1': The mouse buttons. This means that the specified button was held | |
1908 `button2': down at the time the event occurred. NOTE: For button-press | |
1909 `button3': events, the button that was just pressed down does NOT appear in | |
1910 `button4': the modifiers. | |
1911 `button5': | |
1912 | |
1913 Button modifiers are currently ignored when defining and looking up key and | |
1914 mouse strokes in keymaps. This could be changed, which would allow a user to | |
1915 create button-chord actions, use a button as a key modifier and do other | |
1916 clever things. | |
428 | 1917 */ |
1918 (event)) | |
1919 { | |
1920 int mod = XINT (Fevent_modifier_bits (event)); | |
1921 Lisp_Object result = Qnil; | |
442 | 1922 struct gcpro gcpro1; |
1923 | |
1924 GCPRO1 (result); | |
1925 if (mod & XEMACS_MOD_SHIFT) result = Fcons (Qshift, result); | |
1926 if (mod & XEMACS_MOD_ALT) result = Fcons (Qalt, result); | |
1927 if (mod & XEMACS_MOD_HYPER) result = Fcons (Qhyper, result); | |
1928 if (mod & XEMACS_MOD_SUPER) result = Fcons (Qsuper, result); | |
1929 if (mod & XEMACS_MOD_META) result = Fcons (Qmeta, result); | |
1930 if (mod & XEMACS_MOD_CONTROL) result = Fcons (Qcontrol, result); | |
1931 if (mod & XEMACS_MOD_BUTTON1) result = Fcons (Qbutton1, result); | |
1932 if (mod & XEMACS_MOD_BUTTON2) result = Fcons (Qbutton2, result); | |
1933 if (mod & XEMACS_MOD_BUTTON3) result = Fcons (Qbutton3, result); | |
1934 if (mod & XEMACS_MOD_BUTTON4) result = Fcons (Qbutton4, result); | |
1935 if (mod & XEMACS_MOD_BUTTON5) result = Fcons (Qbutton5, result); | |
1936 RETURN_UNGCPRO (Fnreverse (result)); | |
428 | 1937 } |
1938 | |
1939 static int | |
1940 event_x_y_pixel_internal (Lisp_Object event, int *x, int *y, int relative) | |
1941 { | |
1942 struct window *w; | |
1943 struct frame *f; | |
1944 | |
934 | 1945 if (XEVENT_TYPE (event) == pointer_motion_event) |
1946 { | |
1204 | 1947 *x = XEVENT_MOTION_X (event); |
1948 *y = XEVENT_MOTION_Y (event); | |
934 | 1949 } |
1950 else if (XEVENT_TYPE (event) == button_press_event || | |
1951 XEVENT_TYPE (event) == button_release_event) | |
1952 { | |
1204 | 1953 *x = XEVENT_BUTTON_X (event); |
1954 *y = XEVENT_BUTTON_Y (event); | |
934 | 1955 } |
1956 else if (XEVENT_TYPE (event) == misc_user_event) | |
1957 { | |
1204 | 1958 *x = XEVENT_MISC_USER_X (event); |
1959 *y = XEVENT_MISC_USER_Y (event); | |
934 | 1960 } |
1961 else | |
1962 return 0; | |
428 | 1963 f = XFRAME (EVENT_CHANNEL (XEVENT (event))); |
1964 | |
1965 if (relative) | |
1966 { | |
1967 w = find_window_by_pixel_pos (*x, *y, f->root_window); | |
1968 | |
1969 if (!w) | |
442 | 1970 return 1; /* #### What should really happen here? */ |
428 | 1971 |
1972 *x -= w->pixel_left; | |
1973 *y -= w->pixel_top; | |
1974 } | |
1975 else | |
1976 { | |
1977 *y -= FRAME_REAL_TOP_TOOLBAR_HEIGHT (f) - | |
1978 FRAME_REAL_TOP_TOOLBAR_BORDER_WIDTH (f); | |
1979 *x -= FRAME_REAL_LEFT_TOOLBAR_WIDTH (f) - | |
1980 FRAME_REAL_LEFT_TOOLBAR_BORDER_WIDTH (f); | |
1981 } | |
1982 | |
1983 return 1; | |
1984 } | |
1985 | |
1986 DEFUN ("event-window-x-pixel", Fevent_window_x_pixel, 1, 1, 0, /* | |
1987 Return the X position in pixels of mouse event EVENT. | |
1988 The value returned is relative to the window the event occurred in. | |
1989 This will signal an error if the event is not a mouse event. | |
1990 See also `mouse-event-p' and `event-x-pixel'. | |
1991 */ | |
1992 (event)) | |
1993 { | |
1994 int x, y; | |
1995 | |
1996 CHECK_LIVE_EVENT (event); | |
1997 | |
1998 if (!event_x_y_pixel_internal (event, &x, &y, 1)) | |
1999 return wrong_type_argument (Qmouse_event_p, event); | |
2000 else | |
2001 return make_int (x); | |
2002 } | |
2003 | |
2004 DEFUN ("event-window-y-pixel", Fevent_window_y_pixel, 1, 1, 0, /* | |
2005 Return the Y position in pixels of mouse event EVENT. | |
2006 The value returned is relative to the window the event occurred in. | |
2007 This will signal an error if the event is not a mouse event. | |
2008 See also `mouse-event-p' and `event-y-pixel'. | |
2009 */ | |
2010 (event)) | |
2011 { | |
2012 int x, y; | |
2013 | |
2014 CHECK_LIVE_EVENT (event); | |
2015 | |
2016 if (!event_x_y_pixel_internal (event, &x, &y, 1)) | |
2017 return wrong_type_argument (Qmouse_event_p, event); | |
2018 else | |
2019 return make_int (y); | |
2020 } | |
2021 | |
2022 DEFUN ("event-x-pixel", Fevent_x_pixel, 1, 1, 0, /* | |
2023 Return the X position in pixels of mouse event EVENT. | |
2024 The value returned is relative to the frame the event occurred in. | |
2025 This will signal an error if the event is not a mouse event. | |
2026 See also `mouse-event-p' and `event-window-x-pixel'. | |
2027 */ | |
2028 (event)) | |
2029 { | |
2030 int x, y; | |
2031 | |
2032 CHECK_LIVE_EVENT (event); | |
2033 | |
2034 if (!event_x_y_pixel_internal (event, &x, &y, 0)) | |
2035 return wrong_type_argument (Qmouse_event_p, event); | |
2036 else | |
2037 return make_int (x); | |
2038 } | |
2039 | |
2040 DEFUN ("event-y-pixel", Fevent_y_pixel, 1, 1, 0, /* | |
2041 Return the Y position in pixels of mouse event EVENT. | |
2042 The value returned is relative to the frame the event occurred in. | |
2043 This will signal an error if the event is not a mouse event. | |
2044 See also `mouse-event-p' `event-window-y-pixel'. | |
2045 */ | |
2046 (event)) | |
2047 { | |
2048 int x, y; | |
2049 | |
2050 CHECK_LIVE_EVENT (event); | |
2051 | |
2052 if (!event_x_y_pixel_internal (event, &x, &y, 0)) | |
2053 return wrong_type_argument (Qmouse_event_p, event); | |
2054 else | |
2055 return make_int (y); | |
2056 } | |
2057 | |
2058 /* Given an event, return a value: | |
2059 | |
2060 OVER_TOOLBAR: over one of the 4 frame toolbars | |
2061 OVER_MODELINE: over a modeline | |
2062 OVER_BORDER: over an internal border | |
2063 OVER_NOTHING: over the text area, but not over text | |
2064 OVER_OUTSIDE: outside of the frame border | |
2065 OVER_TEXT: over text in the text area | |
2066 OVER_V_DIVIDER: over windows vertical divider | |
2067 | |
2068 and return: | |
2069 | |
2070 The X char position in CHAR_X, if not a null pointer. | |
2071 The Y char position in CHAR_Y, if not a null pointer. | |
2072 (These last two values are relative to the window the event is over.) | |
2073 The window it's over in W, if not a null pointer. | |
2074 The buffer position it's over in BUFP, if not a null pointer. | |
2075 The closest buffer position in CLOSEST, if not a null pointer. | |
2076 | |
2077 OBJ_X, OBJ_Y, OBJ1, and OBJ2 are as in pixel_to_glyph_translation(). | |
2078 */ | |
2079 | |
2080 static int | |
2081 event_pixel_translation (Lisp_Object event, int *char_x, int *char_y, | |
2082 int *obj_x, int *obj_y, | |
665 | 2083 struct window **w, Charbpos *bufp, Charbpos *closest, |
428 | 2084 Charcount *modeline_closest, |
2085 Lisp_Object *obj1, Lisp_Object *obj2) | |
2086 { | |
2087 int pix_x = 0; | |
2088 int pix_y = 0; | |
2089 int result; | |
2090 Lisp_Object frame; | |
2091 | |
2092 int ret_x, ret_y, ret_obj_x, ret_obj_y; | |
2093 struct window *ret_w; | |
665 | 2094 Charbpos ret_bufp, ret_closest; |
428 | 2095 Charcount ret_modeline_closest; |
2096 Lisp_Object ret_obj1, ret_obj2; | |
2097 | |
2098 CHECK_LIVE_EVENT (event); | |
934 | 2099 frame = XEVENT_CHANNEL (event); |
2100 switch (XEVENT_TYPE (event)) | |
2101 { | |
2102 case pointer_motion_event : | |
1204 | 2103 pix_x = XEVENT_MOTION_X (event); |
2104 pix_y = XEVENT_MOTION_Y (event); | |
934 | 2105 break; |
2106 case button_press_event : | |
2107 case button_release_event : | |
1204 | 2108 pix_x = XEVENT_BUTTON_X (event); |
2109 pix_y = XEVENT_BUTTON_Y (event); | |
934 | 2110 break; |
2111 case misc_user_event : | |
1204 | 2112 pix_x = XEVENT_MISC_USER_X (event); |
2113 pix_y = XEVENT_MISC_USER_Y (event); | |
934 | 2114 break; |
2115 default: | |
2116 dead_wrong_type_argument (Qmouse_event_p, event); | |
2117 } | |
428 | 2118 |
2119 result = pixel_to_glyph_translation (XFRAME (frame), pix_x, pix_y, | |
2120 &ret_x, &ret_y, &ret_obj_x, &ret_obj_y, | |
2121 &ret_w, &ret_bufp, &ret_closest, | |
2122 &ret_modeline_closest, | |
2123 &ret_obj1, &ret_obj2); | |
2124 | |
2125 if (result == OVER_NOTHING || result == OVER_OUTSIDE) | |
2126 ret_bufp = 0; | |
2127 else if (ret_w && NILP (ret_w->buffer)) | |
2128 /* Why does this happen? (Does it still happen?) | |
2129 I guess the window has gotten reused as a non-leaf... */ | |
2130 ret_w = 0; | |
2131 | |
2132 /* #### pixel_to_glyph_translation() sometimes returns garbage... | |
2133 The word has type Lisp_Type_Record (presumably meaning `extent') but the | |
2134 pointer points to random memory, often filled with 0, sometimes not. | |
2135 */ | |
2136 /* #### Chuck, do we still need this crap? */ | |
5055
79564cbad5f3
Simplify assertion in events.c so it will build under Visual Studio 6
Vin Shelton <acs@xemacs.org>
parents:
5052
diff
changeset
|
2137 #ifdef HAVE_TOOLBARS |
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
2138 assert (NILP (ret_obj1) || GLYPHP (ret_obj1) |
5055
79564cbad5f3
Simplify assertion in events.c so it will build under Visual Studio 6
Vin Shelton <acs@xemacs.org>
parents:
5052
diff
changeset
|
2139 || TOOLBAR_BUTTONP (ret_obj1)); |
79564cbad5f3
Simplify assertion in events.c so it will build under Visual Studio 6
Vin Shelton <acs@xemacs.org>
parents:
5052
diff
changeset
|
2140 #else |
79564cbad5f3
Simplify assertion in events.c so it will build under Visual Studio 6
Vin Shelton <acs@xemacs.org>
parents:
5052
diff
changeset
|
2141 assert (NILP (ret_obj1) || GLYPHP (ret_obj1)); |
428 | 2142 #endif |
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
2143 assert (NILP (ret_obj2) || EXTENTP (ret_obj2) || CONSP (ret_obj2)); |
428 | 2144 |
2145 if (char_x) | |
2146 *char_x = ret_x; | |
2147 if (char_y) | |
2148 *char_y = ret_y; | |
2149 if (obj_x) | |
2150 *obj_x = ret_obj_x; | |
2151 if (obj_y) | |
2152 *obj_y = ret_obj_y; | |
2153 if (w) | |
2154 *w = ret_w; | |
2155 if (bufp) | |
2156 *bufp = ret_bufp; | |
2157 if (closest) | |
2158 *closest = ret_closest; | |
2159 if (modeline_closest) | |
2160 *modeline_closest = ret_modeline_closest; | |
2161 if (obj1) | |
2162 *obj1 = ret_obj1; | |
2163 if (obj2) | |
2164 *obj2 = ret_obj2; | |
2165 | |
2166 return result; | |
2167 } | |
2168 | |
2169 DEFUN ("event-over-text-area-p", Fevent_over_text_area_p, 1, 1, 0, /* | |
2170 Return t if the mouse event EVENT occurred over the text area of a window. | |
2171 The modeline is not considered to be part of the text area. | |
2172 */ | |
2173 (event)) | |
2174 { | |
2175 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | |
2176 | |
2177 return result == OVER_TEXT || result == OVER_NOTHING ? Qt : Qnil; | |
2178 } | |
2179 | |
2180 DEFUN ("event-over-modeline-p", Fevent_over_modeline_p, 1, 1, 0, /* | |
2181 Return t if the mouse event EVENT occurred over the modeline of a window. | |
2182 */ | |
2183 (event)) | |
2184 { | |
2185 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | |
2186 | |
2187 return result == OVER_MODELINE ? Qt : Qnil; | |
2188 } | |
2189 | |
2190 DEFUN ("event-over-border-p", Fevent_over_border_p, 1, 1, 0, /* | |
2191 Return t if the mouse event EVENT occurred over an internal border. | |
2192 */ | |
2193 (event)) | |
2194 { | |
2195 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | |
2196 | |
2197 return result == OVER_BORDER ? Qt : Qnil; | |
2198 } | |
2199 | |
2200 DEFUN ("event-over-toolbar-p", Fevent_over_toolbar_p, 1, 1, 0, /* | |
2201 Return t if the mouse event EVENT occurred over a toolbar. | |
2202 */ | |
2203 (event)) | |
2204 { | |
2205 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | |
2206 | |
2207 return result == OVER_TOOLBAR ? Qt : Qnil; | |
2208 } | |
2209 | |
2210 DEFUN ("event-over-vertical-divider-p", Fevent_over_vertical_divider_p, 1, 1, 0, /* | |
2211 Return t if the mouse event EVENT occurred over a window divider. | |
2212 */ | |
2213 (event)) | |
2214 { | |
2215 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | |
2216 | |
2217 return result == OVER_V_DIVIDER ? Qt : Qnil; | |
2218 } | |
2219 | |
2220 struct console * | |
2221 event_console_or_selected (Lisp_Object event) | |
2222 { | |
2223 Lisp_Object channel = EVENT_CHANNEL (XEVENT (event)); | |
2224 Lisp_Object console = CDFW_CONSOLE (channel); | |
2225 | |
2226 if (NILP (console)) | |
2227 console = Vselected_console; | |
2228 | |
2229 return XCONSOLE (console); | |
2230 } | |
2231 | |
2232 DEFUN ("event-channel", Fevent_channel, 1, 1, 0, /* | |
2233 Return the channel that the event EVENT occurred on. | |
2234 This will be a frame, device, console, or nil for some types | |
2235 of events (e.g. eval events). | |
2236 */ | |
2237 (event)) | |
2238 { | |
2239 CHECK_LIVE_EVENT (event); | |
2240 return EVENT_CHANNEL (XEVENT (event)); | |
2241 } | |
2242 | |
2243 DEFUN ("event-window", Fevent_window, 1, 1, 0, /* | |
2244 Return the window over which mouse event EVENT occurred. | |
2245 This may be nil if the event occurred in the border or over a toolbar. | |
2246 The modeline is considered to be within the window it describes. | |
2247 */ | |
2248 (event)) | |
2249 { | |
2250 struct window *w; | |
2251 | |
2252 event_pixel_translation (event, 0, 0, 0, 0, &w, 0, 0, 0, 0, 0); | |
2253 | |
2254 if (!w) | |
2255 return Qnil; | |
2256 else | |
2257 { | |
793 | 2258 return wrap_window (w); |
428 | 2259 } |
2260 } | |
2261 | |
2262 DEFUN ("event-point", Fevent_point, 1, 1, 0, /* | |
2263 Return the character position of the mouse event EVENT. | |
2264 If the event did not occur over a window, or did not occur over text, | |
2265 then this returns nil. Otherwise, it returns a position in the buffer | |
2266 visible in the event's window. | |
2267 */ | |
2268 (event)) | |
2269 { | |
665 | 2270 Charbpos bufp; |
428 | 2271 struct window *w; |
2272 | |
2273 event_pixel_translation (event, 0, 0, 0, 0, &w, &bufp, 0, 0, 0, 0); | |
2274 | |
2275 return w && bufp ? make_int (bufp) : Qnil; | |
2276 } | |
2277 | |
2278 DEFUN ("event-closest-point", Fevent_closest_point, 1, 1, 0, /* | |
2279 Return the character position closest to the mouse event EVENT. | |
2280 If the event did not occur over a window or over text, return the | |
2281 closest point to the location of the event. If the Y pixel position | |
2282 overlaps a window and the X pixel position is to the left of that | |
2283 window, the closest point is the beginning of the line containing the | |
2284 Y position. If the Y pixel position overlaps a window and the X pixel | |
2285 position is to the right of that window, the closest point is the end | |
2286 of the line containing the Y position. If the Y pixel position is | |
2287 above a window, return 0. If it is below the last character in a window, | |
2288 return the value of (window-end). | |
2289 */ | |
2290 (event)) | |
2291 { | |
665 | 2292 Charbpos bufp; |
428 | 2293 |
2294 event_pixel_translation (event, 0, 0, 0, 0, 0, 0, &bufp, 0, 0, 0); | |
2295 | |
2296 return bufp ? make_int (bufp) : Qnil; | |
2297 } | |
2298 | |
2299 DEFUN ("event-x", Fevent_x, 1, 1, 0, /* | |
2300 Return the X position of the mouse event EVENT in characters. | |
2301 This is relative to the window the event occurred over. | |
2302 */ | |
2303 (event)) | |
2304 { | |
2305 int char_x; | |
2306 | |
2307 event_pixel_translation (event, &char_x, 0, 0, 0, 0, 0, 0, 0, 0, 0); | |
2308 | |
2309 return make_int (char_x); | |
2310 } | |
2311 | |
2312 DEFUN ("event-y", Fevent_y, 1, 1, 0, /* | |
2313 Return the Y position of the mouse event EVENT in characters. | |
2314 This is relative to the window the event occurred over. | |
2315 */ | |
2316 (event)) | |
2317 { | |
2318 int char_y; | |
2319 | |
2320 event_pixel_translation (event, 0, &char_y, 0, 0, 0, 0, 0, 0, 0, 0); | |
2321 | |
2322 return make_int (char_y); | |
2323 } | |
2324 | |
2325 DEFUN ("event-modeline-position", Fevent_modeline_position, 1, 1, 0, /* | |
2326 Return the character position in the modeline that EVENT occurred over. | |
2327 EVENT should be a mouse event. If EVENT did not occur over a modeline, | |
2328 nil is returned. You can determine the actual character that the | |
2329 event occurred over by looking in `generated-modeline-string' at the | |
2330 returned character position. Note that `generated-modeline-string' | |
2331 is buffer-local, and you must use EVENT's buffer when retrieving | |
2332 `generated-modeline-string' in order to get accurate results. | |
2333 */ | |
2334 (event)) | |
2335 { | |
2336 Charcount mbufp; | |
2337 int where; | |
2338 | |
2339 where = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, &mbufp, 0, 0); | |
2340 | |
2341 return (mbufp < 0 || where != OVER_MODELINE) ? Qnil : make_int (mbufp); | |
2342 } | |
2343 | |
2344 DEFUN ("event-glyph", Fevent_glyph, 1, 1, 0, /* | |
2345 Return the glyph that the mouse event EVENT occurred over, or nil. | |
2346 */ | |
2347 (event)) | |
2348 { | |
2349 Lisp_Object glyph; | |
2350 struct window *w; | |
2351 | |
2352 event_pixel_translation (event, 0, 0, 0, 0, &w, 0, 0, 0, &glyph, 0); | |
2353 | |
2354 return w && GLYPHP (glyph) ? glyph : Qnil; | |
2355 } | |
2356 | |
2357 DEFUN ("event-glyph-extent", Fevent_glyph_extent, 1, 1, 0, /* | |
2358 Return the extent of the glyph that the mouse event EVENT occurred over. | |
2359 If the event did not occur over a glyph, nil is returned. | |
2360 */ | |
2361 (event)) | |
2362 { | |
2363 Lisp_Object extent; | |
2364 struct window *w; | |
2365 | |
2366 event_pixel_translation (event, 0, 0, 0, 0, &w, 0, 0, 0, 0, &extent); | |
2367 | |
2368 return w && EXTENTP (extent) ? extent : Qnil; | |
2369 } | |
2370 | |
2371 DEFUN ("event-glyph-x-pixel", Fevent_glyph_x_pixel, 1, 1, 0, /* | |
2372 Return the X pixel position of EVENT relative to the glyph it occurred over. | |
2373 EVENT should be a mouse event. If the event did not occur over a glyph, | |
2374 nil is returned. | |
2375 */ | |
2376 (event)) | |
2377 { | |
2378 Lisp_Object extent; | |
2379 struct window *w; | |
2380 int obj_x; | |
2381 | |
2382 event_pixel_translation (event, 0, 0, &obj_x, 0, &w, 0, 0, 0, 0, &extent); | |
2383 | |
2384 return w && EXTENTP (extent) ? make_int (obj_x) : Qnil; | |
2385 } | |
2386 | |
2387 DEFUN ("event-glyph-y-pixel", Fevent_glyph_y_pixel, 1, 1, 0, /* | |
2388 Return the Y pixel position of EVENT relative to the glyph it occurred over. | |
2389 EVENT should be a mouse event. If the event did not occur over a glyph, | |
2390 nil is returned. | |
2391 */ | |
2392 (event)) | |
2393 { | |
2394 Lisp_Object extent; | |
2395 struct window *w; | |
2396 int obj_y; | |
2397 | |
2398 event_pixel_translation (event, 0, 0, 0, &obj_y, &w, 0, 0, 0, 0, &extent); | |
2399 | |
2400 return w && EXTENTP (extent) ? make_int (obj_y) : Qnil; | |
2401 } | |
2402 | |
2403 DEFUN ("event-toolbar-button", Fevent_toolbar_button, 1, 1, 0, /* | |
2404 Return the toolbar button that the mouse event EVENT occurred over. | |
2405 If the event did not occur over a toolbar button, nil is returned. | |
2406 */ | |
2340 | 2407 (USED_IF_TOOLBARS (event))) |
428 | 2408 { |
2409 #ifdef HAVE_TOOLBARS | |
2410 Lisp_Object button; | |
2411 | |
2412 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, &button, 0); | |
2413 | |
2414 return result == OVER_TOOLBAR && TOOLBAR_BUTTONP (button) ? button : Qnil; | |
2415 #else | |
2416 return Qnil; | |
2417 #endif | |
2418 } | |
2419 | |
2420 DEFUN ("event-process", Fevent_process, 1, 1, 0, /* | |
444 | 2421 Return the process of the process-output event EVENT. |
428 | 2422 */ |
2423 (event)) | |
2424 { | |
934 | 2425 CHECK_EVENT_TYPE (event, process_event, Qprocess_event_p); |
1204 | 2426 return XEVENT_PROCESS_PROCESS (event); |
428 | 2427 } |
2428 | |
2429 DEFUN ("event-function", Fevent_function, 1, 1, 0, /* | |
2430 Return the callback function of EVENT. | |
2431 EVENT should be a timeout, misc-user, or eval event. | |
2432 */ | |
2433 (event)) | |
2434 { | |
2435 again: | |
2436 CHECK_LIVE_EVENT (event); | |
934 | 2437 switch (XEVENT_TYPE (event)) |
2438 { | |
2439 case timeout_event: | |
1204 | 2440 return XEVENT_TIMEOUT_FUNCTION (event); |
934 | 2441 case misc_user_event: |
1204 | 2442 return XEVENT_MISC_USER_FUNCTION (event); |
934 | 2443 case eval_event: |
1204 | 2444 return XEVENT_EVAL_FUNCTION (event); |
934 | 2445 default: |
2446 event = wrong_type_argument (intern ("timeout-or-eval-event-p"), event); | |
2447 goto again; | |
2448 } | |
428 | 2449 } |
2450 | |
2451 DEFUN ("event-object", Fevent_object, 1, 1, 0, /* | |
2452 Return the callback function argument of EVENT. | |
2453 EVENT should be a timeout, misc-user, or eval event. | |
2454 */ | |
2455 (event)) | |
2456 { | |
2457 again: | |
2458 CHECK_LIVE_EVENT (event); | |
934 | 2459 switch (XEVENT_TYPE (event)) |
2460 { | |
2461 case timeout_event: | |
1204 | 2462 return XEVENT_TIMEOUT_OBJECT (event); |
934 | 2463 case misc_user_event: |
1204 | 2464 return XEVENT_MISC_USER_OBJECT (event); |
934 | 2465 case eval_event: |
1204 | 2466 return XEVENT_EVAL_OBJECT (event); |
934 | 2467 default: |
2468 event = wrong_type_argument (intern ("timeout-or-eval-event-p"), event); | |
2469 goto again; | |
2470 } | |
428 | 2471 } |
2472 | |
2473 DEFUN ("event-properties", Fevent_properties, 1, 1, 0, /* | |
2474 Return a list of all of the properties of EVENT. | |
2475 This is in the form of a property list (alternating keyword/value pairs). | |
2476 */ | |
2477 (event)) | |
2478 { | |
2479 Lisp_Object props = Qnil; | |
440 | 2480 Lisp_Event *e; |
428 | 2481 struct gcpro gcpro1; |
2482 | |
2483 CHECK_LIVE_EVENT (event); | |
2484 e = XEVENT (event); | |
2485 GCPRO1 (props); | |
2486 | |
2487 props = cons3 (Qtimestamp, Fevent_timestamp (event), props); | |
2488 | |
934 | 2489 switch (EVENT_TYPE (e)) |
428 | 2490 { |
2500 | 2491 default: ABORT (); |
428 | 2492 |
2493 case process_event: | |
1204 | 2494 props = cons3 (Qprocess, EVENT_PROCESS_PROCESS (e), props); |
428 | 2495 break; |
2496 | |
2497 case timeout_event: | |
2498 props = cons3 (Qobject, Fevent_object (event), props); | |
2499 props = cons3 (Qfunction, Fevent_function (event), props); | |
1204 | 2500 props = cons3 (Qid, make_int (EVENT_TIMEOUT_ID_NUMBER (e)), props); |
428 | 2501 break; |
2502 | |
2503 case key_press_event: | |
2504 props = cons3 (Qmodifiers, Fevent_modifiers (event), props); | |
2505 props = cons3 (Qkey, Fevent_key (event), props); | |
2506 break; | |
2507 | |
2508 case button_press_event: | |
2509 case button_release_event: | |
2510 props = cons3 (Qy, Fevent_y_pixel (event), props); | |
2511 props = cons3 (Qx, Fevent_x_pixel (event), props); | |
2512 props = cons3 (Qmodifiers, Fevent_modifiers (event), props); | |
2513 props = cons3 (Qbutton, Fevent_button (event), props); | |
2514 break; | |
2515 | |
2516 case pointer_motion_event: | |
2517 props = cons3 (Qmodifiers, Fevent_modifiers (event), props); | |
2518 props = cons3 (Qy, Fevent_y_pixel (event), props); | |
2519 props = cons3 (Qx, Fevent_x_pixel (event), props); | |
2520 break; | |
2521 | |
2522 case misc_user_event: | |
2523 props = cons3 (Qobject, Fevent_object (event), props); | |
2524 props = cons3 (Qfunction, Fevent_function (event), props); | |
2525 props = cons3 (Qy, Fevent_y_pixel (event), props); | |
2526 props = cons3 (Qx, Fevent_x_pixel (event), props); | |
2527 props = cons3 (Qmodifiers, Fevent_modifiers (event), props); | |
2528 props = cons3 (Qbutton, Fevent_button (event), props); | |
2529 break; | |
2530 | |
2531 case eval_event: | |
2532 props = cons3 (Qobject, Fevent_object (event), props); | |
2533 props = cons3 (Qfunction, Fevent_function (event), props); | |
2534 break; | |
2535 | |
2536 case magic_eval_event: | |
2537 case magic_event: | |
2538 break; | |
2539 | |
2540 case empty_event: | |
2541 RETURN_UNGCPRO (Qnil); | |
2542 break; | |
2543 } | |
2544 | |
2545 props = cons3 (Qchannel, Fevent_channel (event), props); | |
2546 UNGCPRO; | |
2547 | |
2548 return props; | |
2549 } | |
2550 | |
2551 | |
2552 /************************************************************************/ | |
2553 /* initialization */ | |
2554 /************************************************************************/ | |
2555 | |
2556 void | |
2557 syms_of_events (void) | |
2558 { | |
442 | 2559 INIT_LRECORD_IMPLEMENTATION (event); |
1204 | 2560 #ifdef EVENT_DATA_AS_OBJECTS |
934 | 2561 INIT_LRECORD_IMPLEMENTATION (key_data); |
2562 INIT_LRECORD_IMPLEMENTATION (button_data); | |
2563 INIT_LRECORD_IMPLEMENTATION (motion_data); | |
2564 INIT_LRECORD_IMPLEMENTATION (process_data); | |
2565 INIT_LRECORD_IMPLEMENTATION (timeout_data); | |
2566 INIT_LRECORD_IMPLEMENTATION (eval_data); | |
2567 INIT_LRECORD_IMPLEMENTATION (misc_user_data); | |
2568 INIT_LRECORD_IMPLEMENTATION (magic_eval_data); | |
2569 INIT_LRECORD_IMPLEMENTATION (magic_data); | |
1204 | 2570 #endif /* EVENT_DATA_AS_OBJECTS */ |
442 | 2571 |
428 | 2572 DEFSUBR (Fcharacter_to_event); |
2573 DEFSUBR (Fevent_to_character); | |
2574 | |
2575 DEFSUBR (Fmake_event); | |
2576 DEFSUBR (Fdeallocate_event); | |
2577 DEFSUBR (Fcopy_event); | |
2578 DEFSUBR (Feventp); | |
2579 DEFSUBR (Fevent_live_p); | |
2580 DEFSUBR (Fevent_type); | |
2581 DEFSUBR (Fevent_properties); | |
2582 | |
2583 DEFSUBR (Fevent_timestamp); | |
442 | 2584 DEFSUBR (Fevent_timestamp_lessp); |
428 | 2585 DEFSUBR (Fevent_key); |
2586 DEFSUBR (Fevent_button); | |
2587 DEFSUBR (Fevent_modifier_bits); | |
2588 DEFSUBR (Fevent_modifiers); | |
2589 DEFSUBR (Fevent_x_pixel); | |
2590 DEFSUBR (Fevent_y_pixel); | |
2591 DEFSUBR (Fevent_window_x_pixel); | |
2592 DEFSUBR (Fevent_window_y_pixel); | |
2593 DEFSUBR (Fevent_over_text_area_p); | |
2594 DEFSUBR (Fevent_over_modeline_p); | |
2595 DEFSUBR (Fevent_over_border_p); | |
2596 DEFSUBR (Fevent_over_toolbar_p); | |
2597 DEFSUBR (Fevent_over_vertical_divider_p); | |
2598 DEFSUBR (Fevent_channel); | |
2599 DEFSUBR (Fevent_window); | |
2600 DEFSUBR (Fevent_point); | |
2601 DEFSUBR (Fevent_closest_point); | |
2602 DEFSUBR (Fevent_x); | |
2603 DEFSUBR (Fevent_y); | |
2604 DEFSUBR (Fevent_modeline_position); | |
2605 DEFSUBR (Fevent_glyph); | |
2606 DEFSUBR (Fevent_glyph_extent); | |
2607 DEFSUBR (Fevent_glyph_x_pixel); | |
2608 DEFSUBR (Fevent_glyph_y_pixel); | |
2609 DEFSUBR (Fevent_toolbar_button); | |
2610 DEFSUBR (Fevent_process); | |
2611 DEFSUBR (Fevent_function); | |
2612 DEFSUBR (Fevent_object); | |
2613 | |
563 | 2614 DEFSYMBOL (Qeventp); |
2615 DEFSYMBOL (Qevent_live_p); | |
2616 DEFSYMBOL (Qkey_press_event_p); | |
2617 DEFSYMBOL (Qbutton_event_p); | |
2618 DEFSYMBOL (Qmouse_event_p); | |
2619 DEFSYMBOL (Qprocess_event_p); | |
2620 DEFSYMBOL (Qkey_press); | |
2621 DEFSYMBOL (Qbutton_press); | |
2622 DEFSYMBOL (Qbutton_release); | |
2623 DEFSYMBOL (Qmisc_user); | |
2828 | 2624 DEFSYMBOL (Qcharacter_of_keysym); |
563 | 2625 DEFSYMBOL (Qascii_character); |
428 | 2626 |
2627 defsymbol (&QKbackspace, "backspace"); | |
2628 defsymbol (&QKtab, "tab"); | |
2629 defsymbol (&QKlinefeed, "linefeed"); | |
2630 defsymbol (&QKreturn, "return"); | |
2631 defsymbol (&QKescape, "escape"); | |
2632 defsymbol (&QKspace, "space"); | |
2633 defsymbol (&QKdelete, "delete"); | |
2634 } | |
2635 | |
2636 | |
2637 void | |
2638 reinit_vars_of_events (void) | |
2639 { | |
2640 Vevent_resource = Qnil; | |
3092 | 2641 #ifdef NEW_GC |
5139
a48ef26d87ee
Clean up prototypes for Lisp variables/symbols. Put decls for them with
Ben Wing <ben@xemacs.org>
parents:
5055
diff
changeset
|
2642 staticpro_nodump (&Vevent_resource); |
3092 | 2643 #endif /* NEW_GC */ |
428 | 2644 } |
2645 | |
2646 void | |
2647 vars_of_events (void) | |
2648 { | |
2649 } |