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