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