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.
|
788
|
4 Copyright (C) 2001, 2002 Ben Wing.
|
428
|
5
|
|
6 This file is part of XEmacs.
|
|
7
|
|
8 XEmacs is free software; you can redistribute it and/or modify it
|
|
9 under the terms of the GNU General Public License as published by the
|
|
10 Free Software Foundation; either version 2, or (at your option) any
|
|
11 later version.
|
|
12
|
|
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
16 for more details.
|
|
17
|
|
18 You should have received a copy of the GNU General Public License
|
|
19 along with XEmacs; see the file COPYING. If not, write to
|
|
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
21 Boston, MA 02111-1307, USA. */
|
|
22
|
|
23 /* Synched up with: Not in FSF. */
|
|
24
|
|
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
|
934
|
44 #ifdef USE_KKCC
|
|
45 #include "console-x.h"
|
|
46 #endif /* USE_KKCC */
|
|
47
|
428
|
48 /* Where old events go when they are explicitly deallocated.
|
|
49 The event chain here is cut loose before GC, so these will be freed
|
|
50 eventually.
|
|
51 */
|
|
52 static Lisp_Object Vevent_resource;
|
|
53
|
|
54 Lisp_Object Qeventp;
|
|
55 Lisp_Object Qevent_live_p;
|
|
56 Lisp_Object Qkey_press_event_p;
|
|
57 Lisp_Object Qbutton_event_p;
|
|
58 Lisp_Object Qmouse_event_p;
|
|
59 Lisp_Object Qprocess_event_p;
|
|
60
|
|
61 Lisp_Object Qkey_press, Qbutton_press, Qbutton_release, Qmisc_user;
|
|
62 Lisp_Object Qascii_character;
|
|
63
|
771
|
64
|
|
65 /************************************************************************/
|
|
66 /* definition of event object */
|
|
67 /************************************************************************/
|
428
|
68
|
|
69 /* #### Ad-hoc hack. Should be part of define_lrecord_implementation */
|
|
70 void
|
|
71 clear_event_resource (void)
|
|
72 {
|
|
73 Vevent_resource = Qnil;
|
|
74 }
|
|
75
|
934
|
76 #ifdef USE_KKCC
|
|
77 /* Make sure we lose quickly if we try to use this event */
|
|
78 static void
|
|
79 deinitialize_event (Lisp_Object ev)
|
|
80 {
|
|
81 Lisp_Event *event = XEVENT (ev);
|
|
82
|
|
83 set_event_type (event, dead_event);
|
|
84 SET_EVENT_CHANNEL (event, Qnil);
|
|
85 set_lheader_implementation (&event->lheader, &lrecord_event);
|
|
86 XSET_EVENT_NEXT (ev, Qnil);
|
|
87 XSET_EVENT_DATA (ev, Qnil);
|
|
88 }
|
|
89
|
|
90 /* Set everything to zero or nil so that it's predictable. */
|
|
91 void
|
|
92 zero_event (Lisp_Event *e)
|
|
93 {
|
|
94 SET_EVENT_DATA (e, Qnil);
|
|
95 set_event_type (e, empty_event);
|
|
96 SET_EVENT_NEXT (e, Qnil);
|
|
97 SET_EVENT_CHANNEL (e, Qnil);
|
|
98 SET_EVENT_TIMESTAMP_ZERO (e);
|
|
99 }
|
|
100
|
|
101 static const struct lrecord_description event_description [] = {
|
|
102 { XD_LISP_OBJECT, offsetof (struct Lisp_Event, next) },
|
|
103 { XD_LISP_OBJECT, offsetof (struct Lisp_Event, channel) },
|
|
104 { XD_LISP_OBJECT, offsetof (struct Lisp_Event, event_data) },
|
|
105 { XD_END }
|
|
106 };
|
|
107
|
|
108 static Lisp_Object
|
|
109 mark_event (Lisp_Object obj)
|
|
110 {
|
|
111 mark_object (XEVENT_DATA(obj));
|
|
112 mark_object (XEVENT_CHANNEL(obj));
|
|
113 return (XEVENT_NEXT(obj));
|
|
114 }
|
|
115
|
|
116
|
|
117 static const struct lrecord_description key_data_description [] = {
|
|
118 { XD_LISP_OBJECT, offsetof (struct Lisp_Key_Data, keysym) },
|
|
119 { XD_END }
|
|
120 };
|
|
121
|
|
122 static Lisp_Object
|
|
123 mark_key_data (Lisp_Object obj)
|
|
124 {
|
|
125 return (XKEY_DATA_KEYSYM(obj));
|
|
126 }
|
|
127
|
|
128
|
|
129 static const struct lrecord_description button_data_description [] = {
|
|
130 { XD_END }
|
|
131 };
|
|
132
|
|
133 static Lisp_Object
|
|
134 mark_button_data (Lisp_Object obj)
|
|
135 {
|
|
136 return Qnil;
|
|
137 }
|
|
138
|
|
139
|
|
140 static const struct lrecord_description motion_data_description [] = {
|
|
141 { XD_END }
|
|
142 };
|
|
143
|
|
144 static Lisp_Object
|
|
145 mark_motion_data (Lisp_Object obj)
|
|
146 {
|
|
147 return Qnil;
|
|
148 }
|
|
149
|
|
150
|
|
151 static const struct lrecord_description process_data_description [] = {
|
|
152 { XD_LISP_OBJECT, offsetof (struct Lisp_Process_Data, process) },
|
|
153 { XD_END }
|
|
154 };
|
|
155
|
|
156 static Lisp_Object
|
|
157 mark_process_data (Lisp_Object obj)
|
|
158 {
|
|
159 return (XPROCESS_DATA_PROCESS(obj));
|
|
160 }
|
|
161
|
|
162
|
|
163 static const struct lrecord_description timeout_data_description [] = {
|
|
164 { XD_LISP_OBJECT, offsetof (struct Lisp_Timeout_Data, function) },
|
|
165 { XD_LISP_OBJECT, offsetof (struct Lisp_Timeout_Data, object) },
|
|
166 { XD_END }
|
|
167 };
|
|
168
|
|
169 static Lisp_Object
|
|
170 mark_timeout_data (Lisp_Object obj)
|
|
171 {
|
|
172 mark_object (XTIMEOUT_DATA_FUNCTION(obj));
|
|
173 return (XTIMEOUT_DATA_OBJECT(obj));
|
|
174 }
|
|
175
|
|
176
|
|
177 static const struct lrecord_description eval_data_description [] = {
|
|
178 { XD_LISP_OBJECT, offsetof (struct Lisp_Eval_Data, function) },
|
|
179 { XD_LISP_OBJECT, offsetof (struct Lisp_Eval_Data, object) },
|
|
180 { XD_END }
|
|
181 };
|
|
182
|
|
183 static Lisp_Object
|
|
184 mark_eval_data (Lisp_Object obj)
|
|
185 {
|
|
186 mark_object (XEVAL_DATA_FUNCTION(obj));
|
|
187 return (XEVAL_DATA_OBJECT(obj));
|
|
188 }
|
|
189
|
|
190
|
|
191 static const struct lrecord_description misc_user_data_description [] = {
|
|
192 { XD_LISP_OBJECT, offsetof (struct Lisp_Misc_User_Data, function) },
|
|
193 { XD_LISP_OBJECT, offsetof (struct Lisp_Misc_User_Data, object) },
|
|
194 { XD_END }
|
|
195 };
|
|
196
|
|
197 static Lisp_Object
|
|
198 mark_misc_user_data (Lisp_Object obj)
|
|
199 {
|
|
200 mark_object (XMISC_USER_DATA_FUNCTION(obj));
|
|
201 return (XMISC_USER_DATA_OBJECT(obj));
|
|
202 }
|
|
203
|
|
204
|
|
205 static const struct lrecord_description magic_eval_data_description [] = {
|
|
206 { XD_LISP_OBJECT, offsetof (struct Lisp_Magic_Eval_Data, object) },
|
|
207 { XD_END }
|
|
208 };
|
|
209
|
|
210 static Lisp_Object
|
|
211 mark_magic_eval_data (Lisp_Object obj)
|
|
212 {
|
|
213 return (XMAGIC_EVAL_DATA_OBJECT(obj));
|
|
214 }
|
|
215
|
|
216
|
|
217 static const struct lrecord_description magic_data_description [] = {
|
|
218 { XD_END }
|
|
219 };
|
|
220
|
|
221 static Lisp_Object
|
|
222 mark_magic_data (Lisp_Object obj)
|
|
223 {
|
|
224 return Qnil;
|
|
225 }
|
|
226
|
|
227
|
|
228
|
|
229 static void
|
|
230 print_event (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
231 {
|
|
232 if (print_readably)
|
|
233 printing_unreadable_object ("#<event>");
|
|
234
|
|
235 switch (XEVENT_TYPE (obj))
|
|
236 {
|
|
237 case key_press_event:
|
|
238 write_c_string (printcharfun, "#<keypress-event ");
|
|
239 break;
|
|
240 case button_press_event:
|
|
241 write_c_string (printcharfun, "#<buttondown-event ");
|
|
242 break;
|
|
243 case button_release_event:
|
|
244 write_c_string (printcharfun, "#<buttonup-event ");
|
|
245 break;
|
|
246 case magic_eval_event:
|
|
247 write_c_string (printcharfun, "#<magic-eval-event ");
|
|
248 break;
|
|
249 case magic_event:
|
|
250 write_c_string (printcharfun, "#<magic-event ");
|
|
251 break;
|
|
252 case pointer_motion_event:
|
|
253 write_c_string (printcharfun, "#<motion-event ");
|
|
254 break;
|
|
255 case process_event:
|
|
256 write_c_string (printcharfun, "#<process-event ");
|
|
257 break;
|
|
258 case timeout_event:
|
|
259 write_c_string (printcharfun, "#<timeout-event ");
|
|
260 break;
|
|
261 case misc_user_event:
|
|
262 write_c_string (printcharfun, "#<misc-user-event ");
|
|
263 break;
|
|
264 case eval_event:
|
|
265 write_c_string (printcharfun, "#<eval-event ");
|
|
266 break;
|
|
267 case empty_event:
|
|
268 write_c_string (printcharfun, "#<empty-event>");
|
|
269 return;
|
|
270 case dead_event:
|
|
271 write_c_string (printcharfun, "#<DEALLOCATED-EVENT>");
|
|
272 return;
|
|
273 default:
|
|
274 write_c_string (printcharfun, "#<UNKNOWN-EVENT-TYPE>");
|
|
275 return;
|
|
276 }
|
|
277
|
|
278 print_internal (XEVENT_DATA (obj), printcharfun, 1);
|
|
279 write_c_string (printcharfun, ">");
|
|
280 }
|
|
281
|
|
282
|
|
283 static void
|
|
284 print_key_data (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
285 {
|
|
286 char buf[128];
|
|
287 if (print_readably)
|
|
288 printing_unreadable_object ("#<key_data>");
|
|
289
|
|
290 sprintf (buf, "#<key_data ");
|
|
291 /* format_event_data_object (buf + 11, obj, 0);
|
|
292 sprintf (buf + strlen (buf), ">");
|
|
293 write_c_string (printcharfun, buf);*/
|
|
294 }
|
|
295
|
|
296 static void
|
|
297 print_button_data (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
298 {
|
|
299 char buf[128];
|
|
300 if (print_readably)
|
|
301 printing_unreadable_object ("#<button_data>");
|
|
302
|
|
303 sprintf (buf, "#<button_data ");
|
|
304 /* format_event_data_object (buf + 14, obj, 0);
|
|
305 sprintf (buf + strlen (buf), ">");
|
|
306 write_c_string (printcharfun, buf);*/
|
|
307 }
|
|
308
|
|
309
|
|
310 static void
|
|
311 print_motion_data (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
312 {
|
|
313 char buf[64];
|
|
314
|
|
315 if (print_readably)
|
|
316 printing_unreadable_object ("#<motion_data>");
|
|
317
|
943
|
318 sprintf (buf, "#<motion-data %ld, %ld>",
|
|
319 (long) XMOTION_DATA_X (obj),
|
|
320 (long) XMOTION_DATA_Y (obj));
|
934
|
321 write_c_string (printcharfun, buf);
|
|
322 }
|
|
323
|
|
324
|
|
325 static void
|
|
326 print_process_data (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
327 {
|
|
328 if (print_readably)
|
|
329 printing_unreadable_object ("#<process_data>");
|
|
330
|
943
|
331 write_c_string (printcharfun, "#<process-data ");
|
934
|
332 print_internal (XPROCESS_DATA_PROCESS (obj), printcharfun, 1);
|
|
333 write_c_string (printcharfun, ">");
|
|
334 }
|
|
335
|
|
336
|
|
337 static void
|
|
338 print_timeout_data (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
339 {
|
|
340 if (print_readably)
|
|
341 printing_unreadable_object ("#<timeout_data>");
|
|
342
|
|
343 write_c_string (printcharfun, "#<timeout-data ");
|
|
344 print_internal (XTIMEOUT_DATA_OBJECT (obj), printcharfun, 1);
|
|
345 write_c_string (printcharfun, ">");
|
|
346 }
|
|
347
|
|
348
|
|
349 static void
|
|
350 print_eval_data (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
351 {
|
|
352 if (print_readably)
|
|
353 printing_unreadable_object ("#<eval_data>");
|
|
354
|
|
355 write_c_string (printcharfun, "#<eval-data ");
|
|
356 print_internal (XEVAL_DATA_FUNCTION (obj), printcharfun, 1);
|
|
357 write_c_string (printcharfun, " ");
|
|
358 print_internal (XEVAL_DATA_OBJECT (obj), printcharfun, 1);
|
|
359 write_c_string (printcharfun, ">");
|
|
360 }
|
|
361
|
|
362
|
|
363 static void
|
|
364 print_misc_user_data (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
365 {
|
|
366 if (print_readably)
|
|
367 printing_unreadable_object ("#<misc_user_data>");
|
|
368
|
|
369 write_c_string (printcharfun, "#<misc-user-data ");
|
|
370 print_internal (XMISC_USER_DATA_FUNCTION (obj), printcharfun, 1);
|
|
371 write_c_string (printcharfun, " ");
|
|
372 print_internal (XMISC_USER_DATA_OBJECT (obj), printcharfun, 1);
|
|
373 write_c_string (printcharfun, ">");
|
|
374 }
|
|
375
|
|
376
|
|
377 static void
|
|
378 print_magic_eval_data (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
379 {
|
|
380 // char buf[128];
|
|
381
|
|
382 if (print_readably)
|
|
383 printing_unreadable_object ("#<magic_eval_data>");
|
|
384
|
|
385 /* format_event_data_object (buf + 18, obj, 0);*/
|
|
386 }
|
|
387
|
|
388
|
|
389 static void
|
|
390 print_magic_data (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
391 {
|
|
392 char buf[128];
|
|
393
|
|
394 if (print_readably)
|
|
395 printing_unreadable_object ("#<magic_data>");
|
|
396
|
|
397 sprintf (buf, "#<magic-data ");
|
|
398 /* format_event_data_object (buf + 13, obj, 0);
|
|
399 sprintf (buf + strlen (buf), ">");
|
|
400 write_c_string (print_readably, buf);*/
|
|
401 }
|
|
402
|
|
403
|
|
404 static int
|
|
405 event_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
|
|
406 {
|
|
407 Lisp_Event *e1 = XEVENT (obj1);
|
|
408 Lisp_Event *e2 = XEVENT (obj2);
|
|
409
|
|
410 if (EVENT_TYPE (e1) != EVENT_TYPE (e2)) return 0;
|
|
411 if (!EQ (EVENT_CHANNEL (e1), EVENT_CHANNEL (e2))) return 0;
|
|
412 /* if (EVENT_TIMESTAMP (e1) != EVENT_TIMESTAMP (e2)) return 0; */
|
|
413 switch (EVENT_TYPE (e1))
|
|
414 {
|
|
415 default: abort ();
|
|
416
|
|
417 case process_event:
|
|
418 case timeout_event:
|
|
419 case pointer_motion_event:
|
|
420 case key_press_event:
|
|
421 case button_press_event:
|
|
422 case button_release_event:
|
|
423 case misc_user_event:
|
|
424 case eval_event:
|
|
425 case magic_eval_event:
|
|
426 return internal_equal (EVENT_DATA (e1), EVENT_DATA (e2), 0);
|
|
427
|
|
428 case magic_event:
|
|
429 {
|
|
430 struct console *con = XCONSOLE (CDFW_CONSOLE (EVENT_CHANNEL (e1)));
|
|
431
|
|
432 #ifdef HAVE_X_WINDOWS
|
|
433 if (CONSOLE_X_P (con))
|
|
434 return (XMAGIC_DATA_X_EVENT (EVENT_DATA (e1)).xany.serial ==
|
|
435 XMAGIC_DATA_X_EVENT (EVENT_DATA (e2)).xany.serial);
|
|
436 #endif
|
|
437 #ifdef HAVE_GTK
|
|
438 if (CONSOLE_GTK_P (con))
|
|
439 return (XMAGIC_DATA_GTK_EVENT (EVENT_DATA (e1)) ==
|
|
440 XMAGIC_DATA_GTK_EVENT (EVENT_DATA (e2)));
|
|
441 #endif
|
|
442 #ifdef HAVE_MS_WINDOWS
|
|
443 if (CONSOLE_MSWINDOWS_P (con))
|
941
|
444 return (XMAGIC_DATA_MSWINDOWS_EVENT (EVENT_DATA (e1)) ==
|
|
445 XMAGIC_DATA_MSWINDOWS_EVENT (EVENT_DATA (e2)));
|
934
|
446 #endif
|
|
447 abort ();
|
|
448 return 1; /* not reached */
|
|
449 }
|
|
450
|
|
451 case empty_event: /* Empty and deallocated events are equal. */
|
|
452 case dead_event:
|
|
453 return 1;
|
|
454 }
|
|
455 }
|
|
456
|
|
457 static int
|
|
458 key_data_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
|
|
459 {
|
|
460 return (EQ (XKEY_DATA_KEYSYM (obj1), XKEY_DATA_KEYSYM (obj2)) &&
|
|
461 (XKEY_DATA_MODIFIERS (obj1) == XKEY_DATA_MODIFIERS (obj2)));
|
|
462 }
|
|
463
|
|
464 static int
|
|
465 button_data_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
|
|
466 {
|
|
467 return (XBUTTON_DATA_BUTTON (obj1) == XBUTTON_DATA_BUTTON (obj2) &&
|
|
468 XBUTTON_DATA_MODIFIERS (obj1) == XBUTTON_DATA_MODIFIERS (obj2));
|
|
469 }
|
|
470
|
|
471 static int
|
|
472 motion_data_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
|
|
473 {
|
|
474 return (XMOTION_DATA_X (obj1) == XMOTION_DATA_X (obj2) &&
|
|
475 XMOTION_DATA_Y (obj1) == XMOTION_DATA_Y (obj2));
|
|
476 }
|
|
477
|
|
478 static int
|
|
479 process_data_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
|
|
480 {
|
|
481 return EQ (XPROCESS_DATA_PROCESS (obj1), XPROCESS_DATA_PROCESS (obj2));
|
|
482 }
|
|
483
|
|
484 static int
|
|
485 timeout_data_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
|
|
486 {
|
|
487 return (internal_equal (XTIMEOUT_DATA_FUNCTION (obj1),
|
|
488 XTIMEOUT_DATA_FUNCTION (obj2), 0) &&
|
|
489 internal_equal (XTIMEOUT_DATA_OBJECT (obj1),
|
|
490 XTIMEOUT_DATA_OBJECT (obj2), 0));
|
|
491 }
|
|
492
|
|
493 static int
|
|
494 eval_data_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
|
|
495 {
|
|
496 return (internal_equal (XEVAL_DATA_FUNCTION (obj1),
|
|
497 XEVAL_DATA_FUNCTION (obj2), 0) &&
|
|
498 internal_equal (XEVAL_DATA_OBJECT (obj1),
|
|
499 XEVAL_DATA_OBJECT (obj2), 0));
|
|
500 }
|
|
501
|
|
502 static int
|
|
503 misc_user_data_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
|
|
504 {
|
|
505 return (internal_equal (XMISC_USER_DATA_FUNCTION (obj1),
|
|
506 XMISC_USER_DATA_FUNCTION (obj2), 0) &&
|
|
507 internal_equal (XMISC_USER_DATA_OBJECT (obj1),
|
|
508 XMISC_USER_DATA_OBJECT (obj2), 0) &&
|
|
509 /* is this really needed for equality
|
|
510 or is x and y also important? */
|
|
511 XMISC_USER_DATA_BUTTON (obj1) == XMISC_USER_DATA_BUTTON (obj2) &&
|
|
512 XMISC_USER_DATA_MODIFIERS (obj1) ==
|
|
513 XMISC_USER_DATA_MODIFIERS (obj2));
|
|
514 }
|
|
515
|
|
516 static int
|
|
517 magic_eval_data_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
|
|
518 {
|
|
519 return (XMAGIC_EVAL_DATA_INTERNAL_FUNCTION (obj1) ==
|
|
520 XMAGIC_EVAL_DATA_INTERNAL_FUNCTION (obj2) &&
|
|
521 internal_equal (XMAGIC_EVAL_DATA_OBJECT (obj1),
|
|
522 XMAGIC_EVAL_DATA_OBJECT (obj2), 0));
|
|
523 }
|
|
524
|
|
525 static int
|
|
526 magic_data_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
|
|
527 {assert (0); return 0;}
|
|
528
|
|
529 static unsigned long
|
|
530 event_hash (Lisp_Object obj, int depth)
|
|
531 {
|
|
532 Lisp_Event *e = XEVENT (obj);
|
|
533 unsigned long hash;
|
|
534
|
|
535 hash = HASH2 (EVENT_TYPE (e), LISP_HASH (EVENT_CHANNEL (e)));
|
|
536 switch (EVENT_TYPE (e))
|
|
537 {
|
|
538 case process_event:
|
|
539 case timeout_event:
|
|
540 case key_press_event:
|
|
541 case button_press_event:
|
|
542 case button_release_event:
|
|
543 case pointer_motion_event:
|
|
544 case misc_user_event:
|
|
545 case eval_event:
|
|
546 case magic_eval_event:
|
|
547 return HASH2 (hash, internal_hash (EVENT_DATA (e), depth + 1));
|
|
548
|
|
549 case magic_event:
|
|
550 {
|
|
551 struct console *con = XCONSOLE (CDFW_CONSOLE (EVENT_CHANNEL (e)));
|
|
552 #ifdef HAVE_X_WINDOWS
|
|
553 if (CONSOLE_X_P (con))
|
|
554 return HASH2 (hash, XMAGIC_DATA_X_EVENT (EVENT_DATA (e)).xany.serial);
|
|
555 #endif
|
|
556 #ifdef HAVE_GTK
|
|
557 if (CONSOLE_GTK_P (con))
|
|
558 return HASH2 (hash, XMAGIC_DATA_GTK_EVENT (EVENT_DATA (e)));
|
|
559 #endif
|
|
560 #ifdef HAVE_MS_WINDOWS
|
|
561 if (CONSOLE_MSWINDOWS_P (con))
|
|
562 return HASH2 (hash, XMAGIC_DATA_MSWINDOWS_EVENT (EVENT_DATA (e)));
|
|
563 #endif
|
|
564 abort ();
|
|
565 return 0;
|
|
566 }
|
|
567
|
|
568 case empty_event:
|
|
569 case dead_event:
|
|
570 return hash;
|
|
571
|
|
572 default:
|
|
573 abort ();
|
|
574 }
|
|
575
|
|
576 return 0; /* unreached */
|
|
577 }
|
|
578
|
|
579 static unsigned long
|
|
580 key_data_hash (Lisp_Object obj, int depth)
|
|
581 {
|
|
582 return HASH2 (LISP_HASH (XKEY_DATA_KEYSYM (obj)),
|
|
583 XKEY_DATA_MODIFIERS (obj));
|
|
584 }
|
|
585
|
|
586 static unsigned long
|
|
587 button_data_hash (Lisp_Object obj, int depth)
|
|
588 {
|
|
589 return HASH2 (XBUTTON_DATA_BUTTON (obj), XBUTTON_DATA_MODIFIERS (obj));
|
|
590 }
|
|
591
|
|
592 static unsigned long
|
|
593 motion_data_hash (Lisp_Object obj, int depth)
|
|
594 {
|
|
595 return HASH2 (XMOTION_DATA_X (obj), XMOTION_DATA_Y (obj));
|
|
596 }
|
|
597
|
|
598 static unsigned long
|
|
599 process_data_hash (Lisp_Object obj, int depth)
|
|
600 {
|
|
601 return LISP_HASH (XPROCESS_DATA_PROCESS (obj));
|
|
602 }
|
|
603
|
|
604 static unsigned long
|
|
605 timeout_data_hash (Lisp_Object obj, int depth)
|
|
606 {
|
|
607 return HASH2 (internal_hash (XTIMEOUT_DATA_FUNCTION (obj), depth + 1),
|
|
608 internal_hash (XTIMEOUT_DATA_OBJECT (obj), depth + 1));
|
|
609 }
|
|
610
|
|
611 static unsigned long
|
|
612 eval_data_hash (Lisp_Object obj, int depth)
|
|
613 {
|
|
614 return HASH2 (internal_hash (XEVAL_DATA_FUNCTION (obj), depth + 1),
|
|
615 internal_hash (XEVAL_DATA_OBJECT (obj), depth + 1));
|
|
616 }
|
|
617
|
|
618 static unsigned long
|
|
619 misc_user_data_hash (Lisp_Object obj, int depth)
|
|
620 {
|
|
621 return HASH4 (internal_hash (XMISC_USER_DATA_FUNCTION (obj), depth + 1),
|
|
622 internal_hash (XMISC_USER_DATA_OBJECT (obj), depth + 1),
|
|
623 XMISC_USER_DATA_BUTTON (obj), XMISC_USER_DATA_MODIFIERS (obj));
|
|
624 }
|
|
625
|
|
626 static unsigned long
|
|
627 magic_eval_data_hash (Lisp_Object obj, int depth)
|
|
628 {
|
|
629 return HASH2 ((unsigned long) XMAGIC_EVAL_DATA_INTERNAL_FUNCTION (obj),
|
|
630 internal_hash (XMAGIC_EVAL_DATA_OBJECT (obj), depth + 1));
|
|
631 }
|
|
632
|
|
633 static unsigned long
|
|
634 magic_data_hash (Lisp_Object obj, int depth)
|
|
635 {assert(0); return 1;}
|
|
636
|
962
|
637 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("key-data", key_data,
|
|
638 0, /*dumpable-flag*/
|
|
639 mark_key_data,
|
|
640 print_key_data, 0,
|
|
641 key_data_equal, key_data_hash,
|
|
642 key_data_description,
|
|
643 Lisp_Key_Data);
|
|
644
|
|
645 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("button-data", button_data,
|
|
646 0, /*dumpable-flag*/
|
|
647 mark_button_data, print_button_data, 0,
|
|
648 button_data_equal, button_data_hash,
|
|
649 button_data_description,
|
|
650 Lisp_Button_Data);
|
|
651
|
|
652 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("motion-data", motion_data,
|
|
653 0, /*dumpable-flag*/
|
|
654 mark_motion_data, print_motion_data, 0,
|
|
655 motion_data_equal, motion_data_hash,
|
|
656 motion_data_description,
|
|
657 Lisp_Motion_Data);
|
|
658
|
|
659 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("process-data", process_data,
|
|
660 0, /*dumpable-flag*/
|
|
661 mark_process_data,
|
|
662 print_process_data, 0,
|
|
663 process_data_equal, process_data_hash,
|
|
664 process_data_description,
|
|
665 Lisp_Process_Data);
|
|
666
|
|
667 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("timeout-data", timeout_data,
|
|
668 0, /*dumpable-flag*/
|
|
669 mark_timeout_data,
|
|
670 print_timeout_data, 0,
|
|
671 timeout_data_equal, timeout_data_hash,
|
|
672 timeout_data_description,
|
|
673 Lisp_Timeout_Data);
|
|
674
|
|
675 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("eval-data", eval_data,
|
|
676 0, /*dumpable-flag*/
|
|
677 mark_eval_data,
|
|
678 print_eval_data, 0,
|
|
679 eval_data_equal, eval_data_hash,
|
|
680 eval_data_description,
|
|
681 Lisp_Eval_Data);
|
|
682
|
|
683 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("misc-user-data", misc_user_data,
|
|
684 0, /*dumpable-flag*/
|
|
685 mark_misc_user_data,
|
|
686 print_misc_user_data,
|
|
687 0, misc_user_data_equal,
|
|
688 misc_user_data_hash,
|
|
689 misc_user_data_description,
|
|
690 Lisp_Misc_User_Data);
|
|
691
|
|
692 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("magic-eval-data", magic_eval_data,
|
|
693 0, /*dumpable-flag*/
|
|
694 mark_magic_eval_data,
|
|
695 print_magic_eval_data, 0,
|
|
696 magic_eval_data_equal,
|
|
697 magic_eval_data_hash,
|
|
698 magic_eval_data_description,
|
|
699 Lisp_Magic_Eval_Data);
|
|
700
|
|
701 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("magic-data", magic_data,
|
|
702 0, /*dumpable-flag*/
|
|
703 mark_magic_data, print_magic_data, 0,
|
|
704 magic_data_equal, magic_data_hash,
|
|
705 magic_data_description,
|
|
706 Lisp_Magic_Data);
|
934
|
707
|
|
708
|
|
709
|
|
710 #else /* not USE_KKCC */
|
428
|
711 /* Make sure we lose quickly if we try to use this event */
|
|
712 static void
|
|
713 deinitialize_event (Lisp_Object ev)
|
|
714 {
|
|
715 int i;
|
440
|
716 Lisp_Event *event = XEVENT (ev);
|
428
|
717
|
440
|
718 for (i = 0; i < (int) (sizeof (Lisp_Event) / sizeof (int)); i++)
|
428
|
719 ((int *) event) [i] = 0xdeadbeef;
|
|
720 event->event_type = dead_event;
|
|
721 event->channel = Qnil;
|
442
|
722 set_lheader_implementation (&event->lheader, &lrecord_event);
|
428
|
723 XSET_EVENT_NEXT (ev, Qnil);
|
|
724 }
|
|
725
|
|
726 /* Set everything to zero or nil so that it's predictable. */
|
|
727 void
|
440
|
728 zero_event (Lisp_Event *e)
|
428
|
729 {
|
|
730 xzero (*e);
|
442
|
731 set_lheader_implementation (&e->lheader, &lrecord_event);
|
428
|
732 e->event_type = empty_event;
|
|
733 e->next = Qnil;
|
|
734 e->channel = Qnil;
|
|
735 }
|
|
736
|
|
737 static Lisp_Object
|
|
738 mark_event (Lisp_Object obj)
|
|
739 {
|
440
|
740 Lisp_Event *event = XEVENT (obj);
|
428
|
741
|
|
742 switch (event->event_type)
|
|
743 {
|
|
744 case key_press_event:
|
|
745 mark_object (event->event.key.keysym);
|
|
746 break;
|
|
747 case process_event:
|
|
748 mark_object (event->event.process.process);
|
|
749 break;
|
|
750 case timeout_event:
|
|
751 mark_object (event->event.timeout.function);
|
|
752 mark_object (event->event.timeout.object);
|
|
753 break;
|
|
754 case eval_event:
|
|
755 case misc_user_event:
|
|
756 mark_object (event->event.eval.function);
|
|
757 mark_object (event->event.eval.object);
|
|
758 break;
|
|
759 case magic_eval_event:
|
|
760 mark_object (event->event.magic_eval.object);
|
|
761 break;
|
|
762 case button_press_event:
|
|
763 case button_release_event:
|
|
764 case pointer_motion_event:
|
|
765 case magic_event:
|
|
766 case empty_event:
|
|
767 case dead_event:
|
|
768 break;
|
|
769 default:
|
|
770 abort ();
|
|
771 }
|
|
772 mark_object (event->channel);
|
|
773 return event->next;
|
|
774 }
|
|
775
|
|
776 static void
|
442
|
777 print_event_1 (const char *str, Lisp_Object obj, Lisp_Object printcharfun)
|
428
|
778 {
|
793
|
779 DECLARE_EISTRING_MALLOC (ei);
|
826
|
780 write_c_string (printcharfun, str);
|
793
|
781 format_event_object (ei, XEVENT (obj), 0);
|
826
|
782 write_eistring (printcharfun, ei);
|
793
|
783 eifree (ei);
|
428
|
784 }
|
|
785
|
|
786 static void
|
|
787 print_event (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
788 {
|
|
789 if (print_readably)
|
563
|
790 printing_unreadable_object ("#<event>");
|
428
|
791
|
|
792 switch (XEVENT (obj)->event_type)
|
|
793 {
|
|
794 case key_press_event:
|
|
795 print_event_1 ("#<keypress-event ", obj, printcharfun);
|
|
796 break;
|
|
797 case button_press_event:
|
|
798 print_event_1 ("#<buttondown-event ", obj, printcharfun);
|
|
799 break;
|
|
800 case button_release_event:
|
|
801 print_event_1 ("#<buttonup-event ", obj, printcharfun);
|
|
802 break;
|
|
803 case magic_event:
|
|
804 case magic_eval_event:
|
|
805 print_event_1 ("#<magic-event ", obj, printcharfun);
|
|
806 break;
|
|
807 case pointer_motion_event:
|
|
808 {
|
|
809 Lisp_Object Vx, Vy;
|
|
810 Vx = Fevent_x_pixel (obj);
|
|
811 assert (INTP (Vx));
|
|
812 Vy = Fevent_y_pixel (obj);
|
|
813 assert (INTP (Vy));
|
793
|
814 write_fmt_string (printcharfun, "#<motion-event %ld, %ld",
|
|
815 (long) XINT (Vx), (long) XINT (Vy));
|
428
|
816 break;
|
|
817 }
|
|
818 case process_event:
|
800
|
819 write_fmt_string_lisp (printcharfun, "#<process-event %S", 1, XEVENT (obj)->event.process.process);
|
428
|
820 break;
|
|
821 case timeout_event:
|
800
|
822 write_fmt_string_lisp (printcharfun, "#<timeout-event %S", 1, XEVENT (obj)->event.timeout.object);
|
428
|
823 break;
|
|
824 case empty_event:
|
826
|
825 write_c_string (printcharfun, "#<empty-event");
|
428
|
826 break;
|
|
827 case misc_user_event:
|
800
|
828 write_fmt_string_lisp (printcharfun, "#<misc-user-event (%S", 1, XEVENT (obj)->event.misc.function);
|
|
829 write_fmt_string_lisp (printcharfun, " %S)", 1, XEVENT (obj)->event.misc.object);
|
428
|
830 break;
|
|
831 case eval_event:
|
800
|
832 write_fmt_string_lisp (printcharfun, "#<eval-event (%S", 1, XEVENT (obj)->event.eval.function);
|
|
833 write_fmt_string_lisp (printcharfun, " %S)", 1, XEVENT (obj)->event.eval.object);
|
428
|
834 break;
|
|
835 case dead_event:
|
826
|
836 write_c_string (printcharfun, "#<DEALLOCATED-EVENT");
|
428
|
837 break;
|
|
838 default:
|
826
|
839 write_c_string (printcharfun, "#<UNKNOWN-EVENT-TYPE");
|
428
|
840 break;
|
|
841 }
|
826
|
842 write_c_string (printcharfun, ">");
|
428
|
843 }
|
|
844
|
|
845 static int
|
|
846 event_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
|
|
847 {
|
440
|
848 Lisp_Event *e1 = XEVENT (obj1);
|
|
849 Lisp_Event *e2 = XEVENT (obj2);
|
428
|
850
|
|
851 if (e1->event_type != e2->event_type) return 0;
|
|
852 if (!EQ (e1->channel, e2->channel)) return 0;
|
|
853 /* if (e1->timestamp != e2->timestamp) return 0; */
|
|
854 switch (e1->event_type)
|
|
855 {
|
|
856 default: abort ();
|
|
857
|
|
858 case process_event:
|
|
859 return EQ (e1->event.process.process, e2->event.process.process);
|
|
860
|
|
861 case timeout_event:
|
|
862 return (internal_equal (e1->event.timeout.function,
|
|
863 e2->event.timeout.function, 0) &&
|
|
864 internal_equal (e1->event.timeout.object,
|
|
865 e2->event.timeout.object, 0));
|
|
866
|
|
867 case key_press_event:
|
|
868 return (EQ (e1->event.key.keysym, e2->event.key.keysym) &&
|
|
869 (e1->event.key.modifiers == e2->event.key.modifiers));
|
|
870
|
|
871 case button_press_event:
|
|
872 case button_release_event:
|
|
873 return (e1->event.button.button == e2->event.button.button &&
|
|
874 e1->event.button.modifiers == e2->event.button.modifiers);
|
|
875
|
|
876 case pointer_motion_event:
|
|
877 return (e1->event.motion.x == e2->event.motion.x &&
|
|
878 e1->event.motion.y == e2->event.motion.y);
|
|
879
|
|
880 case misc_user_event:
|
|
881 return (internal_equal (e1->event.eval.function,
|
|
882 e2->event.eval.function, 0) &&
|
|
883 internal_equal (e1->event.eval.object,
|
|
884 e2->event.eval.object, 0) &&
|
|
885 /* is this really needed for equality
|
|
886 or is x and y also important? */
|
|
887 e1->event.misc.button == e2->event.misc.button &&
|
|
888 e1->event.misc.modifiers == e2->event.misc.modifiers);
|
|
889
|
|
890 case eval_event:
|
|
891 return (internal_equal (e1->event.eval.function,
|
|
892 e2->event.eval.function, 0) &&
|
|
893 internal_equal (e1->event.eval.object,
|
|
894 e2->event.eval.object, 0));
|
|
895
|
|
896 case magic_eval_event:
|
|
897 return (e1->event.magic_eval.internal_function ==
|
|
898 e2->event.magic_eval.internal_function &&
|
|
899 internal_equal (e1->event.magic_eval.object,
|
|
900 e2->event.magic_eval.object, 0));
|
|
901
|
|
902 case magic_event:
|
788
|
903 return event_stream_compare_magic_event (e1, e2);
|
428
|
904
|
|
905 case empty_event: /* Empty and deallocated events are equal. */
|
|
906 case dead_event:
|
|
907 return 1;
|
|
908 }
|
|
909 }
|
|
910
|
665
|
911 static Hashcode
|
428
|
912 event_hash (Lisp_Object obj, int depth)
|
|
913 {
|
440
|
914 Lisp_Event *e = XEVENT (obj);
|
665
|
915 Hashcode hash;
|
428
|
916
|
|
917 hash = HASH2 (e->event_type, LISP_HASH (e->channel));
|
|
918 switch (e->event_type)
|
|
919 {
|
|
920 case process_event:
|
|
921 return HASH2 (hash, LISP_HASH (e->event.process.process));
|
|
922
|
|
923 case timeout_event:
|
|
924 return HASH3 (hash, internal_hash (e->event.timeout.function, depth + 1),
|
|
925 internal_hash (e->event.timeout.object, depth + 1));
|
|
926
|
|
927 case key_press_event:
|
|
928 return HASH3 (hash, LISP_HASH (e->event.key.keysym),
|
|
929 e->event.key.modifiers);
|
|
930
|
|
931 case button_press_event:
|
|
932 case button_release_event:
|
|
933 return HASH3 (hash, e->event.button.button, e->event.button.modifiers);
|
|
934
|
|
935 case pointer_motion_event:
|
|
936 return HASH3 (hash, e->event.motion.x, e->event.motion.y);
|
|
937
|
|
938 case misc_user_event:
|
|
939 return HASH5 (hash, internal_hash (e->event.misc.function, depth + 1),
|
|
940 internal_hash (e->event.misc.object, depth + 1),
|
|
941 e->event.misc.button, e->event.misc.modifiers);
|
|
942
|
|
943 case eval_event:
|
|
944 return HASH3 (hash, internal_hash (e->event.eval.function, depth + 1),
|
|
945 internal_hash (e->event.eval.object, depth + 1));
|
|
946
|
|
947 case magic_eval_event:
|
|
948 return HASH3 (hash,
|
665
|
949 (Hashcode) e->event.magic_eval.internal_function,
|
428
|
950 internal_hash (e->event.magic_eval.object, depth + 1));
|
|
951
|
|
952 case magic_event:
|
788
|
953 return HASH2 (hash, event_stream_hash_magic_event (e));
|
428
|
954
|
|
955 case empty_event:
|
|
956 case dead_event:
|
|
957 return hash;
|
|
958
|
|
959 default:
|
|
960 abort ();
|
|
961 }
|
|
962
|
|
963 return 0; /* unreached */
|
|
964 }
|
934
|
965 #endif /* not USE_KKCC */
|
|
966
|
|
967
|
|
968 #ifdef USE_KKCC
|
|
969 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("event", event,
|
|
970 0, /*dumpable-flag*/
|
|
971 mark_event, print_event, 0, event_equal,
|
|
972 event_hash, 0/*event_description*/, Lisp_Event);
|
|
973 #else /* not USE_KKCC */
|
428
|
974 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("event", event,
|
|
975 mark_event, print_event, 0, event_equal,
|
440
|
976 event_hash, 0, Lisp_Event);
|
934
|
977 #endif /* not USE_KKCC */
|
428
|
978
|
|
979 DEFUN ("make-event", Fmake_event, 0, 2, 0, /*
|
|
980 Return a new event of type TYPE, with properties described by PLIST.
|
|
981
|
|
982 TYPE is a symbol, either `empty', `key-press', `button-press',
|
|
983 `button-release', `misc-user' or `motion'. If TYPE is nil, it
|
|
984 defaults to `empty'.
|
|
985
|
|
986 PLIST is a property list, the properties being compatible to those
|
|
987 returned by `event-properties'. The following properties are
|
|
988 allowed:
|
|
989
|
|
990 channel -- The event channel, a frame or a console. For
|
|
991 button-press, button-release, misc-user and motion events,
|
|
992 this must be a frame. For key-press events, it must be
|
|
993 a console. If channel is unspecified, it will be set to
|
|
994 the selected frame or selected console, as appropriate.
|
|
995 key -- The event key, a symbol or character. Allowed only for
|
|
996 keypress events.
|
|
997 button -- The event button, integer 1, 2 or 3. Allowed for
|
|
998 button-press, button-release and misc-user events.
|
|
999 modifiers -- The event modifiers, a list of modifier symbols. Allowed
|
|
1000 for key-press, button-press, button-release, motion and
|
|
1001 misc-user events.
|
|
1002 function -- Function. Allowed for misc-user events only.
|
|
1003 object -- An object, function's parameter. Allowed for misc-user
|
|
1004 events only.
|
|
1005 x -- The event X coordinate, an integer. This is relative
|
|
1006 to the left of CHANNEL's root window. Allowed for
|
|
1007 motion, button-press, button-release and misc-user events.
|
|
1008 y -- The event Y coordinate, an integer. This is relative
|
|
1009 to the top of CHANNEL's root window. Allowed for
|
|
1010 motion, button-press, button-release and misc-user events.
|
|
1011 timestamp -- The event timestamp, a non-negative integer. Allowed for
|
|
1012 all types of events. If unspecified, it will be set to 0
|
|
1013 by default.
|
|
1014
|
|
1015 For event type `empty', PLIST must be nil.
|
|
1016 `button-release', or `motion'. If TYPE is left out, it defaults to
|
|
1017 `empty'.
|
|
1018 PLIST is a list of properties, as returned by `event-properties'. Not
|
|
1019 all properties are allowed for all kinds of events, and some are
|
|
1020 required.
|
|
1021
|
|
1022 WARNING: the event object returned may be a reused one; see the function
|
|
1023 `deallocate-event'.
|
|
1024 */
|
|
1025 (type, plist))
|
|
1026 {
|
|
1027 Lisp_Object event = Qnil;
|
440
|
1028 Lisp_Event *e;
|
428
|
1029 EMACS_INT coord_x = 0, coord_y = 0;
|
|
1030 struct gcpro gcpro1;
|
|
1031
|
|
1032 GCPRO1 (event);
|
|
1033
|
|
1034 if (NILP (type))
|
|
1035 type = Qempty;
|
|
1036
|
|
1037 if (!NILP (Vevent_resource))
|
|
1038 {
|
|
1039 event = Vevent_resource;
|
|
1040 Vevent_resource = XEVENT_NEXT (event);
|
|
1041 }
|
|
1042 else
|
|
1043 {
|
|
1044 event = allocate_event ();
|
|
1045 }
|
|
1046 e = XEVENT (event);
|
|
1047 zero_event (e);
|
|
1048
|
|
1049 if (EQ (type, Qempty))
|
|
1050 {
|
|
1051 /* For empty event, we return immediately, without processing
|
|
1052 PLIST. In fact, processing PLIST would be wrong, because the
|
|
1053 sanitizing process would fill in the properties
|
|
1054 (e.g. CHANNEL), which we don't want in empty events. */
|
934
|
1055 #ifdef USE_KKCC
|
|
1056 set_event_type (e, empty_event);
|
|
1057 #else /* not USE_KKCC */
|
428
|
1058 e->event_type = empty_event;
|
934
|
1059 #endif /* not USE_KKCC */
|
428
|
1060 if (!NILP (plist))
|
563
|
1061 invalid_operation ("Cannot set properties of empty event", plist);
|
428
|
1062 UNGCPRO;
|
|
1063 return event;
|
|
1064 }
|
|
1065 else if (EQ (type, Qkey_press))
|
|
1066 {
|
934
|
1067 #ifdef USE_KKCC
|
|
1068 set_event_type (e, key_press_event);
|
|
1069 XSET_KEY_DATA_KEYSYM (EVENT_DATA (e), Qunbound);
|
|
1070 #else /* not USE_KKCC */
|
428
|
1071 e->event_type = key_press_event;
|
|
1072 e->event.key.keysym = Qunbound;
|
934
|
1073 #endif /* not USE_KKCC */
|
428
|
1074 }
|
|
1075 else if (EQ (type, Qbutton_press))
|
934
|
1076 #ifdef USE_KKCC
|
|
1077 set_event_type (e, button_press_event);
|
|
1078 #else /* not USE_KKCC */
|
428
|
1079 e->event_type = button_press_event;
|
934
|
1080 #endif /* not USE_KKCC */
|
428
|
1081 else if (EQ (type, Qbutton_release))
|
934
|
1082 #ifdef USE_KKCC
|
|
1083 set_event_type (e, button_release_event);
|
|
1084 #else /* not USE_KKCC */
|
428
|
1085 e->event_type = button_release_event;
|
934
|
1086 #endif /* not USE_KKCC */
|
428
|
1087 else if (EQ (type, Qmotion))
|
934
|
1088 #ifdef USE_KKCC
|
|
1089 set_event_type (e, pointer_motion_event);
|
|
1090 #else /* not USE_KKCC */
|
428
|
1091 e->event_type = pointer_motion_event;
|
934
|
1092 #endif /* not USE_KKCC */
|
428
|
1093 else if (EQ (type, Qmisc_user))
|
|
1094 {
|
934
|
1095 #ifdef USE_KKCC
|
|
1096 set_event_type (e, misc_user_event);
|
|
1097 XSET_MISC_USER_DATA_FUNCTION (EVENT_DATA (e), Qnil);
|
|
1098 XSET_MISC_USER_DATA_OBJECT (EVENT_DATA (e), Qnil);
|
|
1099 #else /* not USE_KKCC */
|
428
|
1100 e->event_type = misc_user_event;
|
|
1101 e->event.eval.function = e->event.eval.object = Qnil;
|
934
|
1102 #endif /* not USE_KKCC */
|
428
|
1103 }
|
|
1104 else
|
|
1105 {
|
|
1106 /* Not allowed: Qprocess, Qtimeout, Qmagic, Qeval, Qmagic_eval. */
|
563
|
1107 invalid_constant ("Invalid event type", type);
|
428
|
1108 }
|
|
1109
|
|
1110 EVENT_CHANNEL (e) = Qnil;
|
|
1111
|
|
1112 plist = Fcopy_sequence (plist);
|
|
1113 Fcanonicalize_plist (plist, Qnil);
|
|
1114
|
442
|
1115 #define WRONG_EVENT_TYPE_FOR_PROPERTY(event_type, prop) \
|
563
|
1116 invalid_argument_2 ("Invalid property for event type", prop, event_type)
|
428
|
1117
|
442
|
1118 {
|
|
1119 EXTERNAL_PROPERTY_LIST_LOOP_3 (keyword, value, plist)
|
|
1120 {
|
|
1121 if (EQ (keyword, Qchannel))
|
|
1122 {
|
934
|
1123 #ifdef USE_KKCC
|
|
1124 if (EVENT_TYPE(e) == key_press_event)
|
|
1125 #else /* not USE_KKCC */
|
442
|
1126 if (e->event_type == key_press_event)
|
934
|
1127 #endif /* not USE_KKCC */
|
442
|
1128 {
|
|
1129 if (!CONSOLEP (value))
|
|
1130 value = wrong_type_argument (Qconsolep, value);
|
|
1131 }
|
|
1132 else
|
|
1133 {
|
|
1134 if (!FRAMEP (value))
|
|
1135 value = wrong_type_argument (Qframep, value);
|
|
1136 }
|
|
1137 EVENT_CHANNEL (e) = value;
|
|
1138 }
|
|
1139 else if (EQ (keyword, Qkey))
|
|
1140 {
|
934
|
1141 #ifdef USE_KKCC
|
|
1142 switch (EVENT_TYPE(e))
|
|
1143 #else /* not USE_KKCC */
|
442
|
1144 switch (e->event_type)
|
934
|
1145 #endif /* not USE_KKCC */
|
442
|
1146 {
|
|
1147 case key_press_event:
|
|
1148 if (!SYMBOLP (value) && !CHARP (value))
|
563
|
1149 invalid_argument ("Invalid event key", value);
|
934
|
1150 #ifdef USE_KKCC
|
|
1151 XSET_KEY_DATA_KEYSYM (EVENT_DATA(e), value);
|
|
1152 #else /* not USE_KKCC */
|
442
|
1153 e->event.key.keysym = value;
|
934
|
1154 #endif /* not USE_KKCC */
|
442
|
1155 break;
|
|
1156 default:
|
|
1157 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword);
|
|
1158 break;
|
|
1159 }
|
|
1160 }
|
|
1161 else if (EQ (keyword, Qbutton))
|
|
1162 {
|
|
1163 CHECK_NATNUM (value);
|
|
1164 check_int_range (XINT (value), 0, 7);
|
428
|
1165
|
934
|
1166 #ifdef USE_KKCC
|
|
1167 switch (EVENT_TYPE(e))
|
|
1168 #else /* not USE_KKCC */
|
442
|
1169 switch (e->event_type)
|
934
|
1170 #endif /* not USE_KKCC */
|
442
|
1171 {
|
|
1172 case button_press_event:
|
|
1173 case button_release_event:
|
934
|
1174 #ifdef USE_KKCC
|
|
1175 XSET_BUTTON_DATA_BUTTON (EVENT_DATA (e), XINT (value));
|
|
1176 #else /* not USE_KKCC */
|
442
|
1177 e->event.button.button = XINT (value);
|
934
|
1178 #endif /* not USE_KKCC */
|
442
|
1179 break;
|
|
1180 case misc_user_event:
|
934
|
1181 #ifdef USE_KKCC
|
|
1182 XSET_MISC_USER_DATA_BUTTON (EVENT_DATA (e), XINT (value));
|
|
1183 #else /* not USE_KKCC */
|
442
|
1184 e->event.misc.button = XINT (value);
|
934
|
1185 #endif /* not USE_KKCC */
|
442
|
1186 break;
|
|
1187 default:
|
|
1188 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword);
|
|
1189 break;
|
|
1190 }
|
|
1191 }
|
|
1192 else if (EQ (keyword, Qmodifiers))
|
|
1193 {
|
|
1194 int modifiers = 0;
|
428
|
1195
|
442
|
1196 EXTERNAL_LIST_LOOP_2 (sym, value)
|
|
1197 {
|
|
1198 if (EQ (sym, Qcontrol)) modifiers |= XEMACS_MOD_CONTROL;
|
|
1199 else if (EQ (sym, Qmeta)) modifiers |= XEMACS_MOD_META;
|
|
1200 else if (EQ (sym, Qsuper)) modifiers |= XEMACS_MOD_SUPER;
|
|
1201 else if (EQ (sym, Qhyper)) modifiers |= XEMACS_MOD_HYPER;
|
|
1202 else if (EQ (sym, Qalt)) modifiers |= XEMACS_MOD_ALT;
|
|
1203 else if (EQ (sym, Qsymbol)) modifiers |= XEMACS_MOD_ALT;
|
|
1204 else if (EQ (sym, Qshift)) modifiers |= XEMACS_MOD_SHIFT;
|
|
1205 else if (EQ (sym, Qbutton1)) modifiers |= XEMACS_MOD_BUTTON1;
|
|
1206 else if (EQ (sym, Qbutton2)) modifiers |= XEMACS_MOD_BUTTON2;
|
|
1207 else if (EQ (sym, Qbutton3)) modifiers |= XEMACS_MOD_BUTTON3;
|
|
1208 else if (EQ (sym, Qbutton4)) modifiers |= XEMACS_MOD_BUTTON4;
|
|
1209 else if (EQ (sym, Qbutton5)) modifiers |= XEMACS_MOD_BUTTON5;
|
|
1210 else
|
563
|
1211 invalid_constant ("Invalid key modifier", sym);
|
442
|
1212 }
|
428
|
1213
|
934
|
1214 #ifdef USE_KKCC
|
|
1215 switch (EVENT_TYPE(e))
|
|
1216 #else /* not USE_KKCC */
|
442
|
1217 switch (e->event_type)
|
934
|
1218 #endif /* not USE_KKCC */
|
442
|
1219 {
|
|
1220 case key_press_event:
|
934
|
1221 #ifdef USE_KKCC
|
|
1222 XSET_KEY_DATA_MODIFIERS (EVENT_DATA (e), modifiers);
|
|
1223 #else /* not USE_KKCC */
|
442
|
1224 e->event.key.modifiers = modifiers;
|
934
|
1225 #endif /* not USE_KKCC */
|
442
|
1226 break;
|
|
1227 case button_press_event:
|
|
1228 case button_release_event:
|
934
|
1229 #ifdef USE_KKCC
|
|
1230 XSET_BUTTON_DATA_MODIFIERS (EVENT_DATA (e), modifiers);
|
|
1231 #else /* not USE_KKCC */
|
442
|
1232 e->event.button.modifiers = modifiers;
|
934
|
1233 #endif /* not USE_KKCC */
|
442
|
1234 break;
|
|
1235 case pointer_motion_event:
|
934
|
1236 #ifdef USE_KKCC
|
|
1237 XSET_MOTION_DATA_MODIFIERS (EVENT_DATA (e), modifiers);
|
|
1238 #else /* not USE_KKCC */
|
442
|
1239 e->event.motion.modifiers = modifiers;
|
934
|
1240 #endif /* not USE_KKCC */
|
442
|
1241 break;
|
|
1242 case misc_user_event:
|
934
|
1243 #ifdef USE_KKCC
|
|
1244 XSET_MISC_USER_DATA_MODIFIERS (EVENT_DATA (e), modifiers);
|
|
1245 #else /* not USE_KKCC */
|
442
|
1246 e->event.misc.modifiers = modifiers;
|
934
|
1247 #endif /* not USE_KKCC */
|
442
|
1248 break;
|
|
1249 default:
|
|
1250 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword);
|
|
1251 break;
|
|
1252 }
|
|
1253 }
|
|
1254 else if (EQ (keyword, Qx))
|
|
1255 {
|
934
|
1256 #ifdef USE_KKCC
|
|
1257 switch (EVENT_TYPE(e))
|
|
1258 #else /* not USE_KKCC */
|
442
|
1259 switch (e->event_type)
|
934
|
1260 #endif /* not USE_KKCC */
|
442
|
1261 {
|
|
1262 case pointer_motion_event:
|
|
1263 case button_press_event:
|
|
1264 case button_release_event:
|
|
1265 case misc_user_event:
|
|
1266 /* Allow negative values, so we can specify toolbar
|
|
1267 positions. */
|
|
1268 CHECK_INT (value);
|
|
1269 coord_x = XINT (value);
|
|
1270 break;
|
|
1271 default:
|
|
1272 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword);
|
|
1273 break;
|
|
1274 }
|
|
1275 }
|
|
1276 else if (EQ (keyword, Qy))
|
|
1277 {
|
934
|
1278 #ifdef USE_KKCC
|
|
1279 switch (EVENT_TYPE(e))
|
|
1280 #else /* not USE_KKCC */
|
442
|
1281 switch (e->event_type)
|
934
|
1282 #endif /* not USE_KKCC */
|
442
|
1283 {
|
|
1284 case pointer_motion_event:
|
|
1285 case button_press_event:
|
|
1286 case button_release_event:
|
|
1287 case misc_user_event:
|
|
1288 /* Allow negative values; see above. */
|
|
1289 CHECK_INT (value);
|
|
1290 coord_y = XINT (value);
|
|
1291 break;
|
|
1292 default:
|
|
1293 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword);
|
|
1294 break;
|
|
1295 }
|
|
1296 }
|
|
1297 else if (EQ (keyword, Qtimestamp))
|
|
1298 {
|
|
1299 CHECK_NATNUM (value);
|
934
|
1300 #ifdef USE_KKCC
|
|
1301 SET_EVENT_TIMESTAMP (e, XINT (value));
|
|
1302 #else /* not USE_KKCC */
|
442
|
1303 e->timestamp = XINT (value);
|
934
|
1304 #endif /* not USE_KKCC */
|
442
|
1305 }
|
|
1306 else if (EQ (keyword, Qfunction))
|
|
1307 {
|
934
|
1308 #ifdef USE_KKCC
|
|
1309 switch (EVENT_TYPE(e))
|
|
1310 #else /* not USE_KKCC */
|
442
|
1311 switch (e->event_type)
|
934
|
1312 #endif /* not USE_KKCC */
|
442
|
1313 {
|
|
1314 case misc_user_event:
|
934
|
1315 #ifdef USE_KKCC
|
|
1316 XSET_MISC_USER_DATA_FUNCTION (EVENT_DATA (e), value);
|
|
1317 #else /* not USE_KKCC */
|
442
|
1318 e->event.eval.function = value;
|
934
|
1319 #endif /* not USE_KKCC */
|
442
|
1320 break;
|
|
1321 default:
|
|
1322 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword);
|
|
1323 break;
|
|
1324 }
|
|
1325 }
|
|
1326 else if (EQ (keyword, Qobject))
|
|
1327 {
|
934
|
1328 #ifdef USE_KKCC
|
|
1329 switch (EVENT_TYPE(e))
|
|
1330 #else /* not USE_KKCC */
|
442
|
1331 switch (e->event_type)
|
934
|
1332 #endif /* not USE_KKCC */
|
442
|
1333 {
|
|
1334 case misc_user_event:
|
934
|
1335 #ifdef USE_KKCC
|
|
1336 XSET_MISC_USER_DATA_OBJECT (EVENT_DATA (e), value);
|
|
1337 #else /* not USE_KKCC */
|
442
|
1338 e->event.eval.object = value;
|
934
|
1339 #endif /* not USE_KKCC */
|
442
|
1340 break;
|
|
1341 default:
|
|
1342 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword);
|
|
1343 break;
|
|
1344 }
|
|
1345 }
|
|
1346 else
|
563
|
1347 invalid_constant_2 ("Invalid property", keyword, value);
|
442
|
1348 }
|
|
1349 }
|
428
|
1350
|
|
1351 /* Insert the channel, if missing. */
|
|
1352 if (NILP (EVENT_CHANNEL (e)))
|
|
1353 {
|
934
|
1354 #ifdef USE_KKCC
|
|
1355 if (EVENT_TYPE (e) == key_press_event)
|
|
1356 #else /* not USE_KKCC */
|
428
|
1357 if (e->event_type == key_press_event)
|
934
|
1358 #endif /* not USE_KKCC */
|
428
|
1359 EVENT_CHANNEL (e) = Vselected_console;
|
|
1360 else
|
|
1361 EVENT_CHANNEL (e) = Fselected_frame (Qnil);
|
|
1362 }
|
|
1363
|
|
1364 /* Fevent_properties, Fevent_x_pixel, etc. work with pixels relative
|
|
1365 to the frame, so we must adjust accordingly. */
|
|
1366 if (FRAMEP (EVENT_CHANNEL (e)))
|
|
1367 {
|
|
1368 coord_x += FRAME_REAL_LEFT_TOOLBAR_WIDTH (XFRAME (EVENT_CHANNEL (e)));
|
|
1369 coord_y += FRAME_REAL_TOP_TOOLBAR_HEIGHT (XFRAME (EVENT_CHANNEL (e)));
|
|
1370
|
|
1371 switch (e->event_type)
|
|
1372 {
|
|
1373 case pointer_motion_event:
|
934
|
1374 #ifdef USE_KKCC
|
|
1375 XSET_MOTION_DATA_X (EVENT_DATA (e), coord_x);
|
|
1376 XSET_MOTION_DATA_Y (EVENT_DATA (e), coord_y);
|
|
1377 #else /* not USE_KKCC */
|
428
|
1378 e->event.motion.x = coord_x;
|
|
1379 e->event.motion.y = coord_y;
|
934
|
1380 #endif /* not USE_KKCC */
|
428
|
1381 break;
|
|
1382 case button_press_event:
|
|
1383 case button_release_event:
|
934
|
1384 #ifdef USE_KKCC
|
|
1385 XSET_BUTTON_DATA_X (EVENT_DATA (e), coord_x);
|
|
1386 XSET_BUTTON_DATA_Y (EVENT_DATA (e), coord_y);
|
|
1387 #else /* not USE_KKCC */
|
428
|
1388 e->event.button.x = coord_x;
|
|
1389 e->event.button.y = coord_y;
|
934
|
1390 #endif /* not USE_KKCC */
|
428
|
1391 break;
|
|
1392 case misc_user_event:
|
934
|
1393 #ifdef USE_KKCC
|
|
1394 XSET_MISC_USER_DATA_X (EVENT_DATA (e), coord_x);
|
|
1395 XSET_MISC_USER_DATA_Y (EVENT_DATA (e), coord_y);
|
|
1396 #else /* not USE_KKCC */
|
428
|
1397 e->event.misc.x = coord_x;
|
|
1398 e->event.misc.y = coord_y;
|
934
|
1399 #endif /* not USE_KKCC */
|
428
|
1400 break;
|
|
1401 default:
|
|
1402 abort();
|
|
1403 }
|
|
1404 }
|
|
1405
|
|
1406 /* Finally, do some more validation. */
|
934
|
1407 #ifdef USE_KKCC
|
|
1408 switch (EVENT_TYPE(e))
|
|
1409 #else /* not USE_KKCC */
|
428
|
1410 switch (e->event_type)
|
934
|
1411 #endif /* not USE_KKCC */
|
428
|
1412 {
|
|
1413 case key_press_event:
|
934
|
1414 #ifdef USE_KKCC
|
|
1415 if (UNBOUNDP (XKEY_DATA_KEYSYM (EVENT_DATA (e))))
|
|
1416 #else /* not USE_KKCC */
|
428
|
1417 if (UNBOUNDP (e->event.key.keysym))
|
934
|
1418 #endif /* not USE_KKCC */
|
563
|
1419 sferror ("A key must be specified to make a keypress event",
|
442
|
1420 plist);
|
428
|
1421 break;
|
|
1422 case button_press_event:
|
934
|
1423 #ifdef USE_KKCC
|
|
1424 if (!XBUTTON_DATA_BUTTON (EVENT_DATA (e)))
|
|
1425 #else /* not USE_KKCC */
|
428
|
1426 if (!e->event.button.button)
|
934
|
1427 #endif /* not USE_KKCC */
|
563
|
1428 sferror
|
442
|
1429 ("A button must be specified to make a button-press event",
|
|
1430 plist);
|
428
|
1431 break;
|
|
1432 case button_release_event:
|
934
|
1433 #ifdef USE_KKCC
|
|
1434 if (!XBUTTON_DATA_BUTTON (EVENT_DATA (e)))
|
|
1435 #else /* not USE_KKCC */
|
428
|
1436 if (!e->event.button.button)
|
934
|
1437 #endif /* not USE_KKCC */
|
563
|
1438 sferror
|
442
|
1439 ("A button must be specified to make a button-release event",
|
|
1440 plist);
|
428
|
1441 break;
|
|
1442 case misc_user_event:
|
934
|
1443 #ifdef USE_KKCC
|
|
1444 if (NILP (XMISC_USER_DATA_FUNCTION (EVENT_DATA (e))))
|
|
1445 #else /* not USE_KKCC */
|
428
|
1446 if (NILP (e->event.misc.function))
|
934
|
1447 #endif /* not USE_KKCC */
|
563
|
1448 sferror ("A function must be specified to make a misc-user event",
|
442
|
1449 plist);
|
428
|
1450 break;
|
|
1451 default:
|
|
1452 break;
|
|
1453 }
|
|
1454
|
|
1455 UNGCPRO;
|
|
1456 return event;
|
|
1457 }
|
|
1458
|
934
|
1459
|
|
1460 #ifdef USE_KKCC
|
|
1461
|
|
1462 Lisp_Object
|
|
1463 make_key_data (void)
|
|
1464 {
|
|
1465 Lisp_Object data = allocate_key_data ();
|
|
1466
|
|
1467 XSET_KEY_DATA_KEYSYM (data, Qnil);
|
|
1468 XSET_KEY_DATA_MODIFIERS (data, 0);
|
|
1469
|
|
1470 return data;
|
|
1471 }
|
|
1472
|
|
1473 Lisp_Object
|
|
1474 make_button_data (void)
|
|
1475 {
|
|
1476 Lisp_Object data = allocate_button_data ();
|
|
1477
|
|
1478 XSET_BUTTON_DATA_BUTTON (data, 0);
|
|
1479 XSET_BUTTON_DATA_MODIFIERS (data, 0);
|
|
1480 XSET_BUTTON_DATA_X (data, 0);
|
|
1481 XSET_BUTTON_DATA_Y (data, 0);
|
|
1482
|
|
1483 return data;
|
|
1484 }
|
|
1485
|
|
1486 Lisp_Object
|
|
1487 make_motion_data (void)
|
|
1488 {
|
|
1489 Lisp_Object data = allocate_motion_data ();
|
|
1490
|
|
1491 XSET_MOTION_DATA_X (data, 0);
|
|
1492 XSET_MOTION_DATA_Y (data, 0);
|
|
1493 XSET_MOTION_DATA_MODIFIERS (data, 0);
|
|
1494
|
|
1495 return data;
|
|
1496 }
|
|
1497
|
|
1498 Lisp_Object
|
|
1499 make_process_data (void)
|
|
1500 {
|
|
1501 Lisp_Object data = allocate_process_data ();
|
|
1502
|
|
1503 XSET_PROCESS_DATA_PROCESS (data, Qnil);
|
|
1504
|
|
1505 return data;
|
|
1506 }
|
|
1507
|
|
1508 Lisp_Object
|
|
1509 make_timeout_data (void)
|
|
1510 {
|
|
1511 Lisp_Object data = allocate_timeout_data ();
|
|
1512
|
|
1513 XSET_TIMEOUT_DATA_INTERVAL_ID (data, 0);
|
|
1514 XSET_TIMEOUT_DATA_ID_NUMBER(data, 0);
|
|
1515 XSET_TIMEOUT_DATA_FUNCTION(data, Qnil);
|
|
1516 XSET_TIMEOUT_DATA_OBJECT (data, Qnil);
|
|
1517
|
|
1518 return data;
|
|
1519 }
|
|
1520
|
|
1521 Lisp_Object
|
|
1522 make_magic_eval_data (void)
|
|
1523 {
|
|
1524 Lisp_Object data = allocate_magic_eval_data ();
|
|
1525
|
|
1526 XSET_MAGIC_EVAL_DATA_OBJECT (data, Qnil);
|
|
1527 XSET_MAGIC_EVAL_DATA_INTERNAL_FUNOBJ (data, 0);
|
|
1528
|
|
1529 return data;
|
|
1530 }
|
|
1531
|
|
1532 Lisp_Object
|
|
1533 make_eval_data (void)
|
|
1534 {
|
|
1535 Lisp_Object data = allocate_eval_data ();
|
|
1536
|
|
1537 XSET_EVAL_DATA_FUNCTION (data, Qnil);
|
|
1538 XSET_EVAL_DATA_OBJECT (data, Qnil);
|
|
1539
|
|
1540 return data;
|
|
1541 }
|
|
1542
|
|
1543 Lisp_Object
|
|
1544 make_magic_data (void)
|
|
1545 {
|
|
1546 return allocate_magic_data ();
|
|
1547 }
|
|
1548
|
|
1549 Lisp_Object
|
|
1550 make_misc_user_data (void)
|
|
1551 {
|
|
1552 Lisp_Object data = allocate_misc_user_data ();
|
|
1553
|
|
1554 XSET_MISC_USER_DATA_FUNCTION (data, Qnil);
|
|
1555 XSET_MISC_USER_DATA_OBJECT (data, Qnil);
|
943
|
1556 XSET_MISC_USER_DATA_BUTTON (data, 0);
|
934
|
1557 XSET_MISC_USER_DATA_MODIFIERS (data, 0);
|
|
1558 XSET_MISC_USER_DATA_X (data, 0);
|
|
1559 XSET_MISC_USER_DATA_Y (data, 0);
|
|
1560
|
|
1561 return data;
|
|
1562 }
|
|
1563 #endif /* USE_KKCC */
|
|
1564
|
|
1565
|
|
1566
|
428
|
1567 DEFUN ("deallocate-event", Fdeallocate_event, 1, 1, 0, /*
|
|
1568 Allow the given event structure to be reused.
|
|
1569 You MUST NOT use this event object after calling this function with it.
|
|
1570 You will lose. It is not necessary to call this function, as event
|
|
1571 objects are garbage-collected like all other objects; however, it may
|
|
1572 be more efficient to explicitly deallocate events when you are sure
|
|
1573 that it is safe to do so.
|
|
1574 */
|
|
1575 (event))
|
|
1576 {
|
|
1577 CHECK_EVENT (event);
|
|
1578
|
|
1579 if (XEVENT_TYPE (event) == dead_event)
|
563
|
1580 invalid_argument ("this event is already deallocated!", Qunbound);
|
428
|
1581
|
|
1582 assert (XEVENT_TYPE (event) <= last_event_type);
|
|
1583
|
|
1584 #if 0
|
|
1585 {
|
|
1586 int i, len;
|
|
1587
|
|
1588 if (EQ (event, Vlast_command_event) ||
|
|
1589 EQ (event, Vlast_input_event) ||
|
|
1590 EQ (event, Vunread_command_event))
|
|
1591 abort ();
|
|
1592
|
|
1593 len = XVECTOR_LENGTH (Vthis_command_keys);
|
|
1594 for (i = 0; i < len; i++)
|
|
1595 if (EQ (event, XVECTOR_DATA (Vthis_command_keys) [i]))
|
|
1596 abort ();
|
|
1597 if (!NILP (Vrecent_keys_ring))
|
|
1598 {
|
|
1599 int recent_ring_len = XVECTOR_LENGTH (Vrecent_keys_ring);
|
|
1600 for (i = 0; i < recent_ring_len; i++)
|
|
1601 if (EQ (event, XVECTOR_DATA (Vrecent_keys_ring) [i]))
|
|
1602 abort ();
|
|
1603 }
|
|
1604 }
|
|
1605 #endif /* 0 */
|
|
1606
|
|
1607 assert (!EQ (event, Vevent_resource));
|
|
1608 deinitialize_event (event);
|
|
1609 #ifndef ALLOC_NO_POOLS
|
|
1610 XSET_EVENT_NEXT (event, Vevent_resource);
|
|
1611 Vevent_resource = event;
|
|
1612 #endif
|
|
1613 return Qnil;
|
|
1614 }
|
|
1615
|
934
|
1616 #ifdef USE_KKCC
|
|
1617 void
|
|
1618 copy_event_data (Lisp_Object dest, Lisp_Object src)
|
|
1619 {
|
|
1620 switch (XRECORD_LHEADER (dest)->type) {
|
|
1621 case lrecord_type_key_data:
|
|
1622 XSET_KEY_DATA_KEYSYM (dest, XKEY_DATA_KEYSYM (src));
|
|
1623 XSET_KEY_DATA_MODIFIERS (dest, XKEY_DATA_MODIFIERS (src));
|
|
1624 break;
|
|
1625 case lrecord_type_button_data:
|
|
1626 XSET_BUTTON_DATA_BUTTON (dest, XBUTTON_DATA_BUTTON (src));
|
|
1627 XSET_BUTTON_DATA_MODIFIERS (dest, XBUTTON_DATA_MODIFIERS (src));
|
|
1628 XSET_BUTTON_DATA_X (dest, XBUTTON_DATA_X (src));
|
|
1629 XSET_BUTTON_DATA_Y (dest, XBUTTON_DATA_Y (src));
|
|
1630 break;
|
|
1631 case lrecord_type_motion_data:
|
|
1632 XSET_MOTION_DATA_X (dest, XMOTION_DATA_X (src));
|
|
1633 XSET_MOTION_DATA_Y (dest, XMOTION_DATA_Y (src));
|
|
1634 XSET_MOTION_DATA_MODIFIERS (dest, XMOTION_DATA_MODIFIERS (src));
|
|
1635 break;
|
|
1636 case lrecord_type_process_data:
|
|
1637 XSET_PROCESS_DATA_PROCESS (dest, XPROCESS_DATA_PROCESS (src));
|
|
1638 break;
|
|
1639 case lrecord_type_timeout_data:
|
|
1640 XSET_TIMEOUT_DATA_INTERVAL_ID (dest, XTIMEOUT_DATA_INTERVAL_ID (src));
|
|
1641 XSET_TIMEOUT_DATA_ID_NUMBER (dest, XTIMEOUT_DATA_ID_NUMBER (src));
|
|
1642 XSET_TIMEOUT_DATA_FUNCTION (dest, XTIMEOUT_DATA_FUNCTION (src));
|
|
1643 XSET_TIMEOUT_DATA_OBJECT (dest, XTIMEOUT_DATA_OBJECT (src));
|
|
1644 break;
|
|
1645 case lrecord_type_eval_data:
|
|
1646 XSET_EVAL_DATA_FUNCTION (dest, XEVAL_DATA_FUNCTION (src));
|
|
1647 XSET_EVAL_DATA_OBJECT (dest, XEVAL_DATA_OBJECT (src));
|
|
1648 break;
|
|
1649 case lrecord_type_misc_user_data:
|
|
1650 XSET_MISC_USER_DATA_FUNCTION (dest, XMISC_USER_DATA_FUNCTION (src));
|
|
1651 XSET_MISC_USER_DATA_OBJECT (dest, XMISC_USER_DATA_OBJECT (src));
|
|
1652 XSET_MISC_USER_DATA_BUTTON (dest, XMISC_USER_DATA_BUTTON (src));
|
|
1653 XSET_MISC_USER_DATA_MODIFIERS (dest, XMISC_USER_DATA_MODIFIERS (src));
|
|
1654 XSET_MISC_USER_DATA_X (dest, XMISC_USER_DATA_X (src));
|
|
1655 XSET_MISC_USER_DATA_Y (dest, XMISC_USER_DATA_Y (src));
|
|
1656 break;
|
|
1657 case lrecord_type_magic_eval_data:
|
|
1658 XSET_MAGIC_EVAL_DATA_INTERNAL_FUNCTION (dest, XMAGIC_EVAL_DATA_INTERNAL_FUNCTION (src));
|
|
1659 XSET_MAGIC_EVAL_DATA_OBJECT (dest, XMAGIC_EVAL_DATA_OBJECT (src));
|
|
1660 break;
|
|
1661 case lrecord_type_magic_data:
|
|
1662 XSET_MAGIC_DATA_UNDERLYING (dest, XMAGIC_DATA_UNDERLYING (src));
|
|
1663 break;
|
|
1664 default:
|
|
1665 break;
|
|
1666 }
|
|
1667 }
|
|
1668 #endif /* USE_KKCC */
|
|
1669
|
428
|
1670 DEFUN ("copy-event", Fcopy_event, 1, 2, 0, /*
|
444
|
1671 Make a copy of the event object EVENT1.
|
|
1672 If a second event argument EVENT2 is given, EVENT1 is copied into
|
|
1673 EVENT2 and EVENT2 is returned. If EVENT2 is not supplied (or is nil)
|
|
1674 then a new event will be made as with `make-event'. See also the
|
|
1675 function `deallocate-event'.
|
428
|
1676 */
|
|
1677 (event1, event2))
|
|
1678 {
|
|
1679 CHECK_LIVE_EVENT (event1);
|
|
1680 if (NILP (event2))
|
|
1681 event2 = Fmake_event (Qnil, Qnil);
|
430
|
1682 else
|
|
1683 {
|
|
1684 CHECK_LIVE_EVENT (event2);
|
|
1685 if (EQ (event1, event2))
|
563
|
1686 return signal_continuable_error_2
|
|
1687 (Qinvalid_argument,
|
|
1688 "copy-event called with `eq' events", event1, event2);
|
430
|
1689 }
|
428
|
1690
|
|
1691 assert (XEVENT_TYPE (event1) <= last_event_type);
|
|
1692 assert (XEVENT_TYPE (event2) <= last_event_type);
|
|
1693
|
934
|
1694 #ifdef USE_KKCC
|
|
1695 XSET_EVENT_TYPE (event2, XEVENT_TYPE (event1));
|
|
1696 XSET_EVENT_CHANNEL (event2, XEVENT_CHANNEL (event1));
|
|
1697 XSET_EVENT_TIMESTAMP (event2, XEVENT_TIMESTAMP (event1));
|
|
1698 copy_event_data (XEVENT_DATA (event2), XEVENT_DATA (event1));
|
|
1699
|
|
1700 return event2;
|
|
1701 #else /* not USE_KKCC */
|
428
|
1702 {
|
430
|
1703 Lisp_Event *ev2 = XEVENT (event2);
|
|
1704 Lisp_Event *ev1 = XEVENT (event1);
|
428
|
1705
|
430
|
1706 ev2->event_type = ev1->event_type;
|
|
1707 ev2->channel = ev1->channel;
|
|
1708 ev2->timestamp = ev1->timestamp;
|
|
1709 ev2->event = ev1->event;
|
|
1710
|
428
|
1711 return event2;
|
|
1712 }
|
934
|
1713 #endif /* not USE_KKCC */
|
428
|
1714 }
|
|
1715
|
|
1716
|
771
|
1717 /************************************************************************/
|
|
1718 /* event chain functions */
|
|
1719 /************************************************************************/
|
428
|
1720
|
|
1721 /* Given a chain of events (or possibly nil), deallocate them all. */
|
|
1722
|
|
1723 void
|
|
1724 deallocate_event_chain (Lisp_Object event_chain)
|
|
1725 {
|
|
1726 while (!NILP (event_chain))
|
|
1727 {
|
|
1728 Lisp_Object next = XEVENT_NEXT (event_chain);
|
|
1729 Fdeallocate_event (event_chain);
|
|
1730 event_chain = next;
|
|
1731 }
|
|
1732 }
|
|
1733
|
|
1734 /* Return the last event in a chain.
|
|
1735 NOTE: You cannot pass nil as a value here! The routine will
|
|
1736 abort if you do. */
|
|
1737
|
|
1738 Lisp_Object
|
|
1739 event_chain_tail (Lisp_Object event_chain)
|
|
1740 {
|
|
1741 while (1)
|
|
1742 {
|
|
1743 Lisp_Object next = XEVENT_NEXT (event_chain);
|
|
1744 if (NILP (next))
|
|
1745 return event_chain;
|
|
1746 event_chain = next;
|
|
1747 }
|
|
1748 }
|
|
1749
|
|
1750 /* Enqueue a single event onto the end of a chain of events.
|
|
1751 HEAD points to the first event in the chain, TAIL to the last event.
|
|
1752 If the chain is empty, both values should be nil. */
|
|
1753
|
|
1754 void
|
|
1755 enqueue_event (Lisp_Object event, Lisp_Object *head, Lisp_Object *tail)
|
|
1756 {
|
|
1757 assert (NILP (XEVENT_NEXT (event)));
|
|
1758 assert (!EQ (*tail, event));
|
|
1759
|
|
1760 if (!NILP (*tail))
|
|
1761 XSET_EVENT_NEXT (*tail, event);
|
|
1762 else
|
|
1763 *head = event;
|
|
1764 *tail = event;
|
|
1765
|
|
1766 assert (!EQ (event, XEVENT_NEXT (event)));
|
|
1767 }
|
|
1768
|
|
1769 /* Remove an event off the head of a chain of events and return it.
|
|
1770 HEAD points to the first event in the chain, TAIL to the last event. */
|
|
1771
|
|
1772 Lisp_Object
|
|
1773 dequeue_event (Lisp_Object *head, Lisp_Object *tail)
|
|
1774 {
|
|
1775 Lisp_Object event;
|
|
1776
|
|
1777 event = *head;
|
|
1778 *head = XEVENT_NEXT (event);
|
|
1779 XSET_EVENT_NEXT (event, Qnil);
|
|
1780 if (NILP (*head))
|
|
1781 *tail = Qnil;
|
|
1782 return event;
|
|
1783 }
|
|
1784
|
|
1785 /* Enqueue a chain of events (or possibly nil) onto the end of another
|
|
1786 chain of events. HEAD points to the first event in the chain being
|
|
1787 queued onto, TAIL to the last event. If the chain is empty, both values
|
|
1788 should be nil. */
|
|
1789
|
|
1790 void
|
|
1791 enqueue_event_chain (Lisp_Object event_chain, Lisp_Object *head,
|
|
1792 Lisp_Object *tail)
|
|
1793 {
|
|
1794 if (NILP (event_chain))
|
|
1795 return;
|
|
1796
|
|
1797 if (NILP (*head))
|
|
1798 {
|
|
1799 *head = event_chain;
|
|
1800 *tail = event_chain;
|
|
1801 }
|
|
1802 else
|
|
1803 {
|
|
1804 XSET_EVENT_NEXT (*tail, event_chain);
|
|
1805 *tail = event_chain_tail (event_chain);
|
|
1806 }
|
|
1807 }
|
|
1808
|
|
1809 /* Return the number of events (possibly 0) on an event chain. */
|
|
1810
|
|
1811 int
|
|
1812 event_chain_count (Lisp_Object event_chain)
|
|
1813 {
|
|
1814 Lisp_Object event;
|
|
1815 int n = 0;
|
|
1816
|
|
1817 EVENT_CHAIN_LOOP (event, event_chain)
|
|
1818 n++;
|
|
1819
|
|
1820 return n;
|
|
1821 }
|
|
1822
|
|
1823 /* Find the event before EVENT in an event chain. This aborts
|
|
1824 if the event is not in the chain. */
|
|
1825
|
|
1826 Lisp_Object
|
|
1827 event_chain_find_previous (Lisp_Object event_chain, Lisp_Object event)
|
|
1828 {
|
|
1829 Lisp_Object previous = Qnil;
|
|
1830
|
|
1831 while (!NILP (event_chain))
|
|
1832 {
|
|
1833 if (EQ (event_chain, event))
|
|
1834 return previous;
|
|
1835 previous = event_chain;
|
|
1836 event_chain = XEVENT_NEXT (event_chain);
|
|
1837 }
|
|
1838
|
|
1839 abort ();
|
|
1840 return Qnil;
|
|
1841 }
|
|
1842
|
|
1843 Lisp_Object
|
|
1844 event_chain_nth (Lisp_Object event_chain, int n)
|
|
1845 {
|
|
1846 Lisp_Object event;
|
|
1847 EVENT_CHAIN_LOOP (event, event_chain)
|
|
1848 {
|
|
1849 if (!n)
|
|
1850 return event;
|
|
1851 n--;
|
|
1852 }
|
|
1853 return Qnil;
|
|
1854 }
|
|
1855
|
771
|
1856 /* Return a freshly allocated copy of all events in the given chain. */
|
|
1857
|
428
|
1858 Lisp_Object
|
|
1859 copy_event_chain (Lisp_Object event_chain)
|
|
1860 {
|
|
1861 Lisp_Object new_chain = Qnil;
|
|
1862 Lisp_Object new_chain_tail = Qnil;
|
|
1863 Lisp_Object event;
|
|
1864
|
|
1865 EVENT_CHAIN_LOOP (event, event_chain)
|
|
1866 {
|
|
1867 Lisp_Object copy = Fcopy_event (event, Qnil);
|
|
1868 enqueue_event (copy, &new_chain, &new_chain_tail);
|
|
1869 }
|
|
1870
|
|
1871 return new_chain;
|
|
1872 }
|
|
1873
|
771
|
1874 /* Given a pointer (maybe nil) into an old chain (also maybe nil, if
|
|
1875 pointer is nil) and a new chain which is a copy of the old, return
|
|
1876 the corresponding new pointer. */
|
|
1877 Lisp_Object
|
|
1878 transfer_event_chain_pointer (Lisp_Object pointer, Lisp_Object old_chain,
|
|
1879 Lisp_Object new_chain)
|
|
1880 {
|
|
1881 if (NILP (pointer))
|
|
1882 return Qnil;
|
|
1883 assert (!NILP (old_chain));
|
800
|
1884 #ifdef ERROR_CHECK_STRUCTURES
|
771
|
1885 /* make sure we're actually in the chain */
|
|
1886 event_chain_find_previous (old_chain, pointer);
|
|
1887 assert (event_chain_count (old_chain) == event_chain_count (new_chain));
|
800
|
1888 #endif /* ERROR_CHECK_STRUCTURES */
|
771
|
1889 return event_chain_nth (new_chain,
|
|
1890 event_chain_count (old_chain) -
|
|
1891 event_chain_count (pointer));
|
|
1892 }
|
|
1893
|
428
|
1894
|
771
|
1895 /************************************************************************/
|
|
1896 /* higher level functions */
|
|
1897 /************************************************************************/
|
428
|
1898
|
|
1899 Lisp_Object QKbackspace, QKtab, QKlinefeed, QKreturn, QKescape,
|
|
1900 QKspace, QKdelete;
|
|
1901
|
|
1902 int
|
|
1903 command_event_p (Lisp_Object event)
|
|
1904 {
|
|
1905 switch (XEVENT_TYPE (event))
|
|
1906 {
|
|
1907 case key_press_event:
|
|
1908 case button_press_event:
|
|
1909 case button_release_event:
|
|
1910 case misc_user_event:
|
|
1911 return 1;
|
|
1912 default:
|
|
1913 return 0;
|
|
1914 }
|
|
1915 }
|
|
1916
|
|
1917
|
|
1918 void
|
867
|
1919 character_to_event (Ichar c, Lisp_Event *event, struct console *con,
|
428
|
1920 int use_console_meta_flag, int do_backspace_mapping)
|
|
1921 {
|
|
1922 Lisp_Object k = Qnil;
|
442
|
1923 int m = 0;
|
934
|
1924 #ifdef USE_KKCC
|
|
1925 if (EVENT_TYPE (event) == dead_event)
|
|
1926 #else /* not USE_KKCC */
|
428
|
1927 if (event->event_type == dead_event)
|
934
|
1928 #endif /* not USE_KKCC */
|
563
|
1929 invalid_argument ("character-to-event called with a deallocated event!", Qunbound);
|
428
|
1930
|
|
1931 #ifndef MULE
|
|
1932 c &= 255;
|
|
1933 #endif
|
|
1934 if (c > 127 && c <= 255)
|
|
1935 {
|
|
1936 int meta_flag = 1;
|
|
1937 if (use_console_meta_flag && CONSOLE_TTY_P (con))
|
|
1938 meta_flag = TTY_FLAGS (con).meta_key;
|
|
1939 switch (meta_flag)
|
|
1940 {
|
|
1941 case 0: /* ignore top bit; it's parity */
|
|
1942 c -= 128;
|
|
1943 break;
|
|
1944 case 1: /* top bit is meta */
|
|
1945 c -= 128;
|
442
|
1946 m = XEMACS_MOD_META;
|
428
|
1947 break;
|
|
1948 default: /* this is a real character */
|
|
1949 break;
|
|
1950 }
|
|
1951 }
|
442
|
1952 if (c < ' ') c += '@', m |= XEMACS_MOD_CONTROL;
|
|
1953 if (m & XEMACS_MOD_CONTROL)
|
428
|
1954 {
|
|
1955 switch (c)
|
|
1956 {
|
442
|
1957 case 'I': k = QKtab; m &= ~XEMACS_MOD_CONTROL; break;
|
|
1958 case 'J': k = QKlinefeed; m &= ~XEMACS_MOD_CONTROL; break;
|
|
1959 case 'M': k = QKreturn; m &= ~XEMACS_MOD_CONTROL; break;
|
|
1960 case '[': k = QKescape; m &= ~XEMACS_MOD_CONTROL; break;
|
428
|
1961 default:
|
|
1962 #if defined(HAVE_TTY)
|
|
1963 if (do_backspace_mapping &&
|
|
1964 CHARP (con->tty_erase_char) &&
|
|
1965 c - '@' == XCHAR (con->tty_erase_char))
|
|
1966 {
|
|
1967 k = QKbackspace;
|
442
|
1968 m &= ~XEMACS_MOD_CONTROL;
|
428
|
1969 }
|
442
|
1970 #endif /* defined(HAVE_TTY) && !defined(CYGWIN) */
|
428
|
1971 break;
|
|
1972 }
|
|
1973 if (c >= 'A' && c <= 'Z') c -= 'A'-'a';
|
|
1974 }
|
|
1975 #if defined(HAVE_TTY)
|
|
1976 else if (do_backspace_mapping &&
|
|
1977 CHARP (con->tty_erase_char) && c == XCHAR (con->tty_erase_char))
|
|
1978 k = QKbackspace;
|
442
|
1979 #endif /* defined(HAVE_TTY) && !defined(CYGWIN) */
|
428
|
1980 else if (c == 127)
|
|
1981 k = QKdelete;
|
|
1982 else if (c == ' ')
|
|
1983 k = QKspace;
|
|
1984
|
934
|
1985 #ifdef USE_KKCC
|
|
1986 set_event_type (event, key_press_event);
|
|
1987 SET_EVENT_TIMESTAMP_ZERO (event); /* #### */
|
|
1988 SET_EVENT_CHANNEL (event, wrap_console (con));
|
|
1989 XSET_KEY_DATA_KEYSYM (EVENT_DATA (event), (!NILP (k) ? k : make_char (c)));
|
|
1990 XSET_KEY_DATA_MODIFIERS (EVENT_DATA (event), m);
|
|
1991 #else /* not USE_KKCC */
|
428
|
1992 event->event_type = key_press_event;
|
|
1993 event->timestamp = 0; /* #### */
|
771
|
1994 event->channel = wrap_console (con);
|
428
|
1995 event->event.key.keysym = (!NILP (k) ? k : make_char (c));
|
|
1996 event->event.key.modifiers = m;
|
934
|
1997 #endif /* not USE_KKCC */
|
428
|
1998 }
|
|
1999
|
|
2000 /* This variable controls what character name -> character code mapping
|
|
2001 we are using. Window-system-specific code sets this to some symbol,
|
|
2002 and we use that symbol as the plist key to convert keysyms into 8-bit
|
|
2003 codes. In this way one can have several character sets predefined and
|
|
2004 switch them by changing this.
|
440
|
2005
|
|
2006 #### This is utterly bogus and should be removed.
|
428
|
2007 */
|
|
2008 Lisp_Object Vcharacter_set_property;
|
|
2009
|
867
|
2010 Ichar
|
440
|
2011 event_to_character (Lisp_Event *event,
|
428
|
2012 int allow_extra_modifiers,
|
|
2013 int allow_meta,
|
|
2014 int allow_non_ascii)
|
|
2015 {
|
867
|
2016 Ichar c = 0;
|
428
|
2017 Lisp_Object code;
|
|
2018
|
934
|
2019 #ifdef USE_KKCC
|
|
2020 if (EVENT_TYPE (event) != key_press_event)
|
|
2021 #else /* not USE_KKCC */
|
428
|
2022 if (event->event_type != key_press_event)
|
934
|
2023 #endif /* not USE_KKCC */
|
428
|
2024 {
|
934
|
2025 #ifdef USE_KKCC
|
|
2026 assert (EVENT_TYPE (event) != dead_event);
|
|
2027 #else /* not USE_KKCC */
|
438
|
2028 assert (event->event_type != dead_event);
|
934
|
2029 #endif /* not USE_KKCC */
|
428
|
2030 return -1;
|
|
2031 }
|
|
2032 if (!allow_extra_modifiers &&
|
934
|
2033 #ifdef USE_KKCC
|
|
2034 XKEY_DATA_MODIFIERS (EVENT_DATA (event)) & (XEMACS_MOD_SUPER|XEMACS_MOD_HYPER|XEMACS_MOD_ALT))
|
|
2035 #else /* not USE_KKCC */
|
442
|
2036 event->event.key.modifiers & (XEMACS_MOD_SUPER|XEMACS_MOD_HYPER|XEMACS_MOD_ALT))
|
934
|
2037 #endif /* not USE_KKCC */
|
428
|
2038 return -1;
|
934
|
2039 #ifdef USE_KKCC
|
|
2040 if (CHAR_OR_CHAR_INTP (XKEY_DATA_KEYSYM (EVENT_DATA (event))))
|
|
2041 c = XCHAR_OR_CHAR_INT (XKEY_DATA_KEYSYM (EVENT_DATA (event)));
|
|
2042 else if (!SYMBOLP (XKEY_DATA_KEYSYM (EVENT_DATA (event))))
|
|
2043 #else /* not USE_KKCC */
|
428
|
2044 if (CHAR_OR_CHAR_INTP (event->event.key.keysym))
|
|
2045 c = XCHAR_OR_CHAR_INT (event->event.key.keysym);
|
|
2046 else if (!SYMBOLP (event->event.key.keysym))
|
934
|
2047 #endif /* not USE_KKCC */
|
428
|
2048 abort ();
|
|
2049 else if (allow_non_ascii && !NILP (Vcharacter_set_property)
|
|
2050 /* Allow window-system-specific extensibility of
|
|
2051 keysym->code mapping */
|
934
|
2052 #ifdef USE_KKCC
|
|
2053 && CHAR_OR_CHAR_INTP (code = Fget (XKEY_DATA_KEYSYM (EVENT_DATA (event)),
|
|
2054 Vcharacter_set_property,
|
|
2055 Qnil)))
|
|
2056 #else /* not USE_KKCC */
|
428
|
2057 && CHAR_OR_CHAR_INTP (code = Fget (event->event.key.keysym,
|
|
2058 Vcharacter_set_property,
|
|
2059 Qnil)))
|
934
|
2060 #endif /* not USE_KKCC */
|
428
|
2061 c = XCHAR_OR_CHAR_INT (code);
|
934
|
2062 #ifdef USE_KKCC
|
|
2063 else if (CHAR_OR_CHAR_INTP (code = Fget (XKEY_DATA_KEYSYM (EVENT_DATA (event)),
|
|
2064 Qascii_character, Qnil)))
|
|
2065 #else /* not USE_KKCC */
|
428
|
2066 else if (CHAR_OR_CHAR_INTP (code = Fget (event->event.key.keysym,
|
|
2067 Qascii_character, Qnil)))
|
934
|
2068 #endif /* not USE_KKCC */
|
428
|
2069 c = XCHAR_OR_CHAR_INT (code);
|
|
2070 else
|
|
2071 return -1;
|
|
2072
|
934
|
2073 #ifdef USE_KKCC
|
|
2074 if (XKEY_DATA_MODIFIERS (EVENT_DATA (event)) & XEMACS_MOD_CONTROL)
|
|
2075 #else /* not USE_KKCC */
|
442
|
2076 if (event->event.key.modifiers & XEMACS_MOD_CONTROL)
|
934
|
2077 #endif /* not USE_KKCC */
|
428
|
2078 {
|
|
2079 if (c >= 'a' && c <= 'z')
|
|
2080 c -= ('a' - 'A');
|
|
2081 else
|
|
2082 /* reject Control-Shift- keys */
|
|
2083 if (c >= 'A' && c <= 'Z' && !allow_extra_modifiers)
|
|
2084 return -1;
|
|
2085
|
|
2086 if (c >= '@' && c <= '_')
|
|
2087 c -= '@';
|
|
2088 else if (c == ' ') /* C-space and C-@ are the same. */
|
|
2089 c = 0;
|
|
2090 else
|
|
2091 /* reject keys that can't take Control- modifiers */
|
|
2092 if (! allow_extra_modifiers) return -1;
|
|
2093 }
|
|
2094
|
934
|
2095 #ifdef USE_KKCC
|
|
2096 if (XKEY_DATA_MODIFIERS (EVENT_DATA (event)) & XEMACS_MOD_META)
|
|
2097 #else /* not USE_KKCC */
|
442
|
2098 if (event->event.key.modifiers & XEMACS_MOD_META)
|
934
|
2099 #endif /* not USE_KKCC */
|
428
|
2100 {
|
|
2101 if (! allow_meta) return -1;
|
|
2102 if (c & 0200) return -1; /* don't allow M-oslash (overlap) */
|
|
2103 #ifdef MULE
|
|
2104 if (c >= 256) return -1;
|
|
2105 #endif
|
|
2106 c |= 0200;
|
|
2107 }
|
|
2108 return c;
|
|
2109 }
|
|
2110
|
|
2111 DEFUN ("event-to-character", Fevent_to_character, 1, 4, 0, /*
|
|
2112 Return the closest ASCII approximation to the given event object.
|
|
2113 If the event isn't a keypress, this returns nil.
|
|
2114 If the ALLOW-EXTRA-MODIFIERS argument is non-nil, then this is lenient in
|
|
2115 its translation; it will ignore modifier keys other than control and meta,
|
|
2116 and will ignore the shift modifier on those characters which have no
|
|
2117 shifted ASCII equivalent (Control-Shift-A for example, will be mapped to
|
|
2118 the same ASCII code as Control-A).
|
|
2119 If the ALLOW-META argument is non-nil, then the Meta modifier will be
|
|
2120 represented by turning on the high bit of the byte returned; otherwise, nil
|
|
2121 will be returned for events containing the Meta modifier.
|
|
2122 If the ALLOW-NON-ASCII argument is non-nil, then characters which are
|
|
2123 present in the prevailing character set (see the `character-set-property'
|
|
2124 variable) will be returned as their code in that character set, instead of
|
|
2125 the return value being restricted to ASCII.
|
|
2126 Note that specifying both ALLOW-META and ALLOW-NON-ASCII is ambiguous, as
|
|
2127 both use the high bit; `M-x' and `oslash' will be indistinguishable.
|
|
2128 */
|
|
2129 (event, allow_extra_modifiers, allow_meta, allow_non_ascii))
|
|
2130 {
|
867
|
2131 Ichar c;
|
428
|
2132 CHECK_LIVE_EVENT (event);
|
|
2133 c = event_to_character (XEVENT (event),
|
|
2134 !NILP (allow_extra_modifiers),
|
|
2135 !NILP (allow_meta),
|
|
2136 !NILP (allow_non_ascii));
|
|
2137 return c < 0 ? Qnil : make_char (c);
|
|
2138 }
|
|
2139
|
|
2140 DEFUN ("character-to-event", Fcharacter_to_event, 1, 4, 0, /*
|
444
|
2141 Convert KEY-DESCRIPTION into an event structure, replete with bucky bits.
|
428
|
2142
|
444
|
2143 KEY-DESCRIPTION is the first argument, and the event to fill in is the
|
|
2144 second. This function contains knowledge about what various kinds of
|
|
2145 arguments ``mean'' -- for example, the number 9 is converted to the
|
|
2146 character ``Tab'', not the distinct character ``Control-I''.
|
428
|
2147
|
444
|
2148 KEY-DESCRIPTION can be an integer, a character, a symbol such as 'clear,
|
|
2149 or a list such as '(control backspace).
|
|
2150
|
|
2151 If the optional second argument EVENT is an event, it is modified and
|
|
2152 returned; otherwise, a new event object is created and returned.
|
428
|
2153
|
|
2154 Optional third arg CONSOLE is the console to store in the event, and
|
|
2155 defaults to the selected console.
|
|
2156
|
444
|
2157 If KEY-DESCRIPTION is an integer or character, the high bit may be
|
|
2158 interpreted as the meta key. (This is done for backward compatibility
|
|
2159 in lots of places.) If USE-CONSOLE-META-FLAG is nil, this will always
|
|
2160 be the case. If USE-CONSOLE-META-FLAG is non-nil, the `meta' flag for
|
|
2161 CONSOLE affects whether the high bit is interpreted as a meta
|
|
2162 key. (See `set-input-mode'.) If you don't want this silly meta
|
|
2163 interpretation done, you should pass in a list containing the
|
|
2164 character.
|
428
|
2165
|
|
2166 Beware that character-to-event and event-to-character are not strictly
|
|
2167 inverse functions, since events contain much more information than the
|
444
|
2168 Lisp character object type can encode.
|
428
|
2169 */
|
444
|
2170 (keystroke, event, console, use_console_meta_flag))
|
428
|
2171 {
|
|
2172 struct console *con = decode_console (console);
|
|
2173 if (NILP (event))
|
|
2174 event = Fmake_event (Qnil, Qnil);
|
|
2175 else
|
|
2176 CHECK_LIVE_EVENT (event);
|
444
|
2177 if (CONSP (keystroke) || SYMBOLP (keystroke))
|
|
2178 key_desc_list_to_event (keystroke, event, 1);
|
428
|
2179 else
|
|
2180 {
|
444
|
2181 CHECK_CHAR_COERCE_INT (keystroke);
|
|
2182 character_to_event (XCHAR (keystroke), XEVENT (event), con,
|
428
|
2183 !NILP (use_console_meta_flag), 1);
|
|
2184 }
|
|
2185 return event;
|
|
2186 }
|
|
2187
|
|
2188 void
|
|
2189 nth_of_key_sequence_as_event (Lisp_Object seq, int n, Lisp_Object event)
|
|
2190 {
|
|
2191 assert (STRINGP (seq) || VECTORP (seq));
|
|
2192 assert (n < XINT (Flength (seq)));
|
|
2193
|
|
2194 if (STRINGP (seq))
|
|
2195 {
|
867
|
2196 Ichar ch = string_ichar (seq, n);
|
428
|
2197 Fcharacter_to_event (make_char (ch), event, Qnil, Qnil);
|
|
2198 }
|
|
2199 else
|
|
2200 {
|
|
2201 Lisp_Object keystroke = XVECTOR_DATA (seq)[n];
|
|
2202 if (EVENTP (keystroke))
|
|
2203 Fcopy_event (keystroke, event);
|
|
2204 else
|
|
2205 Fcharacter_to_event (keystroke, event, Qnil, Qnil);
|
|
2206 }
|
|
2207 }
|
|
2208
|
|
2209 Lisp_Object
|
|
2210 key_sequence_to_event_chain (Lisp_Object seq)
|
|
2211 {
|
|
2212 int len = XINT (Flength (seq));
|
|
2213 int i;
|
|
2214 Lisp_Object head = Qnil, tail = Qnil;
|
|
2215
|
|
2216 for (i = 0; i < len; i++)
|
|
2217 {
|
|
2218 Lisp_Object event = Fmake_event (Qnil, Qnil);
|
|
2219 nth_of_key_sequence_as_event (seq, i, event);
|
|
2220 enqueue_event (event, &head, &tail);
|
|
2221 }
|
|
2222
|
|
2223 return head;
|
|
2224 }
|
|
2225
|
934
|
2226
|
793
|
2227 /* Concatenate a string description of EVENT onto the end of BUF. If
|
|
2228 BRIEF, use short forms for keys, e.g. C- instead of control-. */
|
|
2229
|
934
|
2230 #ifdef USE_KKCC
|
|
2231 void
|
|
2232 format_event_object (Eistring *buf, Lisp_Object event, int brief)
|
|
2233 #else /* not USE_KKCC */
|
428
|
2234 void
|
793
|
2235 format_event_object (Eistring *buf, Lisp_Event *event, int brief)
|
934
|
2236 #endif /* not USE_KKCC */
|
428
|
2237 {
|
|
2238 int mouse_p = 0;
|
|
2239 int mod = 0;
|
|
2240 Lisp_Object key;
|
|
2241
|
934
|
2242 #ifdef USE_KKCC
|
|
2243 switch (EVENT_TYPE (XEVENT(event)))
|
|
2244 #else /* not USE_KKCC */
|
428
|
2245 switch (event->event_type)
|
934
|
2246 #endif /* not USE_KKCC */
|
428
|
2247 {
|
|
2248 case key_press_event:
|
|
2249 {
|
934
|
2250 #ifdef USE_KKCC
|
|
2251 mod = XKEY_DATA_MODIFIERS (XEVENT_DATA(event));
|
|
2252 key = XKEY_DATA_KEYSYM (XEVENT_DATA(event));
|
|
2253 #else /* not USE_KKCC */
|
428
|
2254 mod = event->event.key.modifiers;
|
|
2255 key = event->event.key.keysym;
|
934
|
2256 #endif /* not USE_KKCC */
|
428
|
2257 /* Hack. */
|
|
2258 if (! brief && CHARP (key) &&
|
793
|
2259 mod & (XEMACS_MOD_CONTROL | XEMACS_MOD_META | XEMACS_MOD_SUPER |
|
|
2260 XEMACS_MOD_HYPER))
|
428
|
2261 {
|
|
2262 int k = XCHAR (key);
|
|
2263 if (k >= 'a' && k <= 'z')
|
|
2264 key = make_char (k - ('a' - 'A'));
|
|
2265 else if (k >= 'A' && k <= 'Z')
|
442
|
2266 mod |= XEMACS_MOD_SHIFT;
|
428
|
2267 }
|
|
2268 break;
|
|
2269 }
|
|
2270 case button_release_event:
|
|
2271 mouse_p++;
|
|
2272 /* Fall through */
|
|
2273 case button_press_event:
|
|
2274 {
|
|
2275 mouse_p++;
|
934
|
2276 #ifdef USE_KKCC
|
|
2277 mod = XBUTTON_DATA_MODIFIERS (XEVENT_DATA(event));
|
|
2278 key = make_char (XBUTTON_DATA_BUTTON (XEVENT_DATA(event)) + '0');
|
|
2279 #else /* not USE_KKCC */
|
428
|
2280 mod = event->event.button.modifiers;
|
|
2281 key = make_char (event->event.button.button + '0');
|
934
|
2282 #endif /* not USE_KKCC */
|
428
|
2283 break;
|
|
2284 }
|
|
2285 case magic_event:
|
|
2286 {
|
788
|
2287 Lisp_Object stream;
|
|
2288 struct gcpro gcpro1;
|
|
2289 GCPRO1 (stream);
|
428
|
2290
|
788
|
2291 stream = make_resizing_buffer_output_stream ();
|
934
|
2292 #ifdef USE_KKCC
|
|
2293 event_stream_format_magic_event (XEVENT(event), stream);
|
|
2294 #else /* not USE_KKCC */
|
788
|
2295 event_stream_format_magic_event (event, stream);
|
934
|
2296 #endif /* not USE_KKCC */
|
788
|
2297 Lstream_flush (XLSTREAM (stream));
|
793
|
2298 eicat_raw (buf, resizing_buffer_stream_ptr (XLSTREAM (stream)),
|
|
2299 Lstream_byte_count (XLSTREAM (stream)));
|
788
|
2300 Lstream_delete (XLSTREAM (stream));
|
|
2301 UNGCPRO;
|
428
|
2302 return;
|
|
2303 }
|
793
|
2304 case magic_eval_event: eicat_c (buf, "magic-eval"); return;
|
|
2305 case pointer_motion_event: eicat_c (buf, "motion"); return;
|
|
2306 case misc_user_event: eicat_c (buf, "misc-user"); return;
|
|
2307 case eval_event: eicat_c (buf, "eval"); return;
|
|
2308 case process_event: eicat_c (buf, "process"); return;
|
|
2309 case timeout_event: eicat_c (buf, "timeout"); return;
|
|
2310 case empty_event: eicat_c (buf, "empty"); return;
|
|
2311 case dead_event: eicat_c (buf, "DEAD-EVENT"); return;
|
428
|
2312 default:
|
|
2313 abort ();
|
442
|
2314 return;
|
428
|
2315 }
|
793
|
2316 #define modprint(x,y) \
|
|
2317 do { if (brief) eicat_c (buf, (y)); else eicat_c (buf, (x)); } while (0)
|
442
|
2318 if (mod & XEMACS_MOD_CONTROL) modprint ("control-", "C-");
|
|
2319 if (mod & XEMACS_MOD_META) modprint ("meta-", "M-");
|
|
2320 if (mod & XEMACS_MOD_SUPER) modprint ("super-", "S-");
|
|
2321 if (mod & XEMACS_MOD_HYPER) modprint ("hyper-", "H-");
|
|
2322 if (mod & XEMACS_MOD_ALT) modprint ("alt-", "A-");
|
|
2323 if (mod & XEMACS_MOD_SHIFT) modprint ("shift-", "Sh-");
|
428
|
2324 if (mouse_p)
|
|
2325 {
|
793
|
2326 eicat_c (buf, "button");
|
428
|
2327 --mouse_p;
|
|
2328 }
|
|
2329
|
|
2330 #undef modprint
|
|
2331
|
|
2332 if (CHARP (key))
|
793
|
2333 eicat_ch (buf, XCHAR (key));
|
428
|
2334 else if (SYMBOLP (key))
|
|
2335 {
|
793
|
2336 const Char_ASCII *str = 0;
|
428
|
2337 if (brief)
|
|
2338 {
|
|
2339 if (EQ (key, QKlinefeed)) str = "LFD";
|
|
2340 else if (EQ (key, QKtab)) str = "TAB";
|
|
2341 else if (EQ (key, QKreturn)) str = "RET";
|
|
2342 else if (EQ (key, QKescape)) str = "ESC";
|
|
2343 else if (EQ (key, QKdelete)) str = "DEL";
|
|
2344 else if (EQ (key, QKspace)) str = "SPC";
|
|
2345 else if (EQ (key, QKbackspace)) str = "BS";
|
|
2346 }
|
|
2347 if (str)
|
793
|
2348 eicat_c (buf, str);
|
428
|
2349 else
|
793
|
2350 eicat_lstr (buf, XSYMBOL (key)->name);
|
428
|
2351 }
|
|
2352 else
|
|
2353 abort ();
|
|
2354 if (mouse_p)
|
793
|
2355 eicat_c (buf, "up");
|
428
|
2356 }
|
|
2357
|
934
|
2358
|
428
|
2359 DEFUN ("eventp", Feventp, 1, 1, 0, /*
|
|
2360 True if OBJECT is an event object.
|
|
2361 */
|
|
2362 (object))
|
|
2363 {
|
|
2364 return EVENTP (object) ? Qt : Qnil;
|
|
2365 }
|
|
2366
|
|
2367 DEFUN ("event-live-p", Fevent_live_p, 1, 1, 0, /*
|
|
2368 True if OBJECT is an event object that has not been deallocated.
|
|
2369 */
|
|
2370 (object))
|
|
2371 {
|
934
|
2372 #ifdef USE_KKCC
|
|
2373 return EVENTP (object) && XEVENT_TYPE (object) != dead_event ?
|
|
2374 Qt : Qnil;
|
|
2375 #else /* not USE_KKCC */
|
428
|
2376 return EVENTP (object) && XEVENT (object)->event_type != dead_event ?
|
|
2377 Qt : Qnil;
|
934
|
2378 #endif /* not USE_KKCC */
|
428
|
2379 }
|
|
2380
|
|
2381 #if 0 /* debugging functions */
|
|
2382
|
826
|
2383 DEFUN ("event-next", Fevent_next, 1, 1, 0, /*
|
428
|
2384 Return the event object's `next' event, or nil if it has none.
|
|
2385 The `next-event' field is changed by calling `set-next-event'.
|
|
2386 */
|
|
2387 (event))
|
|
2388 {
|
440
|
2389 Lisp_Event *e;
|
428
|
2390 CHECK_LIVE_EVENT (event);
|
|
2391
|
|
2392 return XEVENT_NEXT (event);
|
|
2393 }
|
|
2394
|
826
|
2395 DEFUN ("set-event-next", Fset_event_next, 2, 2, 0, /*
|
428
|
2396 Set the `next event' of EVENT to NEXT-EVENT.
|
|
2397 NEXT-EVENT must be an event object or nil.
|
|
2398 */
|
|
2399 (event, next_event))
|
|
2400 {
|
|
2401 Lisp_Object ev;
|
|
2402
|
|
2403 CHECK_LIVE_EVENT (event);
|
|
2404 if (NILP (next_event))
|
|
2405 {
|
|
2406 XSET_EVENT_NEXT (event, Qnil);
|
|
2407 return Qnil;
|
|
2408 }
|
|
2409
|
|
2410 CHECK_LIVE_EVENT (next_event);
|
|
2411
|
|
2412 EVENT_CHAIN_LOOP (ev, XEVENT_NEXT (event))
|
|
2413 {
|
|
2414 QUIT;
|
|
2415 if (EQ (ev, event))
|
563
|
2416 invalid_operation_2 ("Cyclic event-next", event, next_event);
|
428
|
2417 }
|
|
2418 XSET_EVENT_NEXT (event, next_event);
|
|
2419 return next_event;
|
|
2420 }
|
|
2421
|
|
2422 #endif /* 0 */
|
|
2423
|
|
2424 DEFUN ("event-type", Fevent_type, 1, 1, 0, /*
|
|
2425 Return the type of EVENT.
|
|
2426 This will be a symbol; one of
|
|
2427
|
|
2428 key-press A key was pressed.
|
|
2429 button-press A mouse button was pressed.
|
|
2430 button-release A mouse button was released.
|
|
2431 misc-user Some other user action happened; typically, this is
|
|
2432 a menu selection or scrollbar action.
|
|
2433 motion The mouse moved.
|
|
2434 process Input is available from a subprocess.
|
|
2435 timeout A timeout has expired.
|
|
2436 eval This causes a specified action to occur when dispatched.
|
|
2437 magic Some window-system-specific event has occurred.
|
|
2438 empty The event has been allocated but not assigned.
|
|
2439
|
|
2440 */
|
|
2441 (event))
|
|
2442 {
|
|
2443 CHECK_LIVE_EVENT (event);
|
934
|
2444 #ifdef USE_KKCC
|
|
2445 switch (XEVENT_TYPE (event))
|
|
2446 #else /* not USE_KKCC */
|
428
|
2447 switch (XEVENT (event)->event_type)
|
934
|
2448 #endif /* not USE_KKCC */
|
428
|
2449 {
|
|
2450 case key_press_event: return Qkey_press;
|
|
2451 case button_press_event: return Qbutton_press;
|
|
2452 case button_release_event: return Qbutton_release;
|
|
2453 case misc_user_event: return Qmisc_user;
|
|
2454 case pointer_motion_event: return Qmotion;
|
|
2455 case process_event: return Qprocess;
|
|
2456 case timeout_event: return Qtimeout;
|
|
2457 case eval_event: return Qeval;
|
|
2458 case magic_event:
|
|
2459 case magic_eval_event:
|
|
2460 return Qmagic;
|
|
2461
|
|
2462 case empty_event:
|
|
2463 return Qempty;
|
|
2464
|
|
2465 default:
|
|
2466 abort ();
|
|
2467 return Qnil;
|
|
2468 }
|
|
2469 }
|
|
2470
|
|
2471 DEFUN ("event-timestamp", Fevent_timestamp, 1, 1, 0, /*
|
|
2472 Return the timestamp of the event object EVENT.
|
442
|
2473 Timestamps are measured in milliseconds since the start of the window system.
|
|
2474 They are NOT related to any current time measurement.
|
|
2475 They should be compared with `event-timestamp<'.
|
|
2476 See also `current-event-timestamp'.
|
428
|
2477 */
|
|
2478 (event))
|
|
2479 {
|
|
2480 CHECK_LIVE_EVENT (event);
|
|
2481 /* This junk is so that timestamps don't get to be negative, but contain
|
|
2482 as many bits as this particular emacs will allow.
|
|
2483 */
|
934
|
2484 #ifdef USE_KKCC
|
|
2485 return make_int (((1L << (VALBITS - 1)) - 1) &
|
|
2486 XEVENT_TIMESTAMP (event));
|
|
2487 #else /* not USE_KKCC */
|
428
|
2488 return make_int (((1L << (VALBITS - 1)) - 1) &
|
|
2489 XEVENT (event)->timestamp);
|
934
|
2490 #endif /* not USE_KKCC */
|
428
|
2491 }
|
|
2492
|
442
|
2493 #define TIMESTAMP_HALFSPACE (1L << (VALBITS - 2))
|
|
2494
|
|
2495 DEFUN ("event-timestamp<", Fevent_timestamp_lessp, 2, 2, 0, /*
|
|
2496 Return true if timestamp TIME1 is earlier than timestamp TIME2.
|
|
2497 This correctly handles timestamp wrap.
|
|
2498 See also `event-timestamp' and `current-event-timestamp'.
|
|
2499 */
|
|
2500 (time1, time2))
|
|
2501 {
|
|
2502 EMACS_INT t1, t2;
|
|
2503
|
|
2504 CHECK_NATNUM (time1);
|
|
2505 CHECK_NATNUM (time2);
|
|
2506 t1 = XINT (time1);
|
|
2507 t2 = XINT (time2);
|
|
2508
|
|
2509 if (t1 < t2)
|
|
2510 return t2 - t1 < TIMESTAMP_HALFSPACE ? Qt : Qnil;
|
|
2511 else
|
|
2512 return t1 - t2 < TIMESTAMP_HALFSPACE ? Qnil : Qt;
|
|
2513 }
|
|
2514
|
934
|
2515 #ifdef USE_KKCC
|
|
2516 #define CHECK_EVENT_TYPE(e,t1,sym) do { \
|
|
2517 CHECK_LIVE_EVENT (e); \
|
|
2518 if (XEVENT_TYPE (e) != (t1)) \
|
|
2519 e = wrong_type_argument (sym,e); \
|
|
2520 } while (0)
|
|
2521 #else /* not USE_KKCC */
|
428
|
2522 #define CHECK_EVENT_TYPE(e,t1,sym) do { \
|
|
2523 CHECK_LIVE_EVENT (e); \
|
|
2524 if (XEVENT(e)->event_type != (t1)) \
|
|
2525 e = wrong_type_argument (sym,e); \
|
|
2526 } while (0)
|
934
|
2527 #endif /* not USE_KKCC */
|
|
2528
|
|
2529 #ifdef USE_KKCC
|
|
2530 #define CHECK_EVENT_TYPE2(e,t1,t2,sym) do { \
|
|
2531 CHECK_LIVE_EVENT (e); \
|
|
2532 { \
|
|
2533 emacs_event_type CET_type = XEVENT_TYPE (e); \
|
|
2534 if (CET_type != (t1) && \
|
|
2535 CET_type != (t2)) \
|
|
2536 e = wrong_type_argument (sym,e); \
|
|
2537 } \
|
|
2538 } while (0)
|
|
2539 #else /* not USE_KKCC */
|
428
|
2540 #define CHECK_EVENT_TYPE2(e,t1,t2,sym) do { \
|
|
2541 CHECK_LIVE_EVENT (e); \
|
|
2542 { \
|
|
2543 emacs_event_type CET_type = XEVENT (e)->event_type; \
|
|
2544 if (CET_type != (t1) && \
|
|
2545 CET_type != (t2)) \
|
|
2546 e = wrong_type_argument (sym,e); \
|
|
2547 } \
|
|
2548 } while (0)
|
934
|
2549 #endif /* not USE_KKCC */
|
|
2550
|
|
2551 #ifdef USE_KKCC
|
|
2552 #define CHECK_EVENT_TYPE3(e,t1,t2,t3,sym) do { \
|
|
2553 CHECK_LIVE_EVENT (e); \
|
|
2554 { \
|
|
2555 emacs_event_type CET_type = XEVENT_TYPE (e); \
|
|
2556 if (CET_type != (t1) && \
|
|
2557 CET_type != (t2) && \
|
|
2558 CET_type != (t3)) \
|
|
2559 e = wrong_type_argument (sym,e); \
|
|
2560 } \
|
|
2561 } while (0)
|
|
2562 #else /* not USE_KKCC */
|
428
|
2563 #define CHECK_EVENT_TYPE3(e,t1,t2,t3,sym) do { \
|
|
2564 CHECK_LIVE_EVENT (e); \
|
|
2565 { \
|
|
2566 emacs_event_type CET_type = XEVENT (e)->event_type; \
|
|
2567 if (CET_type != (t1) && \
|
|
2568 CET_type != (t2) && \
|
|
2569 CET_type != (t3)) \
|
|
2570 e = wrong_type_argument (sym,e); \
|
|
2571 } \
|
|
2572 } while (0)
|
934
|
2573 #endif /* not USE_KKCC */
|
428
|
2574
|
|
2575 DEFUN ("event-key", Fevent_key, 1, 1, 0, /*
|
|
2576 Return the Keysym of the key-press event EVENT.
|
|
2577 This will be a character if the event is associated with one, else a symbol.
|
|
2578 */
|
|
2579 (event))
|
|
2580 {
|
|
2581 CHECK_EVENT_TYPE (event, key_press_event, Qkey_press_event_p);
|
934
|
2582 #ifdef USE_KKCC
|
|
2583 return XKEY_DATA_KEYSYM (XEVENT_DATA (event));
|
|
2584 #else /* not USE_KKCC */
|
428
|
2585 return XEVENT (event)->event.key.keysym;
|
934
|
2586 #endif /* not USE_KKCC */
|
428
|
2587 }
|
|
2588
|
|
2589 DEFUN ("event-button", Fevent_button, 1, 1, 0, /*
|
444
|
2590 Return the button-number of the button-press or button-release event EVENT.
|
428
|
2591 */
|
|
2592 (event))
|
|
2593 {
|
|
2594
|
|
2595 CHECK_EVENT_TYPE3 (event, button_press_event, button_release_event,
|
|
2596 misc_user_event, Qbutton_event_p);
|
|
2597 #ifdef HAVE_WINDOW_SYSTEM
|
934
|
2598 #ifdef USE_KKCC
|
|
2599 if ( XEVENT_TYPE (event) == misc_user_event)
|
|
2600 return make_int (XMISC_USER_DATA_BUTTON (XEVENT_DATA (event)));
|
|
2601 else
|
|
2602 return make_int (XBUTTON_DATA_BUTTON (XEVENT_DATA (event)));
|
|
2603 #else /* not USE_KKCC */
|
428
|
2604 if ( XEVENT (event)->event_type == misc_user_event)
|
|
2605 return make_int (XEVENT (event)->event.misc.button);
|
|
2606 else
|
|
2607 return make_int (XEVENT (event)->event.button.button);
|
934
|
2608 #endif /* not USE_KKCC */
|
428
|
2609 #else /* !HAVE_WINDOW_SYSTEM */
|
|
2610 return Qzero;
|
|
2611 #endif /* !HAVE_WINDOW_SYSTEM */
|
|
2612
|
|
2613 }
|
|
2614
|
|
2615 DEFUN ("event-modifier-bits", Fevent_modifier_bits, 1, 1, 0, /*
|
442
|
2616 Return a number representing the modifier keys and buttons which were down
|
428
|
2617 when the given mouse or keyboard event was produced.
|
442
|
2618 See also the function `event-modifiers'.
|
428
|
2619 */
|
|
2620 (event))
|
|
2621 {
|
|
2622 again:
|
|
2623 CHECK_LIVE_EVENT (event);
|
934
|
2624 #ifdef USE_KKCC
|
|
2625 switch (XEVENT_TYPE (event))
|
|
2626 {
|
|
2627 case key_press_event:
|
|
2628 return make_int (XKEY_DATA_MODIFIERS (XEVENT_DATA (event)));
|
|
2629 case button_press_event:
|
|
2630 case button_release_event:
|
|
2631 return make_int (XBUTTON_DATA_MODIFIERS (XEVENT_DATA (event)));
|
|
2632 case pointer_motion_event:
|
|
2633 return make_int (XMOTION_DATA_MODIFIERS (XEVENT_DATA (event)));
|
|
2634 case misc_user_event:
|
|
2635 return make_int (XMISC_USER_DATA_MODIFIERS (XEVENT_DATA (event)));
|
|
2636 default:
|
|
2637 event = wrong_type_argument (intern ("key-or-mouse-event-p"), event);
|
|
2638 goto again;
|
|
2639 }
|
|
2640 #else /* not USE_KKCC */
|
428
|
2641 switch (XEVENT (event)->event_type)
|
|
2642 {
|
|
2643 case key_press_event:
|
|
2644 return make_int (XEVENT (event)->event.key.modifiers);
|
|
2645 case button_press_event:
|
|
2646 case button_release_event:
|
|
2647 return make_int (XEVENT (event)->event.button.modifiers);
|
|
2648 case pointer_motion_event:
|
|
2649 return make_int (XEVENT (event)->event.motion.modifiers);
|
|
2650 case misc_user_event:
|
|
2651 return make_int (XEVENT (event)->event.misc.modifiers);
|
|
2652 default:
|
|
2653 event = wrong_type_argument (intern ("key-or-mouse-event-p"), event);
|
|
2654 goto again;
|
|
2655 }
|
934
|
2656 #endif /* not USE_KKCC */
|
428
|
2657 }
|
|
2658
|
|
2659 DEFUN ("event-modifiers", Fevent_modifiers, 1, 1, 0, /*
|
442
|
2660 Return a list of symbols, the names of the modifier keys and buttons
|
428
|
2661 which were down when the given mouse or keyboard event was produced.
|
442
|
2662 See also the function `event-modifier-bits'.
|
|
2663
|
|
2664 The possible symbols in the list are
|
|
2665
|
|
2666 `shift': The Shift key. Will not appear, in general, on key events
|
|
2667 where the keysym is an ASCII character, because using Shift
|
|
2668 on such a character converts it into another character rather
|
|
2669 than actually just adding a Shift modifier.
|
|
2670
|
|
2671 `control': The Control key.
|
|
2672
|
|
2673 `meta': The Meta key. On PC's and PC-style keyboards, this is generally
|
|
2674 labelled \"Alt\"; Meta is a holdover from early Lisp Machines and
|
|
2675 such, propagated through the X Window System. On Sun keyboards,
|
|
2676 this key is labelled with a diamond.
|
|
2677
|
|
2678 `alt': The \"Alt\" key. Alt is in quotes because this does not refer
|
|
2679 to what it obviously should refer to, namely the Alt key on PC
|
|
2680 keyboards. Instead, it refers to the key labelled Alt on Sun
|
|
2681 keyboards, and to no key at all on PC keyboards.
|
|
2682
|
|
2683 `super': The Super key. Most keyboards don't have any such key, but
|
|
2684 under X Windows using `xmodmap' you can assign any key (such as
|
|
2685 an underused right-shift, right-control, or right-alt key) to
|
|
2686 this key modifier. No support currently exists under MS Windows
|
|
2687 for generating these modifiers.
|
|
2688
|
|
2689 `hyper': The Hyper key. Works just like the Super key.
|
|
2690
|
|
2691 `button1': The mouse buttons. This means that the specified button was held
|
|
2692 `button2': down at the time the event occurred. NOTE: For button-press
|
|
2693 `button3': events, the button that was just pressed down does NOT appear in
|
|
2694 `button4': the modifiers.
|
|
2695 `button5':
|
|
2696
|
|
2697 Button modifiers are currently ignored when defining and looking up key and
|
|
2698 mouse strokes in keymaps. This could be changed, which would allow a user to
|
|
2699 create button-chord actions, use a button as a key modifier and do other
|
|
2700 clever things.
|
428
|
2701 */
|
|
2702 (event))
|
|
2703 {
|
|
2704 int mod = XINT (Fevent_modifier_bits (event));
|
|
2705 Lisp_Object result = Qnil;
|
442
|
2706 struct gcpro gcpro1;
|
|
2707
|
|
2708 GCPRO1 (result);
|
|
2709 if (mod & XEMACS_MOD_SHIFT) result = Fcons (Qshift, result);
|
|
2710 if (mod & XEMACS_MOD_ALT) result = Fcons (Qalt, result);
|
|
2711 if (mod & XEMACS_MOD_HYPER) result = Fcons (Qhyper, result);
|
|
2712 if (mod & XEMACS_MOD_SUPER) result = Fcons (Qsuper, result);
|
|
2713 if (mod & XEMACS_MOD_META) result = Fcons (Qmeta, result);
|
|
2714 if (mod & XEMACS_MOD_CONTROL) result = Fcons (Qcontrol, result);
|
|
2715 if (mod & XEMACS_MOD_BUTTON1) result = Fcons (Qbutton1, result);
|
|
2716 if (mod & XEMACS_MOD_BUTTON2) result = Fcons (Qbutton2, result);
|
|
2717 if (mod & XEMACS_MOD_BUTTON3) result = Fcons (Qbutton3, result);
|
|
2718 if (mod & XEMACS_MOD_BUTTON4) result = Fcons (Qbutton4, result);
|
|
2719 if (mod & XEMACS_MOD_BUTTON5) result = Fcons (Qbutton5, result);
|
|
2720 RETURN_UNGCPRO (Fnreverse (result));
|
428
|
2721 }
|
|
2722
|
|
2723 static int
|
|
2724 event_x_y_pixel_internal (Lisp_Object event, int *x, int *y, int relative)
|
|
2725 {
|
|
2726 struct window *w;
|
|
2727 struct frame *f;
|
|
2728
|
934
|
2729 #ifdef USE_KKCC
|
|
2730 if (XEVENT_TYPE (event) == pointer_motion_event)
|
|
2731 {
|
|
2732 *x = XMOTION_DATA_X (XEVENT_DATA (event));
|
|
2733 *y = XMOTION_DATA_Y (XEVENT_DATA (event));
|
|
2734 }
|
|
2735 else if (XEVENT_TYPE (event) == button_press_event ||
|
|
2736 XEVENT_TYPE (event) == button_release_event)
|
|
2737 {
|
|
2738 *x = XBUTTON_DATA_X (XEVENT_DATA (event));
|
|
2739 *y = XBUTTON_DATA_Y (XEVENT_DATA (event));
|
|
2740 }
|
|
2741 else if (XEVENT_TYPE (event) == misc_user_event)
|
|
2742 {
|
|
2743 *x = XMISC_USER_DATA_X (XEVENT_DATA (event));
|
|
2744 *y = XMISC_USER_DATA_Y (XEVENT_DATA (event));
|
|
2745 }
|
|
2746 else
|
|
2747 return 0;
|
|
2748 #else /* not USE_KKCC */
|
428
|
2749 if (XEVENT (event)->event_type == pointer_motion_event)
|
|
2750 {
|
|
2751 *x = XEVENT (event)->event.motion.x;
|
|
2752 *y = XEVENT (event)->event.motion.y;
|
|
2753 }
|
|
2754 else if (XEVENT (event)->event_type == button_press_event ||
|
|
2755 XEVENT (event)->event_type == button_release_event)
|
|
2756 {
|
|
2757 *x = XEVENT (event)->event.button.x;
|
|
2758 *y = XEVENT (event)->event.button.y;
|
|
2759 }
|
|
2760 else if (XEVENT (event)->event_type == misc_user_event)
|
|
2761 {
|
|
2762 *x = XEVENT (event)->event.misc.x;
|
|
2763 *y = XEVENT (event)->event.misc.y;
|
|
2764 }
|
|
2765 else
|
|
2766 return 0;
|
934
|
2767 #endif /* not USE_KKCC */
|
428
|
2768 f = XFRAME (EVENT_CHANNEL (XEVENT (event)));
|
|
2769
|
|
2770 if (relative)
|
|
2771 {
|
|
2772 w = find_window_by_pixel_pos (*x, *y, f->root_window);
|
|
2773
|
|
2774 if (!w)
|
442
|
2775 return 1; /* #### What should really happen here? */
|
428
|
2776
|
|
2777 *x -= w->pixel_left;
|
|
2778 *y -= w->pixel_top;
|
|
2779 }
|
|
2780 else
|
|
2781 {
|
|
2782 *y -= FRAME_REAL_TOP_TOOLBAR_HEIGHT (f) -
|
|
2783 FRAME_REAL_TOP_TOOLBAR_BORDER_WIDTH (f);
|
|
2784 *x -= FRAME_REAL_LEFT_TOOLBAR_WIDTH (f) -
|
|
2785 FRAME_REAL_LEFT_TOOLBAR_BORDER_WIDTH (f);
|
|
2786 }
|
|
2787
|
|
2788 return 1;
|
|
2789 }
|
|
2790
|
|
2791 DEFUN ("event-window-x-pixel", Fevent_window_x_pixel, 1, 1, 0, /*
|
|
2792 Return the X position in pixels of mouse event EVENT.
|
|
2793 The value returned is relative to the window the event occurred in.
|
|
2794 This will signal an error if the event is not a mouse event.
|
|
2795 See also `mouse-event-p' and `event-x-pixel'.
|
|
2796 */
|
|
2797 (event))
|
|
2798 {
|
|
2799 int x, y;
|
|
2800
|
|
2801 CHECK_LIVE_EVENT (event);
|
|
2802
|
|
2803 if (!event_x_y_pixel_internal (event, &x, &y, 1))
|
|
2804 return wrong_type_argument (Qmouse_event_p, event);
|
|
2805 else
|
|
2806 return make_int (x);
|
|
2807 }
|
|
2808
|
|
2809 DEFUN ("event-window-y-pixel", Fevent_window_y_pixel, 1, 1, 0, /*
|
|
2810 Return the Y position in pixels of mouse event EVENT.
|
|
2811 The value returned is relative to the window the event occurred in.
|
|
2812 This will signal an error if the event is not a mouse event.
|
|
2813 See also `mouse-event-p' and `event-y-pixel'.
|
|
2814 */
|
|
2815 (event))
|
|
2816 {
|
|
2817 int x, y;
|
|
2818
|
|
2819 CHECK_LIVE_EVENT (event);
|
|
2820
|
|
2821 if (!event_x_y_pixel_internal (event, &x, &y, 1))
|
|
2822 return wrong_type_argument (Qmouse_event_p, event);
|
|
2823 else
|
|
2824 return make_int (y);
|
|
2825 }
|
|
2826
|
|
2827 DEFUN ("event-x-pixel", Fevent_x_pixel, 1, 1, 0, /*
|
|
2828 Return the X position in pixels of mouse event EVENT.
|
|
2829 The value returned is relative to the frame the event occurred in.
|
|
2830 This will signal an error if the event is not a mouse event.
|
|
2831 See also `mouse-event-p' and `event-window-x-pixel'.
|
|
2832 */
|
|
2833 (event))
|
|
2834 {
|
|
2835 int x, y;
|
|
2836
|
|
2837 CHECK_LIVE_EVENT (event);
|
|
2838
|
|
2839 if (!event_x_y_pixel_internal (event, &x, &y, 0))
|
|
2840 return wrong_type_argument (Qmouse_event_p, event);
|
|
2841 else
|
|
2842 return make_int (x);
|
|
2843 }
|
|
2844
|
|
2845 DEFUN ("event-y-pixel", Fevent_y_pixel, 1, 1, 0, /*
|
|
2846 Return the Y position in pixels of mouse event EVENT.
|
|
2847 The value returned is relative to the frame the event occurred in.
|
|
2848 This will signal an error if the event is not a mouse event.
|
|
2849 See also `mouse-event-p' `event-window-y-pixel'.
|
|
2850 */
|
|
2851 (event))
|
|
2852 {
|
|
2853 int x, y;
|
|
2854
|
|
2855 CHECK_LIVE_EVENT (event);
|
|
2856
|
|
2857 if (!event_x_y_pixel_internal (event, &x, &y, 0))
|
|
2858 return wrong_type_argument (Qmouse_event_p, event);
|
|
2859 else
|
|
2860 return make_int (y);
|
|
2861 }
|
|
2862
|
|
2863 /* Given an event, return a value:
|
|
2864
|
|
2865 OVER_TOOLBAR: over one of the 4 frame toolbars
|
|
2866 OVER_MODELINE: over a modeline
|
|
2867 OVER_BORDER: over an internal border
|
|
2868 OVER_NOTHING: over the text area, but not over text
|
|
2869 OVER_OUTSIDE: outside of the frame border
|
|
2870 OVER_TEXT: over text in the text area
|
|
2871 OVER_V_DIVIDER: over windows vertical divider
|
|
2872
|
|
2873 and return:
|
|
2874
|
|
2875 The X char position in CHAR_X, if not a null pointer.
|
|
2876 The Y char position in CHAR_Y, if not a null pointer.
|
|
2877 (These last two values are relative to the window the event is over.)
|
|
2878 The window it's over in W, if not a null pointer.
|
|
2879 The buffer position it's over in BUFP, if not a null pointer.
|
|
2880 The closest buffer position in CLOSEST, if not a null pointer.
|
|
2881
|
|
2882 OBJ_X, OBJ_Y, OBJ1, and OBJ2 are as in pixel_to_glyph_translation().
|
|
2883 */
|
|
2884
|
|
2885 static int
|
|
2886 event_pixel_translation (Lisp_Object event, int *char_x, int *char_y,
|
|
2887 int *obj_x, int *obj_y,
|
665
|
2888 struct window **w, Charbpos *bufp, Charbpos *closest,
|
428
|
2889 Charcount *modeline_closest,
|
|
2890 Lisp_Object *obj1, Lisp_Object *obj2)
|
|
2891 {
|
|
2892 int pix_x = 0;
|
|
2893 int pix_y = 0;
|
|
2894 int result;
|
|
2895 Lisp_Object frame;
|
|
2896
|
|
2897 int ret_x, ret_y, ret_obj_x, ret_obj_y;
|
|
2898 struct window *ret_w;
|
665
|
2899 Charbpos ret_bufp, ret_closest;
|
428
|
2900 Charcount ret_modeline_closest;
|
|
2901 Lisp_Object ret_obj1, ret_obj2;
|
|
2902
|
|
2903 CHECK_LIVE_EVENT (event);
|
934
|
2904 #ifdef USE_KKCC
|
|
2905 frame = XEVENT_CHANNEL (event);
|
|
2906 switch (XEVENT_TYPE (event))
|
|
2907 {
|
|
2908 case pointer_motion_event :
|
|
2909 pix_x = XMOTION_DATA_X (XEVENT_DATA (event));
|
|
2910 pix_y = XMOTION_DATA_Y (XEVENT_DATA (event));
|
|
2911 break;
|
|
2912 case button_press_event :
|
|
2913 case button_release_event :
|
|
2914 pix_x = XBUTTON_DATA_X (XEVENT_DATA (event));
|
|
2915 pix_y = XBUTTON_DATA_Y (XEVENT_DATA (event));
|
|
2916 break;
|
|
2917 case misc_user_event :
|
|
2918 pix_x = XMISC_USER_DATA_X (XEVENT_DATA (event));
|
|
2919 pix_y = XMISC_USER_DATA_Y (XEVENT_DATA (event));
|
|
2920 break;
|
|
2921 default:
|
|
2922 dead_wrong_type_argument (Qmouse_event_p, event);
|
|
2923 }
|
|
2924 #else /* not USE_KKCC */
|
428
|
2925 frame = XEVENT (event)->channel;
|
|
2926 switch (XEVENT (event)->event_type)
|
|
2927 {
|
|
2928 case pointer_motion_event :
|
|
2929 pix_x = XEVENT (event)->event.motion.x;
|
|
2930 pix_y = XEVENT (event)->event.motion.y;
|
|
2931 break;
|
|
2932 case button_press_event :
|
|
2933 case button_release_event :
|
|
2934 pix_x = XEVENT (event)->event.button.x;
|
|
2935 pix_y = XEVENT (event)->event.button.y;
|
|
2936 break;
|
|
2937 case misc_user_event :
|
|
2938 pix_x = XEVENT (event)->event.misc.x;
|
|
2939 pix_y = XEVENT (event)->event.misc.y;
|
|
2940 break;
|
|
2941 default:
|
|
2942 dead_wrong_type_argument (Qmouse_event_p, event);
|
|
2943 }
|
934
|
2944 #endif /* not USE_KKCC */
|
428
|
2945
|
|
2946 result = pixel_to_glyph_translation (XFRAME (frame), pix_x, pix_y,
|
|
2947 &ret_x, &ret_y, &ret_obj_x, &ret_obj_y,
|
|
2948 &ret_w, &ret_bufp, &ret_closest,
|
|
2949 &ret_modeline_closest,
|
|
2950 &ret_obj1, &ret_obj2);
|
|
2951
|
|
2952 if (result == OVER_NOTHING || result == OVER_OUTSIDE)
|
|
2953 ret_bufp = 0;
|
|
2954 else if (ret_w && NILP (ret_w->buffer))
|
|
2955 /* Why does this happen? (Does it still happen?)
|
|
2956 I guess the window has gotten reused as a non-leaf... */
|
|
2957 ret_w = 0;
|
|
2958
|
|
2959 /* #### pixel_to_glyph_translation() sometimes returns garbage...
|
|
2960 The word has type Lisp_Type_Record (presumably meaning `extent') but the
|
|
2961 pointer points to random memory, often filled with 0, sometimes not.
|
|
2962 */
|
|
2963 /* #### Chuck, do we still need this crap? */
|
|
2964 if (!NILP (ret_obj1) && !(GLYPHP (ret_obj1)
|
|
2965 #ifdef HAVE_TOOLBARS
|
|
2966 || TOOLBAR_BUTTONP (ret_obj1)
|
|
2967 #endif
|
|
2968 ))
|
|
2969 abort ();
|
|
2970 if (!NILP (ret_obj2) && !(EXTENTP (ret_obj2) || CONSP (ret_obj2)))
|
|
2971 abort ();
|
|
2972
|
|
2973 if (char_x)
|
|
2974 *char_x = ret_x;
|
|
2975 if (char_y)
|
|
2976 *char_y = ret_y;
|
|
2977 if (obj_x)
|
|
2978 *obj_x = ret_obj_x;
|
|
2979 if (obj_y)
|
|
2980 *obj_y = ret_obj_y;
|
|
2981 if (w)
|
|
2982 *w = ret_w;
|
|
2983 if (bufp)
|
|
2984 *bufp = ret_bufp;
|
|
2985 if (closest)
|
|
2986 *closest = ret_closest;
|
|
2987 if (modeline_closest)
|
|
2988 *modeline_closest = ret_modeline_closest;
|
|
2989 if (obj1)
|
|
2990 *obj1 = ret_obj1;
|
|
2991 if (obj2)
|
|
2992 *obj2 = ret_obj2;
|
|
2993
|
|
2994 return result;
|
|
2995 }
|
|
2996
|
|
2997 DEFUN ("event-over-text-area-p", Fevent_over_text_area_p, 1, 1, 0, /*
|
|
2998 Return t if the mouse event EVENT occurred over the text area of a window.
|
|
2999 The modeline is not considered to be part of the text area.
|
|
3000 */
|
|
3001 (event))
|
|
3002 {
|
|
3003 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
3004
|
|
3005 return result == OVER_TEXT || result == OVER_NOTHING ? Qt : Qnil;
|
|
3006 }
|
|
3007
|
|
3008 DEFUN ("event-over-modeline-p", Fevent_over_modeline_p, 1, 1, 0, /*
|
|
3009 Return t if the mouse event EVENT occurred over the modeline of a window.
|
|
3010 */
|
|
3011 (event))
|
|
3012 {
|
|
3013 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
3014
|
|
3015 return result == OVER_MODELINE ? Qt : Qnil;
|
|
3016 }
|
|
3017
|
|
3018 DEFUN ("event-over-border-p", Fevent_over_border_p, 1, 1, 0, /*
|
|
3019 Return t if the mouse event EVENT occurred over an internal border.
|
|
3020 */
|
|
3021 (event))
|
|
3022 {
|
|
3023 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
3024
|
|
3025 return result == OVER_BORDER ? Qt : Qnil;
|
|
3026 }
|
|
3027
|
|
3028 DEFUN ("event-over-toolbar-p", Fevent_over_toolbar_p, 1, 1, 0, /*
|
|
3029 Return t if the mouse event EVENT occurred over a toolbar.
|
|
3030 */
|
|
3031 (event))
|
|
3032 {
|
|
3033 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
3034
|
|
3035 return result == OVER_TOOLBAR ? Qt : Qnil;
|
|
3036 }
|
|
3037
|
|
3038 DEFUN ("event-over-vertical-divider-p", Fevent_over_vertical_divider_p, 1, 1, 0, /*
|
|
3039 Return t if the mouse event EVENT occurred over a window divider.
|
|
3040 */
|
|
3041 (event))
|
|
3042 {
|
|
3043 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
3044
|
|
3045 return result == OVER_V_DIVIDER ? Qt : Qnil;
|
|
3046 }
|
|
3047
|
|
3048 struct console *
|
|
3049 event_console_or_selected (Lisp_Object event)
|
|
3050 {
|
|
3051 Lisp_Object channel = EVENT_CHANNEL (XEVENT (event));
|
|
3052 Lisp_Object console = CDFW_CONSOLE (channel);
|
|
3053
|
|
3054 if (NILP (console))
|
|
3055 console = Vselected_console;
|
|
3056
|
|
3057 return XCONSOLE (console);
|
|
3058 }
|
|
3059
|
|
3060 DEFUN ("event-channel", Fevent_channel, 1, 1, 0, /*
|
|
3061 Return the channel that the event EVENT occurred on.
|
|
3062 This will be a frame, device, console, or nil for some types
|
|
3063 of events (e.g. eval events).
|
|
3064 */
|
|
3065 (event))
|
|
3066 {
|
|
3067 CHECK_LIVE_EVENT (event);
|
|
3068 return EVENT_CHANNEL (XEVENT (event));
|
|
3069 }
|
|
3070
|
|
3071 DEFUN ("event-window", Fevent_window, 1, 1, 0, /*
|
|
3072 Return the window over which mouse event EVENT occurred.
|
|
3073 This may be nil if the event occurred in the border or over a toolbar.
|
|
3074 The modeline is considered to be within the window it describes.
|
|
3075 */
|
|
3076 (event))
|
|
3077 {
|
|
3078 struct window *w;
|
|
3079
|
|
3080 event_pixel_translation (event, 0, 0, 0, 0, &w, 0, 0, 0, 0, 0);
|
|
3081
|
|
3082 if (!w)
|
|
3083 return Qnil;
|
|
3084 else
|
|
3085 {
|
793
|
3086 return wrap_window (w);
|
428
|
3087 }
|
|
3088 }
|
|
3089
|
|
3090 DEFUN ("event-point", Fevent_point, 1, 1, 0, /*
|
|
3091 Return the character position of the mouse event EVENT.
|
|
3092 If the event did not occur over a window, or did not occur over text,
|
|
3093 then this returns nil. Otherwise, it returns a position in the buffer
|
|
3094 visible in the event's window.
|
|
3095 */
|
|
3096 (event))
|
|
3097 {
|
665
|
3098 Charbpos bufp;
|
428
|
3099 struct window *w;
|
|
3100
|
|
3101 event_pixel_translation (event, 0, 0, 0, 0, &w, &bufp, 0, 0, 0, 0);
|
|
3102
|
|
3103 return w && bufp ? make_int (bufp) : Qnil;
|
|
3104 }
|
|
3105
|
|
3106 DEFUN ("event-closest-point", Fevent_closest_point, 1, 1, 0, /*
|
|
3107 Return the character position closest to the mouse event EVENT.
|
|
3108 If the event did not occur over a window or over text, return the
|
|
3109 closest point to the location of the event. If the Y pixel position
|
|
3110 overlaps a window and the X pixel position is to the left of that
|
|
3111 window, the closest point is the beginning of the line containing the
|
|
3112 Y position. If the Y pixel position overlaps a window and the X pixel
|
|
3113 position is to the right of that window, the closest point is the end
|
|
3114 of the line containing the Y position. If the Y pixel position is
|
|
3115 above a window, return 0. If it is below the last character in a window,
|
|
3116 return the value of (window-end).
|
|
3117 */
|
|
3118 (event))
|
|
3119 {
|
665
|
3120 Charbpos bufp;
|
428
|
3121
|
|
3122 event_pixel_translation (event, 0, 0, 0, 0, 0, 0, &bufp, 0, 0, 0);
|
|
3123
|
|
3124 return bufp ? make_int (bufp) : Qnil;
|
|
3125 }
|
|
3126
|
|
3127 DEFUN ("event-x", Fevent_x, 1, 1, 0, /*
|
|
3128 Return the X position of the mouse event EVENT in characters.
|
|
3129 This is relative to the window the event occurred over.
|
|
3130 */
|
|
3131 (event))
|
|
3132 {
|
|
3133 int char_x;
|
|
3134
|
|
3135 event_pixel_translation (event, &char_x, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
3136
|
|
3137 return make_int (char_x);
|
|
3138 }
|
|
3139
|
|
3140 DEFUN ("event-y", Fevent_y, 1, 1, 0, /*
|
|
3141 Return the Y position of the mouse event EVENT in characters.
|
|
3142 This is relative to the window the event occurred over.
|
|
3143 */
|
|
3144 (event))
|
|
3145 {
|
|
3146 int char_y;
|
|
3147
|
|
3148 event_pixel_translation (event, 0, &char_y, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
3149
|
|
3150 return make_int (char_y);
|
|
3151 }
|
|
3152
|
|
3153 DEFUN ("event-modeline-position", Fevent_modeline_position, 1, 1, 0, /*
|
|
3154 Return the character position in the modeline that EVENT occurred over.
|
|
3155 EVENT should be a mouse event. If EVENT did not occur over a modeline,
|
|
3156 nil is returned. You can determine the actual character that the
|
|
3157 event occurred over by looking in `generated-modeline-string' at the
|
|
3158 returned character position. Note that `generated-modeline-string'
|
|
3159 is buffer-local, and you must use EVENT's buffer when retrieving
|
|
3160 `generated-modeline-string' in order to get accurate results.
|
|
3161 */
|
|
3162 (event))
|
|
3163 {
|
|
3164 Charcount mbufp;
|
|
3165 int where;
|
|
3166
|
|
3167 where = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, &mbufp, 0, 0);
|
|
3168
|
|
3169 return (mbufp < 0 || where != OVER_MODELINE) ? Qnil : make_int (mbufp);
|
|
3170 }
|
|
3171
|
|
3172 DEFUN ("event-glyph", Fevent_glyph, 1, 1, 0, /*
|
|
3173 Return the glyph that the mouse event EVENT occurred over, or nil.
|
|
3174 */
|
|
3175 (event))
|
|
3176 {
|
|
3177 Lisp_Object glyph;
|
|
3178 struct window *w;
|
|
3179
|
|
3180 event_pixel_translation (event, 0, 0, 0, 0, &w, 0, 0, 0, &glyph, 0);
|
|
3181
|
|
3182 return w && GLYPHP (glyph) ? glyph : Qnil;
|
|
3183 }
|
|
3184
|
|
3185 DEFUN ("event-glyph-extent", Fevent_glyph_extent, 1, 1, 0, /*
|
|
3186 Return the extent of the glyph that the mouse event EVENT occurred over.
|
|
3187 If the event did not occur over a glyph, nil is returned.
|
|
3188 */
|
|
3189 (event))
|
|
3190 {
|
|
3191 Lisp_Object extent;
|
|
3192 struct window *w;
|
|
3193
|
|
3194 event_pixel_translation (event, 0, 0, 0, 0, &w, 0, 0, 0, 0, &extent);
|
|
3195
|
|
3196 return w && EXTENTP (extent) ? extent : Qnil;
|
|
3197 }
|
|
3198
|
|
3199 DEFUN ("event-glyph-x-pixel", Fevent_glyph_x_pixel, 1, 1, 0, /*
|
|
3200 Return the X pixel position of EVENT relative to the glyph it occurred over.
|
|
3201 EVENT should be a mouse event. If the event did not occur over a glyph,
|
|
3202 nil is returned.
|
|
3203 */
|
|
3204 (event))
|
|
3205 {
|
|
3206 Lisp_Object extent;
|
|
3207 struct window *w;
|
|
3208 int obj_x;
|
|
3209
|
|
3210 event_pixel_translation (event, 0, 0, &obj_x, 0, &w, 0, 0, 0, 0, &extent);
|
|
3211
|
|
3212 return w && EXTENTP (extent) ? make_int (obj_x) : Qnil;
|
|
3213 }
|
|
3214
|
|
3215 DEFUN ("event-glyph-y-pixel", Fevent_glyph_y_pixel, 1, 1, 0, /*
|
|
3216 Return the Y pixel position of EVENT relative to the glyph it occurred over.
|
|
3217 EVENT should be a mouse event. If the event did not occur over a glyph,
|
|
3218 nil is returned.
|
|
3219 */
|
|
3220 (event))
|
|
3221 {
|
|
3222 Lisp_Object extent;
|
|
3223 struct window *w;
|
|
3224 int obj_y;
|
|
3225
|
|
3226 event_pixel_translation (event, 0, 0, 0, &obj_y, &w, 0, 0, 0, 0, &extent);
|
|
3227
|
|
3228 return w && EXTENTP (extent) ? make_int (obj_y) : Qnil;
|
|
3229 }
|
|
3230
|
|
3231 DEFUN ("event-toolbar-button", Fevent_toolbar_button, 1, 1, 0, /*
|
|
3232 Return the toolbar button that the mouse event EVENT occurred over.
|
|
3233 If the event did not occur over a toolbar button, nil is returned.
|
|
3234 */
|
|
3235 (event))
|
|
3236 {
|
|
3237 #ifdef HAVE_TOOLBARS
|
|
3238 Lisp_Object button;
|
|
3239
|
|
3240 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, &button, 0);
|
|
3241
|
|
3242 return result == OVER_TOOLBAR && TOOLBAR_BUTTONP (button) ? button : Qnil;
|
|
3243 #else
|
|
3244 return Qnil;
|
|
3245 #endif
|
|
3246 }
|
|
3247
|
|
3248 DEFUN ("event-process", Fevent_process, 1, 1, 0, /*
|
444
|
3249 Return the process of the process-output event EVENT.
|
428
|
3250 */
|
|
3251 (event))
|
|
3252 {
|
934
|
3253 #ifdef USE_KKCC
|
|
3254 CHECK_EVENT_TYPE (event, process_event, Qprocess_event_p);
|
|
3255 return XPROCESS_DATA_PROCESS (XEVENT_DATA (event));
|
|
3256 #else /* not USE_KKCC */
|
428
|
3257 CHECK_EVENT_TYPE (event, process_event, Qprocess_event_p);
|
|
3258 return XEVENT (event)->event.process.process;
|
934
|
3259 #endif /* not USE_KKCC */
|
428
|
3260 }
|
|
3261
|
|
3262 DEFUN ("event-function", Fevent_function, 1, 1, 0, /*
|
|
3263 Return the callback function of EVENT.
|
|
3264 EVENT should be a timeout, misc-user, or eval event.
|
|
3265 */
|
|
3266 (event))
|
|
3267 {
|
|
3268 again:
|
|
3269 CHECK_LIVE_EVENT (event);
|
934
|
3270 #ifdef USE_KKCC
|
|
3271 switch (XEVENT_TYPE (event))
|
|
3272 {
|
|
3273 case timeout_event:
|
|
3274 return XTIMEOUT_DATA_FUNCTION (XEVENT_DATA (event));
|
|
3275 case misc_user_event:
|
|
3276 return XMISC_USER_DATA_FUNCTION (XEVENT_DATA (event));
|
|
3277 case eval_event:
|
|
3278 return XEVAL_DATA_FUNCTION (XEVENT_DATA (event));
|
|
3279 default:
|
|
3280 event = wrong_type_argument (intern ("timeout-or-eval-event-p"), event);
|
|
3281 goto again;
|
|
3282 }
|
|
3283 #else /* not USE_KKCC */
|
428
|
3284 switch (XEVENT (event)->event_type)
|
|
3285 {
|
|
3286 case timeout_event:
|
|
3287 return XEVENT (event)->event.timeout.function;
|
|
3288 case misc_user_event:
|
|
3289 return XEVENT (event)->event.misc.function;
|
|
3290 case eval_event:
|
|
3291 return XEVENT (event)->event.eval.function;
|
|
3292 default:
|
|
3293 event = wrong_type_argument (intern ("timeout-or-eval-event-p"), event);
|
|
3294 goto again;
|
|
3295 }
|
934
|
3296 #endif /* not USE_KKCC */
|
428
|
3297 }
|
|
3298
|
|
3299 DEFUN ("event-object", Fevent_object, 1, 1, 0, /*
|
|
3300 Return the callback function argument of EVENT.
|
|
3301 EVENT should be a timeout, misc-user, or eval event.
|
|
3302 */
|
|
3303 (event))
|
|
3304 {
|
|
3305 again:
|
|
3306 CHECK_LIVE_EVENT (event);
|
934
|
3307 #ifdef USE_KKCC
|
|
3308 switch (XEVENT_TYPE (event))
|
|
3309 {
|
|
3310 case timeout_event:
|
|
3311 return XTIMEOUT_DATA_OBJECT (XEVENT_DATA (event));
|
|
3312 case misc_user_event:
|
|
3313 return XMISC_USER_DATA_OBJECT (XEVENT_DATA (event));
|
|
3314 case eval_event:
|
|
3315 return XEVAL_DATA_OBJECT (XEVENT_DATA (event));
|
|
3316 default:
|
|
3317 event = wrong_type_argument (intern ("timeout-or-eval-event-p"), event);
|
|
3318 goto again;
|
|
3319 }
|
|
3320 #else /* not USE_KKCC */
|
428
|
3321 switch (XEVENT (event)->event_type)
|
|
3322 {
|
|
3323 case timeout_event:
|
|
3324 return XEVENT (event)->event.timeout.object;
|
|
3325 case misc_user_event:
|
|
3326 return XEVENT (event)->event.misc.object;
|
|
3327 case eval_event:
|
|
3328 return XEVENT (event)->event.eval.object;
|
|
3329 default:
|
|
3330 event = wrong_type_argument (intern ("timeout-or-eval-event-p"), event);
|
|
3331 goto again;
|
|
3332 }
|
934
|
3333 #endif /* not USE_KKCC */
|
428
|
3334 }
|
|
3335
|
|
3336 DEFUN ("event-properties", Fevent_properties, 1, 1, 0, /*
|
|
3337 Return a list of all of the properties of EVENT.
|
|
3338 This is in the form of a property list (alternating keyword/value pairs).
|
|
3339 */
|
|
3340 (event))
|
|
3341 {
|
|
3342 Lisp_Object props = Qnil;
|
440
|
3343 Lisp_Event *e;
|
428
|
3344 struct gcpro gcpro1;
|
|
3345
|
|
3346 CHECK_LIVE_EVENT (event);
|
|
3347 e = XEVENT (event);
|
|
3348 GCPRO1 (props);
|
|
3349
|
|
3350 props = cons3 (Qtimestamp, Fevent_timestamp (event), props);
|
|
3351
|
934
|
3352 #ifdef USE_KKCC
|
|
3353 switch (EVENT_TYPE (e))
|
|
3354 #else /* not USE_KKCC */
|
428
|
3355 switch (e->event_type)
|
934
|
3356 #endif /* not USE_KKCC */
|
428
|
3357 {
|
|
3358 default: abort ();
|
|
3359
|
|
3360 case process_event:
|
934
|
3361 #ifdef USE_KKCC
|
|
3362 props = cons3 (Qprocess, XPROCESS_DATA_PROCESS (EVENT_DATA (e)), props);
|
|
3363 #else /* not USE_KKCC */
|
428
|
3364 props = cons3 (Qprocess, e->event.process.process, props);
|
934
|
3365 #endif /* not USE_KKCC */
|
428
|
3366 break;
|
|
3367
|
|
3368 case timeout_event:
|
|
3369 props = cons3 (Qobject, Fevent_object (event), props);
|
|
3370 props = cons3 (Qfunction, Fevent_function (event), props);
|
934
|
3371 #ifdef USE_KKCC
|
|
3372 props = cons3 (Qid, make_int (XTIMEOUT_DATA_ID_NUMBER (EVENT_DATA (e))), props);
|
|
3373 #else /* not USE_KKCC */
|
428
|
3374 props = cons3 (Qid, make_int (e->event.timeout.id_number), props);
|
934
|
3375 #endif /* not USE_KKCC */
|
428
|
3376 break;
|
|
3377
|
|
3378 case key_press_event:
|
|
3379 props = cons3 (Qmodifiers, Fevent_modifiers (event), props);
|
|
3380 props = cons3 (Qkey, Fevent_key (event), props);
|
|
3381 break;
|
|
3382
|
|
3383 case button_press_event:
|
|
3384 case button_release_event:
|
|
3385 props = cons3 (Qy, Fevent_y_pixel (event), props);
|
|
3386 props = cons3 (Qx, Fevent_x_pixel (event), props);
|
|
3387 props = cons3 (Qmodifiers, Fevent_modifiers (event), props);
|
|
3388 props = cons3 (Qbutton, Fevent_button (event), props);
|
|
3389 break;
|
|
3390
|
|
3391 case pointer_motion_event:
|
|
3392 props = cons3 (Qmodifiers, Fevent_modifiers (event), props);
|
|
3393 props = cons3 (Qy, Fevent_y_pixel (event), props);
|
|
3394 props = cons3 (Qx, Fevent_x_pixel (event), props);
|
|
3395 break;
|
|
3396
|
|
3397 case misc_user_event:
|
|
3398 props = cons3 (Qobject, Fevent_object (event), props);
|
|
3399 props = cons3 (Qfunction, Fevent_function (event), props);
|
|
3400 props = cons3 (Qy, Fevent_y_pixel (event), props);
|
|
3401 props = cons3 (Qx, Fevent_x_pixel (event), props);
|
|
3402 props = cons3 (Qmodifiers, Fevent_modifiers (event), props);
|
|
3403 props = cons3 (Qbutton, Fevent_button (event), props);
|
|
3404 break;
|
|
3405
|
|
3406 case eval_event:
|
|
3407 props = cons3 (Qobject, Fevent_object (event), props);
|
|
3408 props = cons3 (Qfunction, Fevent_function (event), props);
|
|
3409 break;
|
|
3410
|
|
3411 case magic_eval_event:
|
|
3412 case magic_event:
|
|
3413 break;
|
|
3414
|
|
3415 case empty_event:
|
|
3416 RETURN_UNGCPRO (Qnil);
|
|
3417 break;
|
|
3418 }
|
|
3419
|
|
3420 props = cons3 (Qchannel, Fevent_channel (event), props);
|
|
3421 UNGCPRO;
|
|
3422
|
|
3423 return props;
|
|
3424 }
|
|
3425
|
|
3426
|
|
3427 /************************************************************************/
|
|
3428 /* initialization */
|
|
3429 /************************************************************************/
|
|
3430
|
|
3431 void
|
|
3432 syms_of_events (void)
|
|
3433 {
|
442
|
3434 INIT_LRECORD_IMPLEMENTATION (event);
|
934
|
3435 #ifdef USE_KKCC
|
|
3436 INIT_LRECORD_IMPLEMENTATION (key_data);
|
|
3437 INIT_LRECORD_IMPLEMENTATION (button_data);
|
|
3438 INIT_LRECORD_IMPLEMENTATION (motion_data);
|
|
3439 INIT_LRECORD_IMPLEMENTATION (process_data);
|
|
3440 INIT_LRECORD_IMPLEMENTATION (timeout_data);
|
|
3441 INIT_LRECORD_IMPLEMENTATION (eval_data);
|
|
3442 INIT_LRECORD_IMPLEMENTATION (misc_user_data);
|
|
3443 INIT_LRECORD_IMPLEMENTATION (magic_eval_data);
|
|
3444 INIT_LRECORD_IMPLEMENTATION (magic_data);
|
|
3445 #endif /* USE_KKCC */
|
442
|
3446
|
428
|
3447 DEFSUBR (Fcharacter_to_event);
|
|
3448 DEFSUBR (Fevent_to_character);
|
|
3449
|
|
3450 DEFSUBR (Fmake_event);
|
|
3451 DEFSUBR (Fdeallocate_event);
|
|
3452 DEFSUBR (Fcopy_event);
|
|
3453 DEFSUBR (Feventp);
|
|
3454 DEFSUBR (Fevent_live_p);
|
|
3455 DEFSUBR (Fevent_type);
|
|
3456 DEFSUBR (Fevent_properties);
|
|
3457
|
|
3458 DEFSUBR (Fevent_timestamp);
|
442
|
3459 DEFSUBR (Fevent_timestamp_lessp);
|
428
|
3460 DEFSUBR (Fevent_key);
|
|
3461 DEFSUBR (Fevent_button);
|
|
3462 DEFSUBR (Fevent_modifier_bits);
|
|
3463 DEFSUBR (Fevent_modifiers);
|
|
3464 DEFSUBR (Fevent_x_pixel);
|
|
3465 DEFSUBR (Fevent_y_pixel);
|
|
3466 DEFSUBR (Fevent_window_x_pixel);
|
|
3467 DEFSUBR (Fevent_window_y_pixel);
|
|
3468 DEFSUBR (Fevent_over_text_area_p);
|
|
3469 DEFSUBR (Fevent_over_modeline_p);
|
|
3470 DEFSUBR (Fevent_over_border_p);
|
|
3471 DEFSUBR (Fevent_over_toolbar_p);
|
|
3472 DEFSUBR (Fevent_over_vertical_divider_p);
|
|
3473 DEFSUBR (Fevent_channel);
|
|
3474 DEFSUBR (Fevent_window);
|
|
3475 DEFSUBR (Fevent_point);
|
|
3476 DEFSUBR (Fevent_closest_point);
|
|
3477 DEFSUBR (Fevent_x);
|
|
3478 DEFSUBR (Fevent_y);
|
|
3479 DEFSUBR (Fevent_modeline_position);
|
|
3480 DEFSUBR (Fevent_glyph);
|
|
3481 DEFSUBR (Fevent_glyph_extent);
|
|
3482 DEFSUBR (Fevent_glyph_x_pixel);
|
|
3483 DEFSUBR (Fevent_glyph_y_pixel);
|
|
3484 DEFSUBR (Fevent_toolbar_button);
|
|
3485 DEFSUBR (Fevent_process);
|
|
3486 DEFSUBR (Fevent_function);
|
|
3487 DEFSUBR (Fevent_object);
|
|
3488
|
563
|
3489 DEFSYMBOL (Qeventp);
|
|
3490 DEFSYMBOL (Qevent_live_p);
|
|
3491 DEFSYMBOL (Qkey_press_event_p);
|
|
3492 DEFSYMBOL (Qbutton_event_p);
|
|
3493 DEFSYMBOL (Qmouse_event_p);
|
|
3494 DEFSYMBOL (Qprocess_event_p);
|
|
3495 DEFSYMBOL (Qkey_press);
|
|
3496 DEFSYMBOL (Qbutton_press);
|
|
3497 DEFSYMBOL (Qbutton_release);
|
|
3498 DEFSYMBOL (Qmisc_user);
|
|
3499 DEFSYMBOL (Qascii_character);
|
428
|
3500
|
|
3501 defsymbol (&QKbackspace, "backspace");
|
|
3502 defsymbol (&QKtab, "tab");
|
|
3503 defsymbol (&QKlinefeed, "linefeed");
|
|
3504 defsymbol (&QKreturn, "return");
|
|
3505 defsymbol (&QKescape, "escape");
|
|
3506 defsymbol (&QKspace, "space");
|
|
3507 defsymbol (&QKdelete, "delete");
|
|
3508 }
|
|
3509
|
|
3510
|
|
3511 void
|
|
3512 reinit_vars_of_events (void)
|
|
3513 {
|
|
3514 Vevent_resource = Qnil;
|
|
3515 }
|
|
3516
|
|
3517 void
|
|
3518 vars_of_events (void)
|
|
3519 {
|
|
3520 reinit_vars_of_events ();
|
|
3521
|
|
3522 DEFVAR_LISP ("character-set-property", &Vcharacter_set_property /*
|
|
3523 A symbol used to look up the 8-bit character of a keysym.
|
|
3524 To convert a keysym symbol to an 8-bit code, as when that key is
|
|
3525 bound to self-insert-command, we will look up the property that this
|
|
3526 variable names on the property list of the keysym-symbol. The window-
|
|
3527 system-specific code will set up appropriate properties and set this
|
|
3528 variable.
|
|
3529 */ );
|
|
3530 Vcharacter_set_property = Qnil;
|
|
3531 }
|