Mercurial > hg > xemacs-beta
annotate src/events.c @ 5046:d4f666cda5e6
some random fixups
-------------------- ChangeLog entries follow: --------------------
man/ChangeLog addition:
2010-02-20 Ben Wing <ben@xemacs.org>
* internals/internals.texi (Intro to Window and Frame Geometry):
Shrink diagram to fit when offset by five spaces as a result of
quoting.
src/ChangeLog addition:
2010-02-20 Ben Wing <ben@xemacs.org>
* syswindows.h:
Add table about GNU Emacs -> XEmacs Windows constants from
the internals manual.
* frame.c:
Shrink size of diagram consistent with internals manual.
* alloc.c:
* compiler.h:
* console.c:
* events.c:
* gc.c (gc_stat_start_new_gc):
* gc.c (gc_stat_resume_gc):
* gc.c (kkcc_marking):
* gc.c (gc_1):
* gc.c (gc):
* objects-tty.c:
* redisplay-msw.c:
* redisplay-msw.c (mswindows_clear_region):
* syntax.c:
* syntax.c (ST_COMMENT_STYLE):
* sysdep.c:
Fix various compiler warnings.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Sat, 20 Feb 2010 03:24:08 -0600 |
parents | e813cf16c015 |
children | 92dc90c0bb40 |
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 | |
880 if (EQ (event, Vlast_command_event) || | |
881 EQ (event, Vlast_input_event) || | |
882 EQ (event, Vunread_command_event)) | |
2500 | 883 ABORT (); |
428 | 884 |
885 len = XVECTOR_LENGTH (Vthis_command_keys); | |
886 for (i = 0; i < len; i++) | |
887 if (EQ (event, XVECTOR_DATA (Vthis_command_keys) [i])) | |
2500 | 888 ABORT (); |
428 | 889 if (!NILP (Vrecent_keys_ring)) |
890 { | |
891 int recent_ring_len = XVECTOR_LENGTH (Vrecent_keys_ring); | |
892 for (i = 0; i < recent_ring_len; i++) | |
893 if (EQ (event, XVECTOR_DATA (Vrecent_keys_ring) [i])) | |
2500 | 894 ABORT (); |
428 | 895 } |
896 } | |
897 #endif /* 0 */ | |
898 | |
899 assert (!EQ (event, Vevent_resource)); | |
900 deinitialize_event (event); | |
901 #ifndef ALLOC_NO_POOLS | |
902 XSET_EVENT_NEXT (event, Vevent_resource); | |
903 Vevent_resource = event; | |
904 #endif | |
905 return Qnil; | |
906 } | |
907 | |
908 DEFUN ("copy-event", Fcopy_event, 1, 2, 0, /* | |
444 | 909 Make a copy of the event object EVENT1. |
910 If a second event argument EVENT2 is given, EVENT1 is copied into | |
911 EVENT2 and EVENT2 is returned. If EVENT2 is not supplied (or is nil) | |
912 then a new event will be made as with `make-event'. See also the | |
913 function `deallocate-event'. | |
428 | 914 */ |
915 (event1, event2)) | |
916 { | |
917 CHECK_LIVE_EVENT (event1); | |
918 if (NILP (event2)) | |
919 event2 = Fmake_event (Qnil, Qnil); | |
430 | 920 else |
921 { | |
922 CHECK_LIVE_EVENT (event2); | |
923 if (EQ (event1, event2)) | |
563 | 924 return signal_continuable_error_2 |
925 (Qinvalid_argument, | |
926 "copy-event called with `eq' events", event1, event2); | |
430 | 927 } |
428 | 928 |
929 assert (XEVENT_TYPE (event1) <= last_event_type); | |
930 assert (XEVENT_TYPE (event2) <= last_event_type); | |
931 | |
934 | 932 XSET_EVENT_TYPE (event2, XEVENT_TYPE (event1)); |
933 XSET_EVENT_CHANNEL (event2, XEVENT_CHANNEL (event1)); | |
934 XSET_EVENT_TIMESTAMP (event2, XEVENT_TIMESTAMP (event1)); | |
1204 | 935 |
936 #ifdef EVENT_DATA_AS_OBJECTS | |
937 copy_lisp_object (XEVENT_DATA (event2), XEVENT_DATA (event1)); | |
938 #else | |
939 XEVENT (event2)->event = XEVENT (event1)->event; | |
940 #endif | |
934 | 941 return event2; |
428 | 942 } |
943 | |
944 | |
771 | 945 /************************************************************************/ |
946 /* event chain functions */ | |
947 /************************************************************************/ | |
428 | 948 |
949 /* Given a chain of events (or possibly nil), deallocate them all. */ | |
950 | |
951 void | |
952 deallocate_event_chain (Lisp_Object event_chain) | |
953 { | |
954 while (!NILP (event_chain)) | |
955 { | |
956 Lisp_Object next = XEVENT_NEXT (event_chain); | |
957 Fdeallocate_event (event_chain); | |
958 event_chain = next; | |
959 } | |
960 } | |
961 | |
962 /* Return the last event in a chain. | |
963 NOTE: You cannot pass nil as a value here! The routine will | |
964 abort if you do. */ | |
965 | |
966 Lisp_Object | |
967 event_chain_tail (Lisp_Object event_chain) | |
968 { | |
969 while (1) | |
970 { | |
971 Lisp_Object next = XEVENT_NEXT (event_chain); | |
972 if (NILP (next)) | |
973 return event_chain; | |
974 event_chain = next; | |
975 } | |
976 } | |
977 | |
978 /* Enqueue a single event onto the end of a chain of events. | |
979 HEAD points to the first event in the chain, TAIL to the last event. | |
980 If the chain is empty, both values should be nil. */ | |
981 | |
982 void | |
983 enqueue_event (Lisp_Object event, Lisp_Object *head, Lisp_Object *tail) | |
984 { | |
985 assert (NILP (XEVENT_NEXT (event))); | |
986 assert (!EQ (*tail, event)); | |
987 | |
988 if (!NILP (*tail)) | |
989 XSET_EVENT_NEXT (*tail, event); | |
990 else | |
991 *head = event; | |
992 *tail = event; | |
993 | |
994 assert (!EQ (event, XEVENT_NEXT (event))); | |
995 } | |
996 | |
997 /* Remove an event off the head of a chain of events and return it. | |
998 HEAD points to the first event in the chain, TAIL to the last event. */ | |
999 | |
1000 Lisp_Object | |
1001 dequeue_event (Lisp_Object *head, Lisp_Object *tail) | |
1002 { | |
1003 Lisp_Object event; | |
1004 | |
1005 event = *head; | |
1006 *head = XEVENT_NEXT (event); | |
1007 XSET_EVENT_NEXT (event, Qnil); | |
1008 if (NILP (*head)) | |
1009 *tail = Qnil; | |
1010 return event; | |
1011 } | |
1012 | |
1013 /* Enqueue a chain of events (or possibly nil) onto the end of another | |
1014 chain of events. HEAD points to the first event in the chain being | |
1015 queued onto, TAIL to the last event. If the chain is empty, both values | |
1016 should be nil. */ | |
1017 | |
1018 void | |
1019 enqueue_event_chain (Lisp_Object event_chain, Lisp_Object *head, | |
1020 Lisp_Object *tail) | |
1021 { | |
1022 if (NILP (event_chain)) | |
1023 return; | |
1024 | |
1025 if (NILP (*head)) | |
1026 { | |
1027 *head = event_chain; | |
1028 *tail = event_chain; | |
1029 } | |
1030 else | |
1031 { | |
1032 XSET_EVENT_NEXT (*tail, event_chain); | |
1033 *tail = event_chain_tail (event_chain); | |
1034 } | |
1035 } | |
1036 | |
1204 | 1037 /* Map a function over each event in the chain. If the function returns |
1038 non-zero, remove the event just processed. Return the total number of | |
1039 items removed. | |
1040 | |
1041 NOTE: | |
1042 | |
1043 If you want a simple mapping over an event chain, with no intention to | |
1044 add or remove items, just use EVENT_CHAIN_LOOP(). | |
1045 */ | |
1046 | |
1047 int | |
1048 map_event_chain_remove (int (*fn) (Lisp_Object ev, void *user_data), | |
1049 Lisp_Object *head, Lisp_Object *tail, | |
1050 void *user_data, int flags) | |
1051 { | |
1052 Lisp_Object event; | |
1053 Lisp_Object previous_event = Qnil; | |
1054 int count = 0; | |
1055 | |
1056 EVENT_CHAIN_LOOP (event, *head) | |
1057 { | |
1058 if (fn (event, user_data)) | |
1059 { | |
1060 if (NILP (previous_event)) | |
1061 dequeue_event (head, tail); | |
1062 else | |
1063 { | |
1064 XSET_EVENT_NEXT (previous_event, XEVENT_NEXT (event)); | |
1065 if (EQ (*tail, event)) | |
1066 *tail = previous_event; | |
1067 } | |
1068 | |
1069 if (flags & MECR_DEALLOCATE_EVENT) | |
1070 Fdeallocate_event (event); | |
1071 count++; | |
1072 } | |
1073 else | |
1074 previous_event = event; | |
1075 } | |
1076 return count; | |
1077 } | |
1078 | |
428 | 1079 /* Return the number of events (possibly 0) on an event chain. */ |
1080 | |
1081 int | |
1082 event_chain_count (Lisp_Object event_chain) | |
1083 { | |
1084 Lisp_Object event; | |
1085 int n = 0; | |
1086 | |
1087 EVENT_CHAIN_LOOP (event, event_chain) | |
1088 n++; | |
1089 | |
1090 return n; | |
1091 } | |
1092 | |
1093 /* Find the event before EVENT in an event chain. This aborts | |
1094 if the event is not in the chain. */ | |
1095 | |
1096 Lisp_Object | |
1097 event_chain_find_previous (Lisp_Object event_chain, Lisp_Object event) | |
1098 { | |
1099 Lisp_Object previous = Qnil; | |
1100 | |
1101 while (!NILP (event_chain)) | |
1102 { | |
1103 if (EQ (event_chain, event)) | |
1104 return previous; | |
1105 previous = event_chain; | |
1106 event_chain = XEVENT_NEXT (event_chain); | |
1107 } | |
1108 | |
2500 | 1109 ABORT (); |
428 | 1110 return Qnil; |
1111 } | |
1112 | |
1113 Lisp_Object | |
1114 event_chain_nth (Lisp_Object event_chain, int n) | |
1115 { | |
1116 Lisp_Object event; | |
1117 EVENT_CHAIN_LOOP (event, event_chain) | |
1118 { | |
1119 if (!n) | |
1120 return event; | |
1121 n--; | |
1122 } | |
1123 return Qnil; | |
1124 } | |
1125 | |
771 | 1126 /* Return a freshly allocated copy of all events in the given chain. */ |
1127 | |
428 | 1128 Lisp_Object |
1129 copy_event_chain (Lisp_Object event_chain) | |
1130 { | |
1131 Lisp_Object new_chain = Qnil; | |
1132 Lisp_Object new_chain_tail = Qnil; | |
1133 Lisp_Object event; | |
1134 | |
1135 EVENT_CHAIN_LOOP (event, event_chain) | |
1136 { | |
1137 Lisp_Object copy = Fcopy_event (event, Qnil); | |
1138 enqueue_event (copy, &new_chain, &new_chain_tail); | |
1139 } | |
1140 | |
1141 return new_chain; | |
1142 } | |
1143 | |
771 | 1144 /* Given a pointer (maybe nil) into an old chain (also maybe nil, if |
1145 pointer is nil) and a new chain which is a copy of the old, return | |
1146 the corresponding new pointer. */ | |
1147 Lisp_Object | |
1148 transfer_event_chain_pointer (Lisp_Object pointer, Lisp_Object old_chain, | |
1149 Lisp_Object new_chain) | |
1150 { | |
1151 if (NILP (pointer)) | |
1152 return Qnil; | |
1153 assert (!NILP (old_chain)); | |
800 | 1154 #ifdef ERROR_CHECK_STRUCTURES |
771 | 1155 /* make sure we're actually in the chain */ |
1156 event_chain_find_previous (old_chain, pointer); | |
1157 assert (event_chain_count (old_chain) == event_chain_count (new_chain)); | |
800 | 1158 #endif /* ERROR_CHECK_STRUCTURES */ |
771 | 1159 return event_chain_nth (new_chain, |
1160 event_chain_count (old_chain) - | |
1161 event_chain_count (pointer)); | |
1162 } | |
1163 | |
428 | 1164 |
771 | 1165 /************************************************************************/ |
1166 /* higher level functions */ | |
1167 /************************************************************************/ | |
428 | 1168 |
1169 Lisp_Object QKbackspace, QKtab, QKlinefeed, QKreturn, QKescape, | |
1170 QKspace, QKdelete; | |
1171 | |
1172 int | |
1173 command_event_p (Lisp_Object event) | |
1174 { | |
1175 switch (XEVENT_TYPE (event)) | |
1176 { | |
1177 case key_press_event: | |
1178 case button_press_event: | |
1179 case button_release_event: | |
1180 case misc_user_event: | |
1181 return 1; | |
1182 default: | |
1183 return 0; | |
1184 } | |
1185 } | |
1186 | |
4780
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1187 /* 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
|
1188 |
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1189 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
|
1190 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
|
1191 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
|
1192 |
1204 | 1193 DO_BACKSPACE_MAPPING means that if CON is a TTY, and C is a the TTY's |
1194 backspace character, the event will have keysym `backspace' instead of | |
1195 '(control h). It is clearly correct to do this conversion is the | |
1196 character was just read from a TTY, clearly incorrect inside of | |
1197 define-key, which must be able to handle all consoles. #### What about | |
1198 in other circumstances? #### Should the user have access to this flag? | |
1199 | |
1200 #### We need to go through and review all the flags in | |
1201 character_to_event() and event_to_character() and figure out exactly | |
1202 under what circumstances they should or should not be set, then go | |
1203 through and review all callers of character_to_event(), | |
1204 Fcharacter_to_event(), event_to_character(), and Fevent_to_character() | |
1205 and check that they are passing the correct flags in for their varied | |
1206 circumstances. | |
1207 | |
1208 #### Some of this garbage, and some of the flags, could go away if we | |
1209 implemented the suggestion, originally from event-Xt.c: | |
1210 | |
2828 | 1211 [[ The way that keysym correspondence to characters should work: |
1204 | 1212 - a Lisp_Event should contain a keysym AND a character slot. |
1213 - keybindings are tried with the keysym. If no binding can be found, | |
2828 | 1214 and there is a corresponding character, call self-insert-command. ]] |
1215 | |
1216 That's an X-specific way of thinking. All the other platforms--even | |
1217 the TTY, make sure you've done (set-input-mode t nil 1) and set your | |
1218 console coding system appropriately when checking--just use | |
1219 characters as emacs keysyms, and, together with defaulting to | |
1220 self-insert-command if an unbound key with a character correspondence | |
1221 is typed, that works fine for them. (Yes, this ignores GTK.) | |
1222 | |
1223 [[ [... snipping other suggestions which I've implemented.] | |
1224 Nuke the Qascii_character property. ]] | |
1204 | 1225 |
2828 | 1226 Well, we've renamed it anyway--it was badly named. |
1227 Qcharacter_of_keysym, here we go. It's really only with X11 that how | |
1228 to map between adiaeresis and (int-to-char #xE4), or ellipsis and | |
1229 whatever, becomes an issue, and IMO the property approach to this is | |
1230 fine. Aidan Kehoe, 2005-05-15. | |
1204 | 1231 |
2828 | 1232 [[ This would apparently solve a lot of different problems. ]] |
1233 | |
1234 I'd be interested to know what's left. Removing the allow-meta | |
1235 argument from event-to-character would be a Good Thing, IMO, but | |
1236 beyond that, I'm not sure what else there is to do wrt. key | |
1237 mappings. Of course, feedback from users of the Russian C-x facility | |
1238 is still needed. */ | |
428 | 1239 |
1240 void | |
867 | 1241 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
|
1242 character_to_event_meta_behavior meta_behavior, |
2340 | 1243 int USED_IF_TTY (do_backspace_mapping)) |
428 | 1244 { |
1245 Lisp_Object k = Qnil; | |
442 | 1246 int m = 0; |
934 | 1247 if (EVENT_TYPE (event) == dead_event) |
563 | 1248 invalid_argument ("character-to-event called with a deallocated event!", Qunbound); |
428 | 1249 |
1250 #ifndef MULE | |
1251 c &= 255; | |
1252 #endif | |
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 != latin_1_maps_to_itself && c > 127 && c <= 255) |
428 | 1254 { |
1255 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
|
1256 if (meta_behavior == use_console_meta_flag && CONSOLE_TTY_P (con)) |
428 | 1257 meta_flag = TTY_FLAGS (con).meta_key; |
1258 switch (meta_flag) | |
1259 { | |
1260 case 0: /* ignore top bit; it's parity */ | |
1261 c -= 128; | |
1262 break; | |
1263 case 1: /* top bit is meta */ | |
1264 c -= 128; | |
442 | 1265 m = XEMACS_MOD_META; |
428 | 1266 break; |
1267 default: /* this is a real character */ | |
1268 break; | |
1269 } | |
1270 } | |
442 | 1271 if (c < ' ') c += '@', m |= XEMACS_MOD_CONTROL; |
1272 if (m & XEMACS_MOD_CONTROL) | |
428 | 1273 { |
1274 switch (c) | |
1275 { | |
442 | 1276 case 'I': k = QKtab; m &= ~XEMACS_MOD_CONTROL; break; |
1277 case 'J': k = QKlinefeed; m &= ~XEMACS_MOD_CONTROL; break; | |
1278 case 'M': k = QKreturn; m &= ~XEMACS_MOD_CONTROL; break; | |
1279 case '[': k = QKescape; m &= ~XEMACS_MOD_CONTROL; break; | |
428 | 1280 default: |
1204 | 1281 #if defined (HAVE_TTY) |
428 | 1282 if (do_backspace_mapping && |
1283 CHARP (con->tty_erase_char) && | |
1284 c - '@' == XCHAR (con->tty_erase_char)) | |
1285 { | |
1286 k = QKbackspace; | |
442 | 1287 m &= ~XEMACS_MOD_CONTROL; |
428 | 1288 } |
1204 | 1289 #endif /* defined (HAVE_TTY) */ |
428 | 1290 break; |
1291 } | |
1292 if (c >= 'A' && c <= 'Z') c -= 'A'-'a'; | |
1293 } | |
1204 | 1294 #if defined (HAVE_TTY) |
428 | 1295 else if (do_backspace_mapping && |
1296 CHARP (con->tty_erase_char) && c == XCHAR (con->tty_erase_char)) | |
1297 k = QKbackspace; | |
1204 | 1298 #endif /* defined (HAVE_TTY) */ |
428 | 1299 else if (c == 127) |
1300 k = QKdelete; | |
1301 else if (c == ' ') | |
1302 k = QKspace; | |
1303 | |
934 | 1304 set_event_type (event, key_press_event); |
1305 SET_EVENT_TIMESTAMP_ZERO (event); /* #### */ | |
1306 SET_EVENT_CHANNEL (event, wrap_console (con)); | |
1204 | 1307 SET_EVENT_KEY_KEYSYM (event, (!NILP (k) ? k : make_char (c))); |
1308 SET_EVENT_KEY_MODIFIERS (event, m); | |
428 | 1309 } |
1310 | |
867 | 1311 Ichar |
1204 | 1312 event_to_character (Lisp_Object event, |
428 | 1313 int allow_extra_modifiers, |
2828 | 1314 int allow_meta) |
428 | 1315 { |
867 | 1316 Ichar c = 0; |
428 | 1317 Lisp_Object code; |
1318 | |
1204 | 1319 if (XEVENT_TYPE (event) != key_press_event) |
428 | 1320 { |
1204 | 1321 assert (XEVENT_TYPE (event) != dead_event); |
428 | 1322 return -1; |
1323 } | |
1324 if (!allow_extra_modifiers && | |
2828 | 1325 XEVENT_KEY_MODIFIERS (event) & |
1326 (XEMACS_MOD_SUPER|XEMACS_MOD_HYPER|XEMACS_MOD_ALT)) | |
428 | 1327 return -1; |
1204 | 1328 if (CHAR_OR_CHAR_INTP (XEVENT_KEY_KEYSYM (event))) |
1329 c = XCHAR_OR_CHAR_INT (XEVENT_KEY_KEYSYM (event)); | |
1330 else if (!SYMBOLP (XEVENT_KEY_KEYSYM (event))) | |
2500 | 1331 ABORT (); |
1204 | 1332 else if (CHAR_OR_CHAR_INTP (code = Fget (XEVENT_KEY_KEYSYM (event), |
2828 | 1333 Qcharacter_of_keysym, Qnil))) |
428 | 1334 c = XCHAR_OR_CHAR_INT (code); |
1335 else | |
2828 | 1336 { |
1337 Lisp_Object thekeysym = XEVENT_KEY_KEYSYM (event); | |
1338 | |
1339 if (CHAR_OR_CHAR_INTP (code = Fget (thekeysym, Qascii_character, Qnil))) | |
1340 { | |
1341 c = XCHAR_OR_CHAR_INT (code); | |
1342 warn_when_safe(Qkey_mapping, Qwarning, | |
1343 "Obsolete key binding technique.\n" | |
428 | 1344 |
2828 | 1345 "Some code you're using bound %s to `self-insert-command' and messed around\n" |
1346 "with its `ascii-character' property. Doing this is deprecated, and the code\n" | |
1347 "should be updated to use the `set-character-of-keysym' interface.\n" | |
1348 "If you're the one updating the code, first check if there's still a need\n" | |
1349 "for it; we support many more X11 keysyms out of the box now than we did\n" | |
1350 "in the past. ", XSTRING_DATA(XSYMBOL_NAME(thekeysym))); | |
1351 /* Only show the warning once for each keysym. */ | |
1352 Fput(thekeysym, Qcharacter_of_keysym, code); | |
1353 } | |
1354 else | |
1355 { | |
1356 return -1; | |
1357 } | |
1358 } | |
1204 | 1359 if (XEVENT_KEY_MODIFIERS (event) & XEMACS_MOD_CONTROL) |
428 | 1360 { |
1361 if (c >= 'a' && c <= 'z') | |
1362 c -= ('a' - 'A'); | |
1363 else | |
1364 /* reject Control-Shift- keys */ | |
1365 if (c >= 'A' && c <= 'Z' && !allow_extra_modifiers) | |
1366 return -1; | |
1367 | |
1368 if (c >= '@' && c <= '_') | |
1369 c -= '@'; | |
1370 else if (c == ' ') /* C-space and C-@ are the same. */ | |
1371 c = 0; | |
1372 else | |
1373 /* reject keys that can't take Control- modifiers */ | |
1374 if (! allow_extra_modifiers) return -1; | |
1375 } | |
1376 | |
1204 | 1377 if (XEVENT_KEY_MODIFIERS (event) & XEMACS_MOD_META) |
428 | 1378 { |
1379 if (! allow_meta) return -1; | |
1204 | 1380 if (c >= 128) return -1; /* don't allow M-oslash (overlap) */ |
428 | 1381 c |= 0200; |
1382 } | |
1383 return c; | |
1384 } | |
1385 | |
2862 | 1386 DEFUN ("event-to-character", Fevent_to_character, 1, 4, 0, /* |
2828 | 1387 Return the closest character approximation to the given event object. |
428 | 1388 If the event isn't a keypress, this returns nil. |
1389 If the ALLOW-EXTRA-MODIFIERS argument is non-nil, then this is lenient in | |
1390 its translation; it will ignore modifier keys other than control and meta, | |
1391 and will ignore the shift modifier on those characters which have no | |
1392 shifted ASCII equivalent (Control-Shift-A for example, will be mapped to | |
1393 the same ASCII code as Control-A). | |
1394 If the ALLOW-META argument is non-nil, then the Meta modifier will be | |
1395 represented by turning on the high bit of the byte returned; otherwise, nil | |
1396 will be returned for events containing the Meta modifier. | |
1204 | 1397 Note that ALLOW-META may cause ambiguity between meta characters and |
1398 Latin-1 characters. | |
2862 | 1399 ALLOW-NON-ASCII is unused, and retained for compatibility. |
428 | 1400 */ |
2862 | 1401 (event, allow_extra_modifiers, allow_meta, UNUSED(allow_non_ascii))) |
428 | 1402 { |
867 | 1403 Ichar c; |
428 | 1404 CHECK_LIVE_EVENT (event); |
1204 | 1405 c = event_to_character (event, |
428 | 1406 !NILP (allow_extra_modifiers), |
2828 | 1407 !NILP (allow_meta)); |
428 | 1408 return c < 0 ? Qnil : make_char (c); |
1409 } | |
1410 | |
1411 DEFUN ("character-to-event", Fcharacter_to_event, 1, 4, 0, /* | |
444 | 1412 Convert KEY-DESCRIPTION into an event structure, replete with bucky bits. |
428 | 1413 |
444 | 1414 KEY-DESCRIPTION is the first argument, and the event to fill in is the |
1415 second. This function contains knowledge about what various kinds of | |
1416 arguments ``mean'' -- for example, the number 9 is converted to the | |
1417 character ``Tab'', not the distinct character ``Control-I''. | |
428 | 1418 |
3025 | 1419 KEY-DESCRIPTION can be an integer, a character, a symbol such as `clear', |
444 | 1420 or a list such as '(control backspace). |
1421 | |
1422 If the optional second argument EVENT is an event, it is modified and | |
1423 returned; otherwise, a new event object is created and returned. | |
428 | 1424 |
1425 Optional third arg CONSOLE is the console to store in the event, and | |
1426 defaults to the selected console. | |
1427 | |
444 | 1428 If KEY-DESCRIPTION is an integer or character, the high bit may be |
1204 | 1429 interpreted as the meta key. (This is done for backward compatibility in |
1430 lots of places -- specifically, because lots of Lisp code uses specs like | |
1431 ?\M-d and "\M-d" in key code, expecting this to work; yet these are in | |
1432 reality converted directly to 8-bit characters by the Lisp reader.) If | |
1433 USE-CONSOLE-META-FLAG is nil or CONSOLE is not a TTY, this will always be | |
1434 the case. If USE-CONSOLE-META-FLAG is non-nil and CONSOLE is a TTY, the | |
1435 `meta' flag for CONSOLE affects whether the high bit is interpreted as a | |
1436 meta key. (See `set-input-mode'.) Don't set this flag to non-nil unless | |
1437 you know what you're doing (more specifically, only if the character came | |
1438 directly from a TTY, not from the user). If you don't want this silly meta | |
1439 interpretation done, you should pass in a list containing the character. | |
428 | 1440 |
1441 Beware that character-to-event and event-to-character are not strictly | |
1442 inverse functions, since events contain much more information than the | |
444 | 1443 Lisp character object type can encode. |
428 | 1444 */ |
4780
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1445 (keystroke, event, console, use_console_meta_flag_)) |
428 | 1446 { |
1447 struct console *con = decode_console (console); | |
1448 if (NILP (event)) | |
1449 event = Fmake_event (Qnil, Qnil); | |
1450 else | |
1451 CHECK_LIVE_EVENT (event); | |
444 | 1452 if (CONSP (keystroke) || SYMBOLP (keystroke)) |
1453 key_desc_list_to_event (keystroke, event, 1); | |
428 | 1454 else |
1455 { | |
444 | 1456 CHECK_CHAR_COERCE_INT (keystroke); |
1457 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
|
1458 (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
|
1459 high_bit_is_meta : use_console_meta_flag), 1); |
428 | 1460 } |
1461 return event; | |
1462 } | |
1463 | |
1464 void | |
1465 nth_of_key_sequence_as_event (Lisp_Object seq, int n, Lisp_Object event) | |
1466 { | |
1467 assert (STRINGP (seq) || VECTORP (seq)); | |
1468 assert (n < XINT (Flength (seq))); | |
1469 | |
1470 if (STRINGP (seq)) | |
1471 { | |
867 | 1472 Ichar ch = string_ichar (seq, n); |
428 | 1473 Fcharacter_to_event (make_char (ch), event, Qnil, Qnil); |
1474 } | |
1475 else | |
1476 { | |
1477 Lisp_Object keystroke = XVECTOR_DATA (seq)[n]; | |
1478 if (EVENTP (keystroke)) | |
1479 Fcopy_event (keystroke, event); | |
1480 else | |
1481 Fcharacter_to_event (keystroke, event, Qnil, Qnil); | |
1482 } | |
1483 } | |
1484 | |
1485 Lisp_Object | |
1486 key_sequence_to_event_chain (Lisp_Object seq) | |
1487 { | |
1488 int len = XINT (Flength (seq)); | |
1489 int i; | |
1490 Lisp_Object head = Qnil, tail = Qnil; | |
1491 | |
1492 for (i = 0; i < len; i++) | |
1493 { | |
1494 Lisp_Object event = Fmake_event (Qnil, Qnil); | |
1495 nth_of_key_sequence_as_event (seq, i, event); | |
1496 enqueue_event (event, &head, &tail); | |
1497 } | |
1498 | |
1499 return head; | |
1500 } | |
1501 | |
934 | 1502 |
793 | 1503 /* Concatenate a string description of EVENT onto the end of BUF. If |
1504 BRIEF, use short forms for keys, e.g. C- instead of control-. */ | |
1505 | |
934 | 1506 void |
1507 format_event_object (Eistring *buf, Lisp_Object event, int brief) | |
428 | 1508 { |
1509 int mouse_p = 0; | |
1510 int mod = 0; | |
1511 Lisp_Object key; | |
1512 | |
1204 | 1513 switch (XEVENT_TYPE (event)) |
428 | 1514 { |
1515 case key_press_event: | |
1516 { | |
1204 | 1517 mod = XEVENT_KEY_MODIFIERS (event); |
1518 key = XEVENT_KEY_KEYSYM (event); | |
428 | 1519 /* Hack. */ |
1520 if (! brief && CHARP (key) && | |
793 | 1521 mod & (XEMACS_MOD_CONTROL | XEMACS_MOD_META | XEMACS_MOD_SUPER | |
1522 XEMACS_MOD_HYPER)) | |
428 | 1523 { |
1524 int k = XCHAR (key); | |
1525 if (k >= 'a' && k <= 'z') | |
1526 key = make_char (k - ('a' - 'A')); | |
1527 else if (k >= 'A' && k <= 'Z') | |
442 | 1528 mod |= XEMACS_MOD_SHIFT; |
428 | 1529 } |
1530 break; | |
1531 } | |
1532 case button_release_event: | |
1533 mouse_p++; | |
1534 /* Fall through */ | |
1535 case button_press_event: | |
1536 { | |
1537 mouse_p++; | |
1204 | 1538 mod = XEVENT_BUTTON_MODIFIERS (event); |
1539 key = make_char (XEVENT_BUTTON_BUTTON (event) + '0'); | |
428 | 1540 break; |
1541 } | |
1542 case magic_event: | |
1543 { | |
788 | 1544 Lisp_Object stream; |
1545 struct gcpro gcpro1; | |
1546 GCPRO1 (stream); | |
428 | 1547 |
788 | 1548 stream = make_resizing_buffer_output_stream (); |
1204 | 1549 event_stream_format_magic_event (XEVENT (event), stream); |
788 | 1550 Lstream_flush (XLSTREAM (stream)); |
793 | 1551 eicat_raw (buf, resizing_buffer_stream_ptr (XLSTREAM (stream)), |
1552 Lstream_byte_count (XLSTREAM (stream))); | |
788 | 1553 Lstream_delete (XLSTREAM (stream)); |
1554 UNGCPRO; | |
428 | 1555 return; |
1556 } | |
2421 | 1557 case magic_eval_event: eicat_ascii (buf, "magic-eval"); return; |
1558 case pointer_motion_event: eicat_ascii (buf, "motion"); return; | |
1559 case misc_user_event: eicat_ascii (buf, "misc-user"); return; | |
1560 case eval_event: eicat_ascii (buf, "eval"); return; | |
1561 case process_event: eicat_ascii (buf, "process"); return; | |
1562 case timeout_event: eicat_ascii (buf, "timeout"); return; | |
1563 case empty_event: eicat_ascii (buf, "empty"); return; | |
1564 case dead_event: eicat_ascii (buf, "DEAD-EVENT"); return; | |
428 | 1565 default: |
2500 | 1566 ABORT (); |
442 | 1567 return; |
428 | 1568 } |
793 | 1569 #define modprint(x,y) \ |
2421 | 1570 do { if (brief) eicat_ascii (buf, (y)); else eicat_ascii (buf, (x)); } while (0) |
442 | 1571 if (mod & XEMACS_MOD_CONTROL) modprint ("control-", "C-"); |
1572 if (mod & XEMACS_MOD_META) modprint ("meta-", "M-"); | |
1573 if (mod & XEMACS_MOD_SUPER) modprint ("super-", "S-"); | |
1574 if (mod & XEMACS_MOD_HYPER) modprint ("hyper-", "H-"); | |
1575 if (mod & XEMACS_MOD_ALT) modprint ("alt-", "A-"); | |
1576 if (mod & XEMACS_MOD_SHIFT) modprint ("shift-", "Sh-"); | |
428 | 1577 if (mouse_p) |
1578 { | |
2421 | 1579 eicat_ascii (buf, "button"); |
428 | 1580 --mouse_p; |
1581 } | |
1582 | |
1583 #undef modprint | |
1584 | |
1585 if (CHARP (key)) | |
793 | 1586 eicat_ch (buf, XCHAR (key)); |
428 | 1587 else if (SYMBOLP (key)) |
1588 { | |
2367 | 1589 const Ascbyte *str = 0; |
428 | 1590 if (brief) |
1591 { | |
1592 if (EQ (key, QKlinefeed)) str = "LFD"; | |
1593 else if (EQ (key, QKtab)) str = "TAB"; | |
1594 else if (EQ (key, QKreturn)) str = "RET"; | |
1595 else if (EQ (key, QKescape)) str = "ESC"; | |
1596 else if (EQ (key, QKdelete)) str = "DEL"; | |
1597 else if (EQ (key, QKspace)) str = "SPC"; | |
1598 else if (EQ (key, QKbackspace)) str = "BS"; | |
1599 } | |
1600 if (str) | |
2421 | 1601 eicat_ascii (buf, str); |
428 | 1602 else |
793 | 1603 eicat_lstr (buf, XSYMBOL (key)->name); |
428 | 1604 } |
1605 else | |
2500 | 1606 ABORT (); |
428 | 1607 if (mouse_p) |
2421 | 1608 eicat_ascii (buf, "up"); |
428 | 1609 } |
1610 | |
1204 | 1611 void |
1612 upshift_event (Lisp_Object event) | |
1613 { | |
1614 Lisp_Object keysym = XEVENT_KEY_KEYSYM (event); | |
1615 Ichar c = 0; | |
1616 | |
1617 if (CHAR_OR_CHAR_INTP (keysym) | |
1618 && ((c = XCHAR_OR_CHAR_INT (keysym)), | |
1619 c >= 'a' && c <= 'z')) | |
1620 XSET_EVENT_KEY_KEYSYM (event, make_char (c + 'A' - 'a')); | |
1621 else | |
1622 if (!(XEVENT_KEY_MODIFIERS (event) & XEMACS_MOD_SHIFT)) | |
1623 XSET_EVENT_KEY_MODIFIERS | |
1624 (event, XEVENT_KEY_MODIFIERS (event) |= XEMACS_MOD_SHIFT); | |
1625 } | |
1626 | |
1627 void | |
1628 downshift_event (Lisp_Object event) | |
1629 { | |
1630 Lisp_Object keysym = XEVENT_KEY_KEYSYM (event); | |
1631 Ichar c = 0; | |
1632 | |
1633 if (XEVENT_KEY_MODIFIERS (event) & XEMACS_MOD_SHIFT) | |
1634 XSET_EVENT_KEY_MODIFIERS | |
1635 (event, XEVENT_KEY_MODIFIERS (event) & ~XEMACS_MOD_SHIFT); | |
1636 else if (CHAR_OR_CHAR_INTP (keysym) | |
1637 && ((c = XCHAR_OR_CHAR_INT (keysym)), | |
1638 c >= 'A' && c <= 'Z')) | |
1639 XSET_EVENT_KEY_KEYSYM (event, make_char (c + 'a' - 'A')); | |
1640 } | |
1641 | |
1642 int | |
1643 event_upshifted_p (Lisp_Object event) | |
1644 { | |
1645 Lisp_Object keysym = XEVENT_KEY_KEYSYM (event); | |
1646 Ichar c = 0; | |
1647 | |
1648 if ((XEVENT_KEY_MODIFIERS (event) & XEMACS_MOD_SHIFT) | |
1649 || (CHAR_OR_CHAR_INTP (keysym) | |
1650 && ((c = XCHAR_OR_CHAR_INT (keysym)), | |
1651 c >= 'A' && c <= 'Z'))) | |
1652 return 1; | |
1653 else | |
1654 return 0; | |
1655 } | |
934 | 1656 |
428 | 1657 DEFUN ("eventp", Feventp, 1, 1, 0, /* |
1658 True if OBJECT is an event object. | |
1659 */ | |
1660 (object)) | |
1661 { | |
1662 return EVENTP (object) ? Qt : Qnil; | |
1663 } | |
1664 | |
1665 DEFUN ("event-live-p", Fevent_live_p, 1, 1, 0, /* | |
1666 True if OBJECT is an event object that has not been deallocated. | |
1667 */ | |
1668 (object)) | |
1669 { | |
934 | 1670 return EVENTP (object) && XEVENT_TYPE (object) != dead_event ? |
1671 Qt : Qnil; | |
428 | 1672 } |
1673 | |
1674 #if 0 /* debugging functions */ | |
1675 | |
826 | 1676 DEFUN ("event-next", Fevent_next, 1, 1, 0, /* |
428 | 1677 Return the event object's `next' event, or nil if it has none. |
1678 The `next-event' field is changed by calling `set-next-event'. | |
1679 */ | |
1680 (event)) | |
1681 { | |
440 | 1682 Lisp_Event *e; |
428 | 1683 CHECK_LIVE_EVENT (event); |
1684 | |
1685 return XEVENT_NEXT (event); | |
1686 } | |
1687 | |
826 | 1688 DEFUN ("set-event-next", Fset_event_next, 2, 2, 0, /* |
428 | 1689 Set the `next event' of EVENT to NEXT-EVENT. |
1690 NEXT-EVENT must be an event object or nil. | |
1691 */ | |
1692 (event, next_event)) | |
1693 { | |
1694 Lisp_Object ev; | |
1695 | |
1696 CHECK_LIVE_EVENT (event); | |
1697 if (NILP (next_event)) | |
1698 { | |
1699 XSET_EVENT_NEXT (event, Qnil); | |
1700 return Qnil; | |
1701 } | |
1702 | |
1703 CHECK_LIVE_EVENT (next_event); | |
1704 | |
1705 EVENT_CHAIN_LOOP (ev, XEVENT_NEXT (event)) | |
1706 { | |
1707 QUIT; | |
1708 if (EQ (ev, event)) | |
563 | 1709 invalid_operation_2 ("Cyclic event-next", event, next_event); |
428 | 1710 } |
1711 XSET_EVENT_NEXT (event, next_event); | |
1712 return next_event; | |
1713 } | |
1714 | |
1715 #endif /* 0 */ | |
1716 | |
1717 DEFUN ("event-type", Fevent_type, 1, 1, 0, /* | |
1718 Return the type of EVENT. | |
1719 This will be a symbol; one of | |
1720 | |
1721 key-press A key was pressed. | |
1722 button-press A mouse button was pressed. | |
1723 button-release A mouse button was released. | |
1724 misc-user Some other user action happened; typically, this is | |
1725 a menu selection or scrollbar action. | |
1726 motion The mouse moved. | |
1727 process Input is available from a subprocess. | |
1728 timeout A timeout has expired. | |
1729 eval This causes a specified action to occur when dispatched. | |
1730 magic Some window-system-specific event has occurred. | |
1731 empty The event has been allocated but not assigned. | |
1732 | |
1733 */ | |
1734 (event)) | |
1735 { | |
1736 CHECK_LIVE_EVENT (event); | |
934 | 1737 switch (XEVENT_TYPE (event)) |
428 | 1738 { |
1739 case key_press_event: return Qkey_press; | |
1740 case button_press_event: return Qbutton_press; | |
1741 case button_release_event: return Qbutton_release; | |
1742 case misc_user_event: return Qmisc_user; | |
1743 case pointer_motion_event: return Qmotion; | |
1744 case process_event: return Qprocess; | |
1745 case timeout_event: return Qtimeout; | |
1746 case eval_event: return Qeval; | |
1747 case magic_event: | |
1748 case magic_eval_event: | |
1749 return Qmagic; | |
1750 | |
1751 case empty_event: | |
1752 return Qempty; | |
1753 | |
1754 default: | |
2500 | 1755 ABORT (); |
428 | 1756 return Qnil; |
1757 } | |
1758 } | |
1759 | |
1760 DEFUN ("event-timestamp", Fevent_timestamp, 1, 1, 0, /* | |
1761 Return the timestamp of the event object EVENT. | |
442 | 1762 Timestamps are measured in milliseconds since the start of the window system. |
1763 They are NOT related to any current time measurement. | |
1764 They should be compared with `event-timestamp<'. | |
1765 See also `current-event-timestamp'. | |
428 | 1766 */ |
1767 (event)) | |
1768 { | |
1769 CHECK_LIVE_EVENT (event); | |
1770 /* This junk is so that timestamps don't get to be negative, but contain | |
1771 as many bits as this particular emacs will allow. | |
1772 */ | |
2039 | 1773 return make_int (EMACS_INT_MAX & XEVENT_TIMESTAMP (event)); |
428 | 1774 } |
1775 | |
2039 | 1776 #define TIMESTAMP_HALFSPACE (1L << (INT_VALBITS - 2)) |
442 | 1777 |
1778 DEFUN ("event-timestamp<", Fevent_timestamp_lessp, 2, 2, 0, /* | |
1779 Return true if timestamp TIME1 is earlier than timestamp TIME2. | |
1780 This correctly handles timestamp wrap. | |
1781 See also `event-timestamp' and `current-event-timestamp'. | |
1782 */ | |
1783 (time1, time2)) | |
1784 { | |
1785 EMACS_INT t1, t2; | |
1786 | |
1787 CHECK_NATNUM (time1); | |
1788 CHECK_NATNUM (time2); | |
1789 t1 = XINT (time1); | |
1790 t2 = XINT (time2); | |
1791 | |
1792 if (t1 < t2) | |
1793 return t2 - t1 < TIMESTAMP_HALFSPACE ? Qt : Qnil; | |
1794 else | |
1795 return t1 - t2 < TIMESTAMP_HALFSPACE ? Qnil : Qt; | |
1796 } | |
1797 | |
934 | 1798 #define CHECK_EVENT_TYPE(e,t1,sym) do { \ |
1799 CHECK_LIVE_EVENT (e); \ | |
1800 if (XEVENT_TYPE (e) != (t1)) \ | |
1801 e = wrong_type_argument (sym,e); \ | |
1802 } while (0) | |
1803 | |
1804 #define CHECK_EVENT_TYPE2(e,t1,t2,sym) do { \ | |
1805 CHECK_LIVE_EVENT (e); \ | |
1806 { \ | |
1807 emacs_event_type CET_type = XEVENT_TYPE (e); \ | |
1808 if (CET_type != (t1) && \ | |
1809 CET_type != (t2)) \ | |
1810 e = wrong_type_argument (sym,e); \ | |
1811 } \ | |
1812 } while (0) | |
1813 | |
1814 #define CHECK_EVENT_TYPE3(e,t1,t2,t3,sym) do { \ | |
1815 CHECK_LIVE_EVENT (e); \ | |
1816 { \ | |
1817 emacs_event_type CET_type = XEVENT_TYPE (e); \ | |
1818 if (CET_type != (t1) && \ | |
1819 CET_type != (t2) && \ | |
1820 CET_type != (t3)) \ | |
1821 e = wrong_type_argument (sym,e); \ | |
1822 } \ | |
1823 } while (0) | |
428 | 1824 |
1825 DEFUN ("event-key", Fevent_key, 1, 1, 0, /* | |
1826 Return the Keysym of the key-press event EVENT. | |
1827 This will be a character if the event is associated with one, else a symbol. | |
1828 */ | |
1829 (event)) | |
1830 { | |
1831 CHECK_EVENT_TYPE (event, key_press_event, Qkey_press_event_p); | |
1204 | 1832 return XEVENT_KEY_KEYSYM (event); |
428 | 1833 } |
1834 | |
1835 DEFUN ("event-button", Fevent_button, 1, 1, 0, /* | |
444 | 1836 Return the button-number of the button-press or button-release event EVENT. |
428 | 1837 */ |
1838 (event)) | |
1839 { | |
1840 CHECK_EVENT_TYPE3 (event, button_press_event, button_release_event, | |
1841 misc_user_event, Qbutton_event_p); | |
1842 #ifdef HAVE_WINDOW_SYSTEM | |
1204 | 1843 if (XEVENT_TYPE (event) == misc_user_event) |
1844 return make_int (XEVENT_MISC_USER_BUTTON (event)); | |
934 | 1845 else |
1204 | 1846 return make_int (XEVENT_BUTTON_BUTTON (event)); |
428 | 1847 #else /* !HAVE_WINDOW_SYSTEM */ |
1848 return Qzero; | |
1849 #endif /* !HAVE_WINDOW_SYSTEM */ | |
1850 } | |
1851 | |
1852 DEFUN ("event-modifier-bits", Fevent_modifier_bits, 1, 1, 0, /* | |
442 | 1853 Return a number representing the modifier keys and buttons which were down |
428 | 1854 when the given mouse or keyboard event was produced. |
442 | 1855 See also the function `event-modifiers'. |
428 | 1856 */ |
1857 (event)) | |
1858 { | |
1859 again: | |
1860 CHECK_LIVE_EVENT (event); | |
934 | 1861 switch (XEVENT_TYPE (event)) |
1862 { | |
1863 case key_press_event: | |
1204 | 1864 return make_int (XEVENT_KEY_MODIFIERS (event)); |
934 | 1865 case button_press_event: |
1866 case button_release_event: | |
1204 | 1867 return make_int (XEVENT_BUTTON_MODIFIERS (event)); |
934 | 1868 case pointer_motion_event: |
1204 | 1869 return make_int (XEVENT_MOTION_MODIFIERS (event)); |
934 | 1870 case misc_user_event: |
1204 | 1871 return make_int (XEVENT_MISC_USER_MODIFIERS (event)); |
934 | 1872 default: |
1873 event = wrong_type_argument (intern ("key-or-mouse-event-p"), event); | |
1874 goto again; | |
1875 } | |
428 | 1876 } |
1877 | |
1878 DEFUN ("event-modifiers", Fevent_modifiers, 1, 1, 0, /* | |
442 | 1879 Return a list of symbols, the names of the modifier keys and buttons |
428 | 1880 which were down when the given mouse or keyboard event was produced. |
442 | 1881 See also the function `event-modifier-bits'. |
1882 | |
1883 The possible symbols in the list are | |
1884 | |
1885 `shift': The Shift key. Will not appear, in general, on key events | |
1886 where the keysym is an ASCII character, because using Shift | |
1887 on such a character converts it into another character rather | |
1888 than actually just adding a Shift modifier. | |
1889 | |
1890 `control': The Control key. | |
1891 | |
1892 `meta': The Meta key. On PC's and PC-style keyboards, this is generally | |
1893 labelled \"Alt\"; Meta is a holdover from early Lisp Machines and | |
1894 such, propagated through the X Window System. On Sun keyboards, | |
1895 this key is labelled with a diamond. | |
1896 | |
1897 `alt': The \"Alt\" key. Alt is in quotes because this does not refer | |
1898 to what it obviously should refer to, namely the Alt key on PC | |
1899 keyboards. Instead, it refers to the key labelled Alt on Sun | |
1900 keyboards, and to no key at all on PC keyboards. | |
1901 | |
1902 `super': The Super key. Most keyboards don't have any such key, but | |
1903 under X Windows using `xmodmap' you can assign any key (such as | |
1904 an underused right-shift, right-control, or right-alt key) to | |
1905 this key modifier. No support currently exists under MS Windows | |
1906 for generating these modifiers. | |
1907 | |
1908 `hyper': The Hyper key. Works just like the Super key. | |
1909 | |
1910 `button1': The mouse buttons. This means that the specified button was held | |
1911 `button2': down at the time the event occurred. NOTE: For button-press | |
1912 `button3': events, the button that was just pressed down does NOT appear in | |
1913 `button4': the modifiers. | |
1914 `button5': | |
1915 | |
1916 Button modifiers are currently ignored when defining and looking up key and | |
1917 mouse strokes in keymaps. This could be changed, which would allow a user to | |
1918 create button-chord actions, use a button as a key modifier and do other | |
1919 clever things. | |
428 | 1920 */ |
1921 (event)) | |
1922 { | |
1923 int mod = XINT (Fevent_modifier_bits (event)); | |
1924 Lisp_Object result = Qnil; | |
442 | 1925 struct gcpro gcpro1; |
1926 | |
1927 GCPRO1 (result); | |
1928 if (mod & XEMACS_MOD_SHIFT) result = Fcons (Qshift, result); | |
1929 if (mod & XEMACS_MOD_ALT) result = Fcons (Qalt, result); | |
1930 if (mod & XEMACS_MOD_HYPER) result = Fcons (Qhyper, result); | |
1931 if (mod & XEMACS_MOD_SUPER) result = Fcons (Qsuper, result); | |
1932 if (mod & XEMACS_MOD_META) result = Fcons (Qmeta, result); | |
1933 if (mod & XEMACS_MOD_CONTROL) result = Fcons (Qcontrol, result); | |
1934 if (mod & XEMACS_MOD_BUTTON1) result = Fcons (Qbutton1, result); | |
1935 if (mod & XEMACS_MOD_BUTTON2) result = Fcons (Qbutton2, result); | |
1936 if (mod & XEMACS_MOD_BUTTON3) result = Fcons (Qbutton3, result); | |
1937 if (mod & XEMACS_MOD_BUTTON4) result = Fcons (Qbutton4, result); | |
1938 if (mod & XEMACS_MOD_BUTTON5) result = Fcons (Qbutton5, result); | |
1939 RETURN_UNGCPRO (Fnreverse (result)); | |
428 | 1940 } |
1941 | |
1942 static int | |
1943 event_x_y_pixel_internal (Lisp_Object event, int *x, int *y, int relative) | |
1944 { | |
1945 struct window *w; | |
1946 struct frame *f; | |
1947 | |
934 | 1948 if (XEVENT_TYPE (event) == pointer_motion_event) |
1949 { | |
1204 | 1950 *x = XEVENT_MOTION_X (event); |
1951 *y = XEVENT_MOTION_Y (event); | |
934 | 1952 } |
1953 else if (XEVENT_TYPE (event) == button_press_event || | |
1954 XEVENT_TYPE (event) == button_release_event) | |
1955 { | |
1204 | 1956 *x = XEVENT_BUTTON_X (event); |
1957 *y = XEVENT_BUTTON_Y (event); | |
934 | 1958 } |
1959 else if (XEVENT_TYPE (event) == misc_user_event) | |
1960 { | |
1204 | 1961 *x = XEVENT_MISC_USER_X (event); |
1962 *y = XEVENT_MISC_USER_Y (event); | |
934 | 1963 } |
1964 else | |
1965 return 0; | |
428 | 1966 f = XFRAME (EVENT_CHANNEL (XEVENT (event))); |
1967 | |
1968 if (relative) | |
1969 { | |
1970 w = find_window_by_pixel_pos (*x, *y, f->root_window); | |
1971 | |
1972 if (!w) | |
442 | 1973 return 1; /* #### What should really happen here? */ |
428 | 1974 |
1975 *x -= w->pixel_left; | |
1976 *y -= w->pixel_top; | |
1977 } | |
1978 else | |
1979 { | |
1980 *y -= FRAME_REAL_TOP_TOOLBAR_HEIGHT (f) - | |
1981 FRAME_REAL_TOP_TOOLBAR_BORDER_WIDTH (f); | |
1982 *x -= FRAME_REAL_LEFT_TOOLBAR_WIDTH (f) - | |
1983 FRAME_REAL_LEFT_TOOLBAR_BORDER_WIDTH (f); | |
1984 } | |
1985 | |
1986 return 1; | |
1987 } | |
1988 | |
1989 DEFUN ("event-window-x-pixel", Fevent_window_x_pixel, 1, 1, 0, /* | |
1990 Return the X position in pixels of mouse event EVENT. | |
1991 The value returned is relative to the window the event occurred in. | |
1992 This will signal an error if the event is not a mouse event. | |
1993 See also `mouse-event-p' and `event-x-pixel'. | |
1994 */ | |
1995 (event)) | |
1996 { | |
1997 int x, y; | |
1998 | |
1999 CHECK_LIVE_EVENT (event); | |
2000 | |
2001 if (!event_x_y_pixel_internal (event, &x, &y, 1)) | |
2002 return wrong_type_argument (Qmouse_event_p, event); | |
2003 else | |
2004 return make_int (x); | |
2005 } | |
2006 | |
2007 DEFUN ("event-window-y-pixel", Fevent_window_y_pixel, 1, 1, 0, /* | |
2008 Return the Y position in pixels of mouse event EVENT. | |
2009 The value returned is relative to the window the event occurred in. | |
2010 This will signal an error if the event is not a mouse event. | |
2011 See also `mouse-event-p' and `event-y-pixel'. | |
2012 */ | |
2013 (event)) | |
2014 { | |
2015 int x, y; | |
2016 | |
2017 CHECK_LIVE_EVENT (event); | |
2018 | |
2019 if (!event_x_y_pixel_internal (event, &x, &y, 1)) | |
2020 return wrong_type_argument (Qmouse_event_p, event); | |
2021 else | |
2022 return make_int (y); | |
2023 } | |
2024 | |
2025 DEFUN ("event-x-pixel", Fevent_x_pixel, 1, 1, 0, /* | |
2026 Return the X position in pixels of mouse event EVENT. | |
2027 The value returned is relative to the frame the event occurred in. | |
2028 This will signal an error if the event is not a mouse event. | |
2029 See also `mouse-event-p' and `event-window-x-pixel'. | |
2030 */ | |
2031 (event)) | |
2032 { | |
2033 int x, y; | |
2034 | |
2035 CHECK_LIVE_EVENT (event); | |
2036 | |
2037 if (!event_x_y_pixel_internal (event, &x, &y, 0)) | |
2038 return wrong_type_argument (Qmouse_event_p, event); | |
2039 else | |
2040 return make_int (x); | |
2041 } | |
2042 | |
2043 DEFUN ("event-y-pixel", Fevent_y_pixel, 1, 1, 0, /* | |
2044 Return the Y position in pixels of mouse event EVENT. | |
2045 The value returned is relative to the frame the event occurred in. | |
2046 This will signal an error if the event is not a mouse event. | |
2047 See also `mouse-event-p' `event-window-y-pixel'. | |
2048 */ | |
2049 (event)) | |
2050 { | |
2051 int x, y; | |
2052 | |
2053 CHECK_LIVE_EVENT (event); | |
2054 | |
2055 if (!event_x_y_pixel_internal (event, &x, &y, 0)) | |
2056 return wrong_type_argument (Qmouse_event_p, event); | |
2057 else | |
2058 return make_int (y); | |
2059 } | |
2060 | |
2061 /* Given an event, return a value: | |
2062 | |
2063 OVER_TOOLBAR: over one of the 4 frame toolbars | |
2064 OVER_MODELINE: over a modeline | |
2065 OVER_BORDER: over an internal border | |
2066 OVER_NOTHING: over the text area, but not over text | |
2067 OVER_OUTSIDE: outside of the frame border | |
2068 OVER_TEXT: over text in the text area | |
2069 OVER_V_DIVIDER: over windows vertical divider | |
2070 | |
2071 and return: | |
2072 | |
2073 The X char position in CHAR_X, if not a null pointer. | |
2074 The Y char position in CHAR_Y, if not a null pointer. | |
2075 (These last two values are relative to the window the event is over.) | |
2076 The window it's over in W, if not a null pointer. | |
2077 The buffer position it's over in BUFP, if not a null pointer. | |
2078 The closest buffer position in CLOSEST, if not a null pointer. | |
2079 | |
2080 OBJ_X, OBJ_Y, OBJ1, and OBJ2 are as in pixel_to_glyph_translation(). | |
2081 */ | |
2082 | |
2083 static int | |
2084 event_pixel_translation (Lisp_Object event, int *char_x, int *char_y, | |
2085 int *obj_x, int *obj_y, | |
665 | 2086 struct window **w, Charbpos *bufp, Charbpos *closest, |
428 | 2087 Charcount *modeline_closest, |
2088 Lisp_Object *obj1, Lisp_Object *obj2) | |
2089 { | |
2090 int pix_x = 0; | |
2091 int pix_y = 0; | |
2092 int result; | |
2093 Lisp_Object frame; | |
2094 | |
2095 int ret_x, ret_y, ret_obj_x, ret_obj_y; | |
2096 struct window *ret_w; | |
665 | 2097 Charbpos ret_bufp, ret_closest; |
428 | 2098 Charcount ret_modeline_closest; |
2099 Lisp_Object ret_obj1, ret_obj2; | |
2100 | |
2101 CHECK_LIVE_EVENT (event); | |
934 | 2102 frame = XEVENT_CHANNEL (event); |
2103 switch (XEVENT_TYPE (event)) | |
2104 { | |
2105 case pointer_motion_event : | |
1204 | 2106 pix_x = XEVENT_MOTION_X (event); |
2107 pix_y = XEVENT_MOTION_Y (event); | |
934 | 2108 break; |
2109 case button_press_event : | |
2110 case button_release_event : | |
1204 | 2111 pix_x = XEVENT_BUTTON_X (event); |
2112 pix_y = XEVENT_BUTTON_Y (event); | |
934 | 2113 break; |
2114 case misc_user_event : | |
1204 | 2115 pix_x = XEVENT_MISC_USER_X (event); |
2116 pix_y = XEVENT_MISC_USER_Y (event); | |
934 | 2117 break; |
2118 default: | |
2119 dead_wrong_type_argument (Qmouse_event_p, event); | |
2120 } | |
428 | 2121 |
2122 result = pixel_to_glyph_translation (XFRAME (frame), pix_x, pix_y, | |
2123 &ret_x, &ret_y, &ret_obj_x, &ret_obj_y, | |
2124 &ret_w, &ret_bufp, &ret_closest, | |
2125 &ret_modeline_closest, | |
2126 &ret_obj1, &ret_obj2); | |
2127 | |
2128 if (result == OVER_NOTHING || result == OVER_OUTSIDE) | |
2129 ret_bufp = 0; | |
2130 else if (ret_w && NILP (ret_w->buffer)) | |
2131 /* Why does this happen? (Does it still happen?) | |
2132 I guess the window has gotten reused as a non-leaf... */ | |
2133 ret_w = 0; | |
2134 | |
2135 /* #### pixel_to_glyph_translation() sometimes returns garbage... | |
2136 The word has type Lisp_Type_Record (presumably meaning `extent') but the | |
2137 pointer points to random memory, often filled with 0, sometimes not. | |
2138 */ | |
2139 /* #### Chuck, do we still need this crap? */ | |
2140 if (!NILP (ret_obj1) && !(GLYPHP (ret_obj1) | |
2141 #ifdef HAVE_TOOLBARS | |
2142 || TOOLBAR_BUTTONP (ret_obj1) | |
2143 #endif | |
2144 )) | |
2500 | 2145 ABORT (); |
428 | 2146 if (!NILP (ret_obj2) && !(EXTENTP (ret_obj2) || CONSP (ret_obj2))) |
2500 | 2147 ABORT (); |
428 | 2148 |
2149 if (char_x) | |
2150 *char_x = ret_x; | |
2151 if (char_y) | |
2152 *char_y = ret_y; | |
2153 if (obj_x) | |
2154 *obj_x = ret_obj_x; | |
2155 if (obj_y) | |
2156 *obj_y = ret_obj_y; | |
2157 if (w) | |
2158 *w = ret_w; | |
2159 if (bufp) | |
2160 *bufp = ret_bufp; | |
2161 if (closest) | |
2162 *closest = ret_closest; | |
2163 if (modeline_closest) | |
2164 *modeline_closest = ret_modeline_closest; | |
2165 if (obj1) | |
2166 *obj1 = ret_obj1; | |
2167 if (obj2) | |
2168 *obj2 = ret_obj2; | |
2169 | |
2170 return result; | |
2171 } | |
2172 | |
2173 DEFUN ("event-over-text-area-p", Fevent_over_text_area_p, 1, 1, 0, /* | |
2174 Return t if the mouse event EVENT occurred over the text area of a window. | |
2175 The modeline is not considered to be part of the text area. | |
2176 */ | |
2177 (event)) | |
2178 { | |
2179 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | |
2180 | |
2181 return result == OVER_TEXT || result == OVER_NOTHING ? Qt : Qnil; | |
2182 } | |
2183 | |
2184 DEFUN ("event-over-modeline-p", Fevent_over_modeline_p, 1, 1, 0, /* | |
2185 Return t if the mouse event EVENT occurred over the modeline of a window. | |
2186 */ | |
2187 (event)) | |
2188 { | |
2189 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | |
2190 | |
2191 return result == OVER_MODELINE ? Qt : Qnil; | |
2192 } | |
2193 | |
2194 DEFUN ("event-over-border-p", Fevent_over_border_p, 1, 1, 0, /* | |
2195 Return t if the mouse event EVENT occurred over an internal border. | |
2196 */ | |
2197 (event)) | |
2198 { | |
2199 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | |
2200 | |
2201 return result == OVER_BORDER ? Qt : Qnil; | |
2202 } | |
2203 | |
2204 DEFUN ("event-over-toolbar-p", Fevent_over_toolbar_p, 1, 1, 0, /* | |
2205 Return t if the mouse event EVENT occurred over a toolbar. | |
2206 */ | |
2207 (event)) | |
2208 { | |
2209 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | |
2210 | |
2211 return result == OVER_TOOLBAR ? Qt : Qnil; | |
2212 } | |
2213 | |
2214 DEFUN ("event-over-vertical-divider-p", Fevent_over_vertical_divider_p, 1, 1, 0, /* | |
2215 Return t if the mouse event EVENT occurred over a window divider. | |
2216 */ | |
2217 (event)) | |
2218 { | |
2219 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | |
2220 | |
2221 return result == OVER_V_DIVIDER ? Qt : Qnil; | |
2222 } | |
2223 | |
2224 struct console * | |
2225 event_console_or_selected (Lisp_Object event) | |
2226 { | |
2227 Lisp_Object channel = EVENT_CHANNEL (XEVENT (event)); | |
2228 Lisp_Object console = CDFW_CONSOLE (channel); | |
2229 | |
2230 if (NILP (console)) | |
2231 console = Vselected_console; | |
2232 | |
2233 return XCONSOLE (console); | |
2234 } | |
2235 | |
2236 DEFUN ("event-channel", Fevent_channel, 1, 1, 0, /* | |
2237 Return the channel that the event EVENT occurred on. | |
2238 This will be a frame, device, console, or nil for some types | |
2239 of events (e.g. eval events). | |
2240 */ | |
2241 (event)) | |
2242 { | |
2243 CHECK_LIVE_EVENT (event); | |
2244 return EVENT_CHANNEL (XEVENT (event)); | |
2245 } | |
2246 | |
2247 DEFUN ("event-window", Fevent_window, 1, 1, 0, /* | |
2248 Return the window over which mouse event EVENT occurred. | |
2249 This may be nil if the event occurred in the border or over a toolbar. | |
2250 The modeline is considered to be within the window it describes. | |
2251 */ | |
2252 (event)) | |
2253 { | |
2254 struct window *w; | |
2255 | |
2256 event_pixel_translation (event, 0, 0, 0, 0, &w, 0, 0, 0, 0, 0); | |
2257 | |
2258 if (!w) | |
2259 return Qnil; | |
2260 else | |
2261 { | |
793 | 2262 return wrap_window (w); |
428 | 2263 } |
2264 } | |
2265 | |
2266 DEFUN ("event-point", Fevent_point, 1, 1, 0, /* | |
2267 Return the character position of the mouse event EVENT. | |
2268 If the event did not occur over a window, or did not occur over text, | |
2269 then this returns nil. Otherwise, it returns a position in the buffer | |
2270 visible in the event's window. | |
2271 */ | |
2272 (event)) | |
2273 { | |
665 | 2274 Charbpos bufp; |
428 | 2275 struct window *w; |
2276 | |
2277 event_pixel_translation (event, 0, 0, 0, 0, &w, &bufp, 0, 0, 0, 0); | |
2278 | |
2279 return w && bufp ? make_int (bufp) : Qnil; | |
2280 } | |
2281 | |
2282 DEFUN ("event-closest-point", Fevent_closest_point, 1, 1, 0, /* | |
2283 Return the character position closest to the mouse event EVENT. | |
2284 If the event did not occur over a window or over text, return the | |
2285 closest point to the location of the event. If the Y pixel position | |
2286 overlaps a window and the X pixel position is to the left of that | |
2287 window, the closest point is the beginning of the line containing the | |
2288 Y position. If the Y pixel position overlaps a window and the X pixel | |
2289 position is to the right of that window, the closest point is the end | |
2290 of the line containing the Y position. If the Y pixel position is | |
2291 above a window, return 0. If it is below the last character in a window, | |
2292 return the value of (window-end). | |
2293 */ | |
2294 (event)) | |
2295 { | |
665 | 2296 Charbpos bufp; |
428 | 2297 |
2298 event_pixel_translation (event, 0, 0, 0, 0, 0, 0, &bufp, 0, 0, 0); | |
2299 | |
2300 return bufp ? make_int (bufp) : Qnil; | |
2301 } | |
2302 | |
2303 DEFUN ("event-x", Fevent_x, 1, 1, 0, /* | |
2304 Return the X position of the mouse event EVENT in characters. | |
2305 This is relative to the window the event occurred over. | |
2306 */ | |
2307 (event)) | |
2308 { | |
2309 int char_x; | |
2310 | |
2311 event_pixel_translation (event, &char_x, 0, 0, 0, 0, 0, 0, 0, 0, 0); | |
2312 | |
2313 return make_int (char_x); | |
2314 } | |
2315 | |
2316 DEFUN ("event-y", Fevent_y, 1, 1, 0, /* | |
2317 Return the Y position of the mouse event EVENT in characters. | |
2318 This is relative to the window the event occurred over. | |
2319 */ | |
2320 (event)) | |
2321 { | |
2322 int char_y; | |
2323 | |
2324 event_pixel_translation (event, 0, &char_y, 0, 0, 0, 0, 0, 0, 0, 0); | |
2325 | |
2326 return make_int (char_y); | |
2327 } | |
2328 | |
2329 DEFUN ("event-modeline-position", Fevent_modeline_position, 1, 1, 0, /* | |
2330 Return the character position in the modeline that EVENT occurred over. | |
2331 EVENT should be a mouse event. If EVENT did not occur over a modeline, | |
2332 nil is returned. You can determine the actual character that the | |
2333 event occurred over by looking in `generated-modeline-string' at the | |
2334 returned character position. Note that `generated-modeline-string' | |
2335 is buffer-local, and you must use EVENT's buffer when retrieving | |
2336 `generated-modeline-string' in order to get accurate results. | |
2337 */ | |
2338 (event)) | |
2339 { | |
2340 Charcount mbufp; | |
2341 int where; | |
2342 | |
2343 where = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, &mbufp, 0, 0); | |
2344 | |
2345 return (mbufp < 0 || where != OVER_MODELINE) ? Qnil : make_int (mbufp); | |
2346 } | |
2347 | |
2348 DEFUN ("event-glyph", Fevent_glyph, 1, 1, 0, /* | |
2349 Return the glyph that the mouse event EVENT occurred over, or nil. | |
2350 */ | |
2351 (event)) | |
2352 { | |
2353 Lisp_Object glyph; | |
2354 struct window *w; | |
2355 | |
2356 event_pixel_translation (event, 0, 0, 0, 0, &w, 0, 0, 0, &glyph, 0); | |
2357 | |
2358 return w && GLYPHP (glyph) ? glyph : Qnil; | |
2359 } | |
2360 | |
2361 DEFUN ("event-glyph-extent", Fevent_glyph_extent, 1, 1, 0, /* | |
2362 Return the extent of the glyph that the mouse event EVENT occurred over. | |
2363 If the event did not occur over a glyph, nil is returned. | |
2364 */ | |
2365 (event)) | |
2366 { | |
2367 Lisp_Object extent; | |
2368 struct window *w; | |
2369 | |
2370 event_pixel_translation (event, 0, 0, 0, 0, &w, 0, 0, 0, 0, &extent); | |
2371 | |
2372 return w && EXTENTP (extent) ? extent : Qnil; | |
2373 } | |
2374 | |
2375 DEFUN ("event-glyph-x-pixel", Fevent_glyph_x_pixel, 1, 1, 0, /* | |
2376 Return the X pixel position of EVENT relative to the glyph it occurred over. | |
2377 EVENT should be a mouse event. If the event did not occur over a glyph, | |
2378 nil is returned. | |
2379 */ | |
2380 (event)) | |
2381 { | |
2382 Lisp_Object extent; | |
2383 struct window *w; | |
2384 int obj_x; | |
2385 | |
2386 event_pixel_translation (event, 0, 0, &obj_x, 0, &w, 0, 0, 0, 0, &extent); | |
2387 | |
2388 return w && EXTENTP (extent) ? make_int (obj_x) : Qnil; | |
2389 } | |
2390 | |
2391 DEFUN ("event-glyph-y-pixel", Fevent_glyph_y_pixel, 1, 1, 0, /* | |
2392 Return the Y pixel position of EVENT relative to the glyph it occurred over. | |
2393 EVENT should be a mouse event. If the event did not occur over a glyph, | |
2394 nil is returned. | |
2395 */ | |
2396 (event)) | |
2397 { | |
2398 Lisp_Object extent; | |
2399 struct window *w; | |
2400 int obj_y; | |
2401 | |
2402 event_pixel_translation (event, 0, 0, 0, &obj_y, &w, 0, 0, 0, 0, &extent); | |
2403 | |
2404 return w && EXTENTP (extent) ? make_int (obj_y) : Qnil; | |
2405 } | |
2406 | |
2407 DEFUN ("event-toolbar-button", Fevent_toolbar_button, 1, 1, 0, /* | |
2408 Return the toolbar button that the mouse event EVENT occurred over. | |
2409 If the event did not occur over a toolbar button, nil is returned. | |
2410 */ | |
2340 | 2411 (USED_IF_TOOLBARS (event))) |
428 | 2412 { |
2413 #ifdef HAVE_TOOLBARS | |
2414 Lisp_Object button; | |
2415 | |
2416 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, &button, 0); | |
2417 | |
2418 return result == OVER_TOOLBAR && TOOLBAR_BUTTONP (button) ? button : Qnil; | |
2419 #else | |
2420 return Qnil; | |
2421 #endif | |
2422 } | |
2423 | |
2424 DEFUN ("event-process", Fevent_process, 1, 1, 0, /* | |
444 | 2425 Return the process of the process-output event EVENT. |
428 | 2426 */ |
2427 (event)) | |
2428 { | |
934 | 2429 CHECK_EVENT_TYPE (event, process_event, Qprocess_event_p); |
1204 | 2430 return XEVENT_PROCESS_PROCESS (event); |
428 | 2431 } |
2432 | |
2433 DEFUN ("event-function", Fevent_function, 1, 1, 0, /* | |
2434 Return the callback function of EVENT. | |
2435 EVENT should be a timeout, misc-user, or eval event. | |
2436 */ | |
2437 (event)) | |
2438 { | |
2439 again: | |
2440 CHECK_LIVE_EVENT (event); | |
934 | 2441 switch (XEVENT_TYPE (event)) |
2442 { | |
2443 case timeout_event: | |
1204 | 2444 return XEVENT_TIMEOUT_FUNCTION (event); |
934 | 2445 case misc_user_event: |
1204 | 2446 return XEVENT_MISC_USER_FUNCTION (event); |
934 | 2447 case eval_event: |
1204 | 2448 return XEVENT_EVAL_FUNCTION (event); |
934 | 2449 default: |
2450 event = wrong_type_argument (intern ("timeout-or-eval-event-p"), event); | |
2451 goto again; | |
2452 } | |
428 | 2453 } |
2454 | |
2455 DEFUN ("event-object", Fevent_object, 1, 1, 0, /* | |
2456 Return the callback function argument of EVENT. | |
2457 EVENT should be a timeout, misc-user, or eval event. | |
2458 */ | |
2459 (event)) | |
2460 { | |
2461 again: | |
2462 CHECK_LIVE_EVENT (event); | |
934 | 2463 switch (XEVENT_TYPE (event)) |
2464 { | |
2465 case timeout_event: | |
1204 | 2466 return XEVENT_TIMEOUT_OBJECT (event); |
934 | 2467 case misc_user_event: |
1204 | 2468 return XEVENT_MISC_USER_OBJECT (event); |
934 | 2469 case eval_event: |
1204 | 2470 return XEVENT_EVAL_OBJECT (event); |
934 | 2471 default: |
2472 event = wrong_type_argument (intern ("timeout-or-eval-event-p"), event); | |
2473 goto again; | |
2474 } | |
428 | 2475 } |
2476 | |
2477 DEFUN ("event-properties", Fevent_properties, 1, 1, 0, /* | |
2478 Return a list of all of the properties of EVENT. | |
2479 This is in the form of a property list (alternating keyword/value pairs). | |
2480 */ | |
2481 (event)) | |
2482 { | |
2483 Lisp_Object props = Qnil; | |
440 | 2484 Lisp_Event *e; |
428 | 2485 struct gcpro gcpro1; |
2486 | |
2487 CHECK_LIVE_EVENT (event); | |
2488 e = XEVENT (event); | |
2489 GCPRO1 (props); | |
2490 | |
2491 props = cons3 (Qtimestamp, Fevent_timestamp (event), props); | |
2492 | |
934 | 2493 switch (EVENT_TYPE (e)) |
428 | 2494 { |
2500 | 2495 default: ABORT (); |
428 | 2496 |
2497 case process_event: | |
1204 | 2498 props = cons3 (Qprocess, EVENT_PROCESS_PROCESS (e), props); |
428 | 2499 break; |
2500 | |
2501 case timeout_event: | |
2502 props = cons3 (Qobject, Fevent_object (event), props); | |
2503 props = cons3 (Qfunction, Fevent_function (event), props); | |
1204 | 2504 props = cons3 (Qid, make_int (EVENT_TIMEOUT_ID_NUMBER (e)), props); |
428 | 2505 break; |
2506 | |
2507 case key_press_event: | |
2508 props = cons3 (Qmodifiers, Fevent_modifiers (event), props); | |
2509 props = cons3 (Qkey, Fevent_key (event), props); | |
2510 break; | |
2511 | |
2512 case button_press_event: | |
2513 case button_release_event: | |
2514 props = cons3 (Qy, Fevent_y_pixel (event), props); | |
2515 props = cons3 (Qx, Fevent_x_pixel (event), props); | |
2516 props = cons3 (Qmodifiers, Fevent_modifiers (event), props); | |
2517 props = cons3 (Qbutton, Fevent_button (event), props); | |
2518 break; | |
2519 | |
2520 case pointer_motion_event: | |
2521 props = cons3 (Qmodifiers, Fevent_modifiers (event), props); | |
2522 props = cons3 (Qy, Fevent_y_pixel (event), props); | |
2523 props = cons3 (Qx, Fevent_x_pixel (event), props); | |
2524 break; | |
2525 | |
2526 case misc_user_event: | |
2527 props = cons3 (Qobject, Fevent_object (event), props); | |
2528 props = cons3 (Qfunction, Fevent_function (event), props); | |
2529 props = cons3 (Qy, Fevent_y_pixel (event), props); | |
2530 props = cons3 (Qx, Fevent_x_pixel (event), props); | |
2531 props = cons3 (Qmodifiers, Fevent_modifiers (event), props); | |
2532 props = cons3 (Qbutton, Fevent_button (event), props); | |
2533 break; | |
2534 | |
2535 case eval_event: | |
2536 props = cons3 (Qobject, Fevent_object (event), props); | |
2537 props = cons3 (Qfunction, Fevent_function (event), props); | |
2538 break; | |
2539 | |
2540 case magic_eval_event: | |
2541 case magic_event: | |
2542 break; | |
2543 | |
2544 case empty_event: | |
2545 RETURN_UNGCPRO (Qnil); | |
2546 break; | |
2547 } | |
2548 | |
2549 props = cons3 (Qchannel, Fevent_channel (event), props); | |
2550 UNGCPRO; | |
2551 | |
2552 return props; | |
2553 } | |
2554 | |
2555 | |
2556 /************************************************************************/ | |
2557 /* initialization */ | |
2558 /************************************************************************/ | |
2559 | |
2560 void | |
2561 syms_of_events (void) | |
2562 { | |
442 | 2563 INIT_LRECORD_IMPLEMENTATION (event); |
1204 | 2564 #ifdef EVENT_DATA_AS_OBJECTS |
934 | 2565 INIT_LRECORD_IMPLEMENTATION (key_data); |
2566 INIT_LRECORD_IMPLEMENTATION (button_data); | |
2567 INIT_LRECORD_IMPLEMENTATION (motion_data); | |
2568 INIT_LRECORD_IMPLEMENTATION (process_data); | |
2569 INIT_LRECORD_IMPLEMENTATION (timeout_data); | |
2570 INIT_LRECORD_IMPLEMENTATION (eval_data); | |
2571 INIT_LRECORD_IMPLEMENTATION (misc_user_data); | |
2572 INIT_LRECORD_IMPLEMENTATION (magic_eval_data); | |
2573 INIT_LRECORD_IMPLEMENTATION (magic_data); | |
1204 | 2574 #endif /* EVENT_DATA_AS_OBJECTS */ |
442 | 2575 |
428 | 2576 DEFSUBR (Fcharacter_to_event); |
2577 DEFSUBR (Fevent_to_character); | |
2578 | |
2579 DEFSUBR (Fmake_event); | |
2580 DEFSUBR (Fdeallocate_event); | |
2581 DEFSUBR (Fcopy_event); | |
2582 DEFSUBR (Feventp); | |
2583 DEFSUBR (Fevent_live_p); | |
2584 DEFSUBR (Fevent_type); | |
2585 DEFSUBR (Fevent_properties); | |
2586 | |
2587 DEFSUBR (Fevent_timestamp); | |
442 | 2588 DEFSUBR (Fevent_timestamp_lessp); |
428 | 2589 DEFSUBR (Fevent_key); |
2590 DEFSUBR (Fevent_button); | |
2591 DEFSUBR (Fevent_modifier_bits); | |
2592 DEFSUBR (Fevent_modifiers); | |
2593 DEFSUBR (Fevent_x_pixel); | |
2594 DEFSUBR (Fevent_y_pixel); | |
2595 DEFSUBR (Fevent_window_x_pixel); | |
2596 DEFSUBR (Fevent_window_y_pixel); | |
2597 DEFSUBR (Fevent_over_text_area_p); | |
2598 DEFSUBR (Fevent_over_modeline_p); | |
2599 DEFSUBR (Fevent_over_border_p); | |
2600 DEFSUBR (Fevent_over_toolbar_p); | |
2601 DEFSUBR (Fevent_over_vertical_divider_p); | |
2602 DEFSUBR (Fevent_channel); | |
2603 DEFSUBR (Fevent_window); | |
2604 DEFSUBR (Fevent_point); | |
2605 DEFSUBR (Fevent_closest_point); | |
2606 DEFSUBR (Fevent_x); | |
2607 DEFSUBR (Fevent_y); | |
2608 DEFSUBR (Fevent_modeline_position); | |
2609 DEFSUBR (Fevent_glyph); | |
2610 DEFSUBR (Fevent_glyph_extent); | |
2611 DEFSUBR (Fevent_glyph_x_pixel); | |
2612 DEFSUBR (Fevent_glyph_y_pixel); | |
2613 DEFSUBR (Fevent_toolbar_button); | |
2614 DEFSUBR (Fevent_process); | |
2615 DEFSUBR (Fevent_function); | |
2616 DEFSUBR (Fevent_object); | |
2617 | |
563 | 2618 DEFSYMBOL (Qeventp); |
2619 DEFSYMBOL (Qevent_live_p); | |
2620 DEFSYMBOL (Qkey_press_event_p); | |
2621 DEFSYMBOL (Qbutton_event_p); | |
2622 DEFSYMBOL (Qmouse_event_p); | |
2623 DEFSYMBOL (Qprocess_event_p); | |
2624 DEFSYMBOL (Qkey_press); | |
2625 DEFSYMBOL (Qbutton_press); | |
2626 DEFSYMBOL (Qbutton_release); | |
2627 DEFSYMBOL (Qmisc_user); | |
2828 | 2628 DEFSYMBOL (Qcharacter_of_keysym); |
563 | 2629 DEFSYMBOL (Qascii_character); |
428 | 2630 |
2631 defsymbol (&QKbackspace, "backspace"); | |
2632 defsymbol (&QKtab, "tab"); | |
2633 defsymbol (&QKlinefeed, "linefeed"); | |
2634 defsymbol (&QKreturn, "return"); | |
2635 defsymbol (&QKescape, "escape"); | |
2636 defsymbol (&QKspace, "space"); | |
2637 defsymbol (&QKdelete, "delete"); | |
2638 } | |
2639 | |
2640 | |
2641 void | |
2642 reinit_vars_of_events (void) | |
2643 { | |
2644 Vevent_resource = Qnil; | |
3092 | 2645 #ifdef NEW_GC |
2646 staticpro (&Vevent_resource); | |
2647 #endif /* NEW_GC */ | |
428 | 2648 } |
2649 | |
2650 void | |
2651 vars_of_events (void) | |
2652 { | |
2653 } |