0
|
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.
|
|
4
|
|
5 This file is part of XEmacs.
|
|
6
|
|
7 XEmacs is free software; you can redistribute it and/or modify it
|
|
8 under the terms of the GNU General Public License as published by the
|
|
9 Free Software Foundation; either version 2, or (at your option) any
|
|
10 later version.
|
|
11
|
|
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
15 for more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License
|
|
18 along with XEmacs; see the file COPYING. If not, write to
|
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
20 Boston, MA 02111-1307, USA. */
|
|
21
|
|
22 /* Synched up with: Not in FSF. */
|
|
23
|
|
24 /* This file has been Mule-ized. */
|
|
25
|
|
26 #include <config.h>
|
|
27 #include "lisp.h"
|
|
28 #include "buffer.h"
|
|
29 #include "console.h"
|
|
30 #include "console-tty.h" /* for stuff in character_to_event */
|
|
31 #include "device.h"
|
|
32 #include "console-x.h" /* for x_event_name prototype */
|
|
33 #include "extents.h" /* Just for the EXTENTP abort check... */
|
|
34 #include "events.h"
|
|
35 #include "frame.h"
|
|
36 #include "glyphs.h"
|
|
37 #include "keymap.h" /* for key_desc_list_to_event() */
|
|
38 #include "redisplay.h"
|
|
39 #include "window.h"
|
|
40
|
100
|
41 #ifdef WINDOWSNT
|
|
42 /* Hmm, under unix we want X modifiers, under NT we want X modifiers if
|
|
43 we are running X and Windows modifiers otherwise.
|
|
44 gak. This is a kludge until we support multiple native GUIs!
|
|
45 */
|
|
46 #undef MOD_ALT
|
|
47 #undef MOD_CONTROL
|
|
48 #undef MOD_SHIFT
|
|
49 #endif
|
|
50
|
157
|
51 #include "events-mod.h"
|
100
|
52
|
0
|
53 /* Where old events go when they are explicitly deallocated.
|
|
54 The event chain here is cut loose before GC, so these will be freed
|
|
55 eventually.
|
|
56 */
|
|
57 static Lisp_Object Vevent_resource;
|
|
58
|
|
59 Lisp_Object Qeventp;
|
|
60 Lisp_Object Qevent_live_p;
|
|
61 Lisp_Object Qkey_press_event_p;
|
|
62 Lisp_Object Qbutton_event_p;
|
|
63 Lisp_Object Qmouse_event_p;
|
|
64 Lisp_Object Qprocess_event_p;
|
|
65
|
163
|
66 Lisp_Object Qkey_press, Qbutton_press, Qbutton_release, Qmisc_user;
|
0
|
67 Lisp_Object Qascii_character;
|
|
68
|
272
|
69 EXFUN (Fevent_x_pixel, 1);
|
|
70 EXFUN (Fevent_y_pixel, 1);
|
|
71
|
0
|
72 /* #### Ad-hoc hack. Should be part of define_lrecord_implementation */
|
|
73 void
|
|
74 clear_event_resource (void)
|
|
75 {
|
|
76 Vevent_resource = Qnil;
|
|
77 }
|
|
78
|
|
79 /* Make sure we lose quickly if we try to use this event */
|
|
80 static void
|
|
81 deinitialize_event (Lisp_Object ev)
|
|
82 {
|
|
83 int i;
|
|
84 struct Lisp_Event *event = XEVENT (ev);
|
|
85
|
272
|
86 for (i = 0; i < (int) (sizeof (struct Lisp_Event) / sizeof (int)); i++)
|
0
|
87 ((int *) event) [i] = 0xdeadbeef;
|
|
88 event->event_type = dead_event;
|
|
89 event->channel = Qnil;
|
|
90 set_lheader_implementation (&(event->lheader), lrecord_event);
|
|
91 XSET_EVENT_NEXT (ev, Qnil);
|
|
92 }
|
|
93
|
|
94 /* Set everything to zero or nil so that it's predictable. */
|
|
95 void
|
|
96 zero_event (struct Lisp_Event *e)
|
|
97 {
|
272
|
98 xzero (*e);
|
0
|
99 set_lheader_implementation (&(e->lheader), lrecord_event);
|
|
100 e->event_type = empty_event;
|
|
101 e->next = Qnil;
|
|
102 e->channel = Qnil;
|
|
103 }
|
|
104
|
|
105 static Lisp_Object
|
|
106 mark_event (Lisp_Object obj, void (*markobj) (Lisp_Object))
|
|
107 {
|
|
108 struct Lisp_Event *event = XEVENT (obj);
|
|
109
|
|
110 switch (event->event_type)
|
|
111 {
|
|
112 case key_press_event:
|
|
113 ((markobj) (event->event.key.keysym));
|
|
114 break;
|
|
115 case process_event:
|
|
116 ((markobj) (event->event.process.process));
|
|
117 break;
|
|
118 case timeout_event:
|
|
119 ((markobj) (event->event.timeout.function));
|
|
120 ((markobj) (event->event.timeout.object));
|
|
121 break;
|
|
122 case eval_event:
|
|
123 case misc_user_event:
|
|
124 ((markobj) (event->event.eval.function));
|
|
125 ((markobj) (event->event.eval.object));
|
|
126 break;
|
|
127 case magic_eval_event:
|
|
128 ((markobj) (event->event.magic_eval.object));
|
|
129 break;
|
|
130 case button_press_event:
|
|
131 case button_release_event:
|
|
132 case pointer_motion_event:
|
|
133 case magic_event:
|
|
134 case empty_event:
|
|
135 case dead_event:
|
|
136 break;
|
|
137 default:
|
|
138 abort ();
|
|
139 }
|
|
140 ((markobj) (event->channel));
|
|
141 return event->next;
|
|
142 }
|
|
143
|
|
144 static void
|
|
145 print_event_1 (CONST char *str, Lisp_Object obj, Lisp_Object printcharfun)
|
|
146 {
|
|
147 char buf[255];
|
|
148 write_c_string (str, printcharfun);
|
|
149 format_event_object (buf, XEVENT (obj), 0);
|
|
150 write_c_string (buf, printcharfun);
|
|
151 }
|
|
152
|
|
153 static void
|
|
154 print_event (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
155 {
|
|
156 if (print_readably)
|
|
157 error ("printing unreadable object #<event>");
|
|
158
|
173
|
159 switch (XEVENT (obj)->event_type)
|
0
|
160 {
|
|
161 case key_press_event:
|
|
162 print_event_1 ("#<keypress-event ", obj, printcharfun);
|
|
163 break;
|
|
164 case button_press_event:
|
|
165 print_event_1 ("#<buttondown-event ", obj, printcharfun);
|
|
166 break;
|
|
167 case button_release_event:
|
|
168 print_event_1 ("#<buttonup-event ", obj, printcharfun);
|
|
169 break;
|
|
170 case magic_event:
|
|
171 case magic_eval_event:
|
|
172 print_event_1 ("#<magic-event ", obj, printcharfun);
|
|
173 break;
|
|
174 case pointer_motion_event:
|
|
175 {
|
213
|
176 char buf[64];
|
215
|
177 Lisp_Object Vx, Vy;
|
|
178 Vx = Fevent_x_pixel (obj);
|
|
179 assert (INTP (Vx));
|
|
180 Vy = Fevent_y_pixel (obj);
|
|
181 assert (INTP (Vy));
|
274
|
182 sprintf (buf, "#<motion-event %ld, %ld", (long)(XINT (Vx)), (long)(XINT (Vy)));
|
0
|
183 write_c_string (buf, printcharfun);
|
|
184 break;
|
|
185 }
|
|
186 case process_event:
|
|
187 write_c_string ("#<process-event ", printcharfun);
|
|
188 print_internal (XEVENT (obj)->event.process.process, printcharfun, 1);
|
|
189 break;
|
|
190 case timeout_event:
|
|
191 write_c_string ("#<timeout-event ", printcharfun);
|
|
192 print_internal (XEVENT (obj)->event.timeout.object, printcharfun, 1);
|
|
193 break;
|
|
194 case empty_event:
|
|
195 write_c_string ("#<empty-event", printcharfun);
|
|
196 break;
|
|
197 case misc_user_event:
|
282
|
198 write_c_string ("#<misc-user-event (", printcharfun);
|
|
199 print_internal (XEVENT (obj)->event.misc.function, printcharfun, 1);
|
|
200 write_c_string (" ", printcharfun);
|
|
201 print_internal (XEVENT (obj)->event.misc.object, printcharfun, 1);
|
|
202 write_c_string (")", printcharfun);
|
|
203 break;
|
0
|
204 case eval_event:
|
282
|
205 write_c_string ("#<eval-event (", printcharfun);
|
0
|
206 print_internal (XEVENT (obj)->event.eval.function, printcharfun, 1);
|
|
207 write_c_string (" ", printcharfun);
|
|
208 print_internal (XEVENT (obj)->event.eval.object, printcharfun, 1);
|
|
209 write_c_string (")", printcharfun);
|
|
210 break;
|
|
211 case dead_event:
|
|
212 write_c_string ("#<DEALLOCATED-EVENT", printcharfun);
|
|
213 break;
|
|
214 default:
|
|
215 write_c_string ("#<UNKNOWN-EVENT-TYPE", printcharfun);
|
|
216 break;
|
|
217 }
|
|
218 write_c_string (">", printcharfun);
|
|
219 }
|
173
|
220
|
0
|
221 static int
|
|
222 event_equal (Lisp_Object o1, Lisp_Object o2, int depth)
|
|
223 {
|
|
224 struct Lisp_Event *e1 = XEVENT (o1);
|
|
225 struct Lisp_Event *e2 = XEVENT (o2);
|
|
226
|
|
227 if (e1->event_type != e2->event_type) return 0;
|
|
228 if (!EQ (e1->channel, e2->channel)) return 0;
|
|
229 /* if (e1->timestamp != e2->timestamp) return 0; */
|
|
230 switch (e1->event_type)
|
|
231 {
|
|
232 case process_event:
|
149
|
233 return EQ (e1->event.process.process, e2->event.process.process);
|
173
|
234
|
0
|
235 case timeout_event:
|
195
|
236 return (internal_equal (e1->event.timeout.function,
|
|
237 e2->event.timeout.function, 0) &&
|
|
238 internal_equal (e1->event.timeout.object,
|
|
239 e2->event.timeout.object, 0));
|
173
|
240
|
0
|
241 case key_press_event:
|
149
|
242 return (EQ (e1->event.key.keysym, e2->event.key.keysym) &&
|
|
243 (e1->event.key.modifiers == e2->event.key.modifiers));
|
0
|
244
|
|
245 case button_press_event:
|
|
246 case button_release_event:
|
149
|
247 return (e1->event.button.button == e2->event.button.button &&
|
|
248 e1->event.button.modifiers == e2->event.button.modifiers);
|
0
|
249
|
|
250 case pointer_motion_event:
|
149
|
251 return (e1->event.motion.x == e2->event.motion.x &&
|
|
252 e1->event.motion.y == e2->event.motion.y);
|
0
|
253
|
|
254 case misc_user_event:
|
282
|
255 return (internal_equal (e1->event.eval.function,
|
|
256 e2->event.eval.function, 0) &&
|
|
257 internal_equal (e1->event.eval.object,
|
|
258 e2->event.eval.object, 0) &&
|
|
259 /* is this really needed for equality
|
|
260 or is x and y also important? */
|
|
261 e1->event.misc.button == e2->event.misc.button &&
|
|
262 e1->event.misc.modifiers == e2->event.misc.modifiers);
|
|
263
|
0
|
264 case eval_event:
|
195
|
265 return (internal_equal (e1->event.eval.function,
|
|
266 e2->event.eval.function, 0) &&
|
|
267 internal_equal (e1->event.eval.object,
|
|
268 e2->event.eval.object, 0));
|
0
|
269
|
|
270 case magic_eval_event:
|
149
|
271 return (e1->event.magic_eval.internal_function ==
|
|
272 e2->event.magic_eval.internal_function &&
|
195
|
273 internal_equal (e1->event.magic_eval.object,
|
|
274 e2->event.magic_eval.object, 0));
|
0
|
275
|
|
276 case magic_event:
|
|
277 {
|
183
|
278 struct console *con = XCONSOLE (CDFW_CONSOLE (e1->channel));
|
0
|
279
|
|
280 #ifdef HAVE_X_WINDOWS
|
183
|
281 if (CONSOLE_X_P (con))
|
|
282 return (e1->event.magic.underlying_x_event.xany.serial ==
|
|
283 e2->event.magic.underlying_x_event.xany.serial);
|
0
|
284 #endif
|
149
|
285 #ifdef HAVE_TTY
|
183
|
286 if (CONSOLE_TTY_P (con))
|
0
|
287 return (e1->event.magic.underlying_tty_event ==
|
|
288 e2->event.magic.underlying_tty_event);
|
149
|
289 #endif
|
213
|
290 #ifdef HAVE_MS_WINDOWS
|
|
291 if (CONSOLE_MSWINDOWS_P (con))
|
|
292 return (!memcmp(&e1->event.magic.underlying_mswindows_event,
|
|
293 &e2->event.magic.underlying_mswindows_event,
|
209
|
294 sizeof(union magic_data)));
|
|
295 #endif
|
183
|
296 return 1; /* not reached */
|
0
|
297 }
|
|
298
|
|
299 case empty_event: /* Empty and deallocated events are equal. */
|
|
300 case dead_event:
|
|
301 return 1;
|
|
302
|
|
303 default:
|
|
304 abort ();
|
|
305 return 0; /* not reached; warning suppression */
|
|
306 }
|
|
307 }
|
|
308
|
|
309 static unsigned long
|
|
310 event_hash (Lisp_Object obj, int depth)
|
|
311 {
|
|
312 struct Lisp_Event *e = XEVENT (obj);
|
|
313 unsigned long hash;
|
|
314
|
|
315 hash = HASH2 (e->event_type, LISP_HASH (e->channel));
|
|
316 switch (e->event_type)
|
|
317 {
|
|
318 case process_event:
|
|
319 return HASH2 (hash, LISP_HASH (e->event.process.process));
|
173
|
320
|
0
|
321 case timeout_event:
|
|
322 return HASH3 (hash, internal_hash (e->event.timeout.function, depth + 1),
|
|
323 internal_hash (e->event.timeout.object, depth + 1));
|
173
|
324
|
0
|
325 case key_press_event:
|
|
326 return HASH3 (hash, LISP_HASH (e->event.key.keysym),
|
|
327 e->event.key.modifiers);
|
|
328
|
|
329 case button_press_event:
|
|
330 case button_release_event:
|
|
331 return HASH3 (hash, e->event.button.button, e->event.button.modifiers);
|
|
332
|
|
333 case pointer_motion_event:
|
|
334 return HASH3 (hash, e->event.motion.x, e->event.motion.y);
|
|
335
|
|
336 case misc_user_event:
|
282
|
337 return HASH5 (hash, internal_hash (e->event.misc.function, depth + 1),
|
|
338 internal_hash (e->event.misc.object, depth + 1),
|
|
339 e->event.misc.button, e->event.misc.modifiers);
|
|
340
|
0
|
341 case eval_event:
|
|
342 return HASH3 (hash, internal_hash (e->event.eval.function, depth + 1),
|
|
343 internal_hash (e->event.eval.object, depth + 1));
|
|
344
|
|
345 case magic_eval_event:
|
|
346 return HASH3 (hash,
|
|
347 (unsigned long) e->event.magic_eval.internal_function,
|
|
348 internal_hash (e->event.magic_eval.object, depth + 1));
|
|
349
|
|
350 case magic_event:
|
|
351 {
|
183
|
352 struct console *con = XCONSOLE (CDFW_CONSOLE (EVENT_CHANNEL (e)));
|
0
|
353 #ifdef HAVE_X_WINDOWS
|
183
|
354 if (CONSOLE_X_P (con))
|
|
355 return HASH2 (hash, e->event.magic.underlying_x_event.xany.serial);
|
0
|
356 #endif
|
183
|
357 #ifdef HAVE_TTY
|
|
358 if (CONSOLE_TTY_P (con))
|
|
359 return HASH2 (hash, e->event.magic.underlying_tty_event);
|
|
360 #endif
|
213
|
361 #ifdef HAVE_MS_WINDOWS
|
|
362 if (CONSOLE_MSWINDOWS_P (con))
|
249
|
363 return HASH2 (hash, e->event.magic.underlying_mswindows_event);
|
209
|
364 #endif
|
0
|
365 }
|
|
366
|
|
367 case empty_event:
|
|
368 case dead_event:
|
|
369 return hash;
|
|
370
|
|
371 default:
|
|
372 abort ();
|
|
373 }
|
|
374
|
183
|
375 return 0; /* unreached */
|
0
|
376 }
|
|
377
|
243
|
378 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("event", event,
|
|
379 mark_event, print_event, 0, event_equal,
|
|
380 event_hash, struct Lisp_Event);
|
|
381
|
0
|
382
|
189
|
383 DEFUN ("make-event", Fmake_event, 0, 2, 0, /*
|
272
|
384 Return a new event of type TYPE, with properties described by PLIST.
|
213
|
385
|
189
|
386 TYPE is a symbol, either `empty', `key-press', `button-press',
|
282
|
387 `button-release', or `motion'. If TYPE is nil, it
|
213
|
388 defaults to `empty'.
|
|
389
|
|
390 PLIST is a property list, the properties being compatible to those
|
|
391 returned by `event-properties'. The following properties are
|
|
392 allowed:
|
|
393
|
|
394 channel -- The event channel, a frame or a console. For
|
282
|
395 button-press, button-release, motion events,
|
|
396 this must be a frame. For key-press
|
215
|
397 events, it must be a console. If channel is
|
|
398 unspecified, it will be set to the selected frame
|
|
399 or selected console, as appropriate.
|
213
|
400 key -- The event key, a symbol or character. Allowed only for
|
|
401 keypress events.
|
215
|
402 button -- The event button, integer 1, 2 or 3. Allowed for
|
282
|
403 button-press, button-release and misc-user events.
|
213
|
404 modifiers -- The event modifiers, a list of modifier symbols. Allowed
|
215
|
405 for key-press, button-press, button-release, motion and
|
282
|
406 misc-user events.
|
213
|
407 x -- The event X coordinate, an integer. This is relative
|
|
408 to the left of CHANNEL's root window. Allowed for
|
282
|
409 motion, button-press, button-release and misc-user events.
|
213
|
410 y -- The event Y coordinate, an integer. This is relative
|
|
411 to the top of CHANNEL's root window. Allowed for
|
282
|
412 motion, button-press, button-release and misc-user events.
|
213
|
413 timestamp -- The event timestamp, a non-negative integer. Allowed for
|
215
|
414 all types of events. If unspecified, it will be set to 0
|
|
415 by default.
|
213
|
416
|
|
417 For event type `empty', PLIST must be nil.
|
189
|
418 `button-release', or `motion'. If TYPE is left out, it defaults to
|
|
419 `empty'.
|
|
420 PLIST is a list of properties, as returned by `event-properties'. Not
|
|
421 all properties are allowed for all kinds of events, and some are
|
|
422 required.
|
0
|
423
|
213
|
424 WARNING: the event object returned may be a reused one; see the function
|
189
|
425 `deallocate-event'.
|
20
|
426 */
|
189
|
427 (type, plist))
|
0
|
428 {
|
213
|
429 Lisp_Object tail, keyword, value;
|
|
430 Lisp_Object event = Qnil;
|
189
|
431 struct Lisp_Event *e;
|
213
|
432 EMACS_INT coord_x = 0, coord_y = 0;
|
282
|
433 struct gcpro gcpro1;
|
213
|
434
|
282
|
435 GCPRO1 (event);
|
189
|
436
|
|
437 if (NILP (type))
|
|
438 type = Qempty;
|
0
|
439
|
|
440 if (!NILP (Vevent_resource))
|
|
441 {
|
|
442 event = Vevent_resource;
|
|
443 Vevent_resource = XEVENT_NEXT (event);
|
|
444 }
|
|
445 else
|
|
446 {
|
|
447 event = allocate_event ();
|
|
448 }
|
189
|
449 e = XEVENT (event);
|
|
450 zero_event (e);
|
|
451
|
213
|
452 if (EQ (type, Qempty))
|
|
453 {
|
|
454 /* For empty event, we return immediately, without processing
|
|
455 PLIST. In fact, processing PLIST would be wrong, because the
|
|
456 sanitizing process would fill in the properties
|
|
457 (e.g. CHANNEL), which we don't want in empty events. */
|
|
458 e->event_type = empty_event;
|
|
459 if (!NILP (plist))
|
|
460 error ("Cannot set properties of empty event");
|
|
461 UNGCPRO;
|
|
462 return event;
|
|
463 }
|
|
464 else if (EQ (type, Qkey_press))
|
280
|
465 {
|
|
466 e->event_type = key_press_event;
|
|
467 e->event.key.keysym = Qunbound;
|
|
468 }
|
189
|
469 else if (EQ (type, Qbutton_press))
|
|
470 e->event_type = button_press_event;
|
|
471 else if (EQ (type, Qbutton_release))
|
|
472 e->event_type = button_release_event;
|
|
473 else if (EQ (type, Qmotion))
|
|
474 e->event_type = pointer_motion_event;
|
267
|
475 else if (EQ (type, Qmisc_user))
|
|
476 {
|
|
477 e->event_type = misc_user_event;
|
|
478 e->event.eval.function = e->event.eval.object = Qnil;
|
|
479 }
|
189
|
480 else
|
213
|
481 {
|
267
|
482 /* Not allowed: Qprocess, Qtimeout, Qmagic, Qeval, Qmagic_eval. */
|
213
|
483 signal_simple_error ("Invalid event type", type);
|
|
484 }
|
|
485
|
267
|
486 EVENT_CHANNEL (e) = Qnil;
|
|
487
|
213
|
488 plist = Fcopy_sequence (plist);
|
|
489 Fcanonicalize_plist (plist, Qnil);
|
189
|
490
|
272
|
491 #define WRONG_EVENT_TYPE_FOR_PROPERTY(type, prop) \
|
|
492 error_with_frob (prop, "Invalid property for %s event", \
|
|
493 string_data (symbol_name (XSYMBOL (type))))
|
267
|
494
|
213
|
495 EXTERNAL_PROPERTY_LIST_LOOP (tail, keyword, value, plist)
|
189
|
496 {
|
213
|
497 if (EQ (keyword, Qchannel))
|
189
|
498 {
|
213
|
499 if (e->event_type == key_press_event)
|
|
500 {
|
272
|
501 if (!CONSOLEP (value))
|
267
|
502 value = wrong_type_argument (Qconsolep, value);
|
213
|
503 }
|
267
|
504 else if (e->event_type != misc_user_event)
|
213
|
505 {
|
272
|
506 if (!FRAMEP (value))
|
267
|
507 value = wrong_type_argument (Qframep, value);
|
213
|
508 }
|
|
509 EVENT_CHANNEL (e) = value;
|
189
|
510 }
|
213
|
511 else if (EQ (keyword, Qkey))
|
189
|
512 {
|
|
513 if (e->event_type != key_press_event)
|
272
|
514 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword);
|
213
|
515 if (!SYMBOLP (value) && !CHARP (value))
|
|
516 signal_simple_error ("Invalid event key", value);
|
|
517 e->event.key.keysym = value;
|
189
|
518 }
|
213
|
519 else if (EQ (keyword, Qbutton))
|
189
|
520 {
|
|
521 if (e->event_type != button_press_event
|
282
|
522 && e->event_type != button_release_event
|
|
523 && e->event_type != misc_user_event)
|
267
|
524 {
|
272
|
525 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword);
|
267
|
526 }
|
272
|
527 CHECK_NATNUM (value);
|
|
528 check_int_range (XINT (value), 0, 7);
|
282
|
529 if (e->event_type == misc_user_event)
|
|
530 e->event.misc.button = XINT (value);
|
|
531 else
|
|
532 e->event.button.button = XINT (value);
|
189
|
533 }
|
213
|
534 else if (EQ (keyword, Qmodifiers))
|
189
|
535 {
|
267
|
536 Lisp_Object modtail;
|
189
|
537 int modifiers = 0;
|
|
538
|
|
539 if (e->event_type != key_press_event
|
|
540 && e->event_type != button_press_event
|
|
541 && e->event_type != button_release_event
|
282
|
542 && e->event_type != pointer_motion_event
|
|
543 && e->event_type != misc_user_event)
|
272
|
544 {
|
|
545 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword);
|
|
546 }
|
189
|
547
|
213
|
548 EXTERNAL_LIST_LOOP (modtail, value)
|
189
|
549 {
|
267
|
550 Lisp_Object sym = XCAR (modtail);
|
189
|
551 if (EQ (sym, Qcontrol)) modifiers |= MOD_CONTROL;
|
|
552 else if (EQ (sym, Qmeta)) modifiers |= MOD_META;
|
|
553 else if (EQ (sym, Qsuper)) modifiers |= MOD_SUPER;
|
|
554 else if (EQ (sym, Qhyper)) modifiers |= MOD_HYPER;
|
|
555 else if (EQ (sym, Qalt)) modifiers |= MOD_ALT;
|
|
556 else if (EQ (sym, Qsymbol)) modifiers |= MOD_ALT;
|
|
557 else if (EQ (sym, Qshift)) modifiers |= MOD_SHIFT;
|
|
558 else
|
267
|
559 signal_simple_error ("Invalid key modifier", sym);
|
189
|
560 }
|
|
561 if (e->event_type == key_press_event)
|
|
562 e->event.key.modifiers = modifiers;
|
|
563 else if (e->event_type == button_press_event
|
|
564 || e->event_type == button_release_event)
|
|
565 e->event.button.modifiers = modifiers;
|
282
|
566 else if (e->event_type == pointer_motion_event)
|
189
|
567 e->event.motion.modifiers = modifiers;
|
282
|
568 else /* misc_user_event */
|
|
569 e->event.misc.modifiers = modifiers;
|
189
|
570 }
|
213
|
571 else if (EQ (keyword, Qx))
|
189
|
572 {
|
213
|
573 if (e->event_type != pointer_motion_event
|
|
574 && e->event_type != button_press_event
|
282
|
575 && e->event_type != button_release_event
|
|
576 && e->event_type != misc_user_event)
|
213
|
577 {
|
272
|
578 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword);
|
213
|
579 }
|
272
|
580 /* Allow negative values, so we can specify toolbar
|
|
581 positions. */
|
|
582 CHECK_INT (value);
|
213
|
583 coord_x = XINT (value);
|
189
|
584 }
|
213
|
585 else if (EQ (keyword, Qy))
|
189
|
586 {
|
213
|
587 if (e->event_type != pointer_motion_event
|
|
588 && e->event_type != button_press_event
|
282
|
589 && e->event_type != button_release_event
|
|
590 && e->event_type != misc_user_event)
|
213
|
591 {
|
272
|
592 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword);
|
213
|
593 }
|
272
|
594 /* Allow negative values; see above. */
|
|
595 CHECK_INT (value);
|
213
|
596 coord_y = XINT (value);
|
|
597 }
|
|
598 else if (EQ (keyword, Qtimestamp))
|
|
599 {
|
|
600 CHECK_NATNUM (value);
|
|
601 e->timestamp = XINT (value);
|
189
|
602 }
|
267
|
603 else if (EQ (keyword, Qfunction))
|
|
604 {
|
|
605 if (e->event_type != misc_user_event)
|
272
|
606 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword);
|
267
|
607 e->event.eval.function = value;
|
|
608 }
|
|
609 else if (EQ (keyword, Qobject))
|
|
610 {
|
|
611 if (e->event_type != misc_user_event)
|
272
|
612 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword);
|
267
|
613 e->event.eval.object = value;
|
|
614 }
|
189
|
615 else
|
267
|
616 signal_simple_error_2 ("Invalid property", keyword, value);
|
|
617 }
|
189
|
618
|
213
|
619 /* Insert the channel, if missing. */
|
|
620 if (NILP (EVENT_CHANNEL (e)))
|
|
621 {
|
|
622 if (e->event_type == key_press_event)
|
|
623 EVENT_CHANNEL (e) = Vselected_console;
|
272
|
624 else
|
213
|
625 EVENT_CHANNEL (e) = Fselected_frame (Qnil);
|
|
626 }
|
|
627
|
|
628 /* Fevent_properties, Fevent_x_pixel, etc. work with pixels relative
|
|
629 to the frame, so we must adjust accordingly. */
|
|
630 if (e->event_type == pointer_motion_event
|
|
631 || e->event_type == button_press_event
|
|
632 || e->event_type == button_release_event
|
282
|
633 || e->event_type == misc_user_event)
|
213
|
634 {
|
|
635 struct frame *f = XFRAME (EVENT_CHANNEL (e));
|
|
636
|
|
637 coord_x += FRAME_REAL_LEFT_TOOLBAR_WIDTH (f);
|
|
638 coord_y += FRAME_REAL_TOP_TOOLBAR_HEIGHT (f);
|
|
639
|
|
640 if (e->event_type == pointer_motion_event)
|
|
641 {
|
|
642 e->event.motion.x = coord_x;
|
|
643 e->event.motion.y = coord_y;
|
|
644 }
|
|
645 else if (e->event_type == button_press_event
|
282
|
646 || e->event_type == button_release_event)
|
213
|
647 {
|
|
648 e->event.button.x = coord_x;
|
|
649 e->event.button.y = coord_y;
|
|
650 }
|
282
|
651 else if (e->event_type == misc_user_event)
|
|
652 {
|
|
653 e->event.misc.x = coord_x;
|
|
654 e->event.misc.y = coord_y;
|
|
655 }
|
213
|
656 }
|
|
657
|
|
658 /* Finally, do some more validation. */
|
189
|
659 switch (e->event_type)
|
|
660 {
|
|
661 case key_press_event:
|
280
|
662 if (UNBOUNDP (e->event.key.keysym)
|
|
663 || !(SYMBOLP (e->event.key.keysym) || CHARP (e->event.key.keysym)))
|
189
|
664 error ("Undefined key for keypress event");
|
|
665 break;
|
|
666 case button_press_event:
|
|
667 case button_release_event:
|
|
668 if (!e->event.button.button)
|
213
|
669 error ("Undefined button for %s event",
|
|
670 e->event_type == button_press_event
|
282
|
671 ? "buton-press" : "button-release");
|
|
672 break;
|
|
673 case misc_user_event:
|
|
674 if (!e->event.misc.button)
|
|
675 error ("Undefined button for misc-user event");
|
189
|
676 break;
|
|
677 default:
|
|
678 break;
|
|
679 }
|
213
|
680
|
|
681 UNGCPRO;
|
0
|
682 return event;
|
|
683 }
|
|
684
|
20
|
685 DEFUN ("deallocate-event", Fdeallocate_event, 1, 1, 0, /*
|
0
|
686 Allow the given event structure to be reused.
|
|
687 You MUST NOT use this event object after calling this function with it.
|
|
688 You will lose. It is not necessary to call this function, as event
|
|
689 objects are garbage-collected like all other objects; however, it may
|
|
690 be more efficient to explicitly deallocate events when you are sure
|
2
|
691 that it is safe to do so.
|
20
|
692 */
|
|
693 (event))
|
0
|
694 {
|
|
695 CHECK_EVENT (event);
|
|
696
|
|
697 if (XEVENT_TYPE (event) == dead_event)
|
|
698 error ("this event is already deallocated!");
|
|
699
|
|
700 assert (XEVENT_TYPE (event) <= last_event_type);
|
|
701
|
|
702 #if 0
|
173
|
703 {
|
|
704 int i, len;
|
0
|
705
|
173
|
706 if (EQ (event, Vlast_command_event) ||
|
|
707 EQ (event, Vlast_input_event) ||
|
|
708 EQ (event, Vunread_command_event))
|
0
|
709 abort ();
|
173
|
710
|
|
711 len = XVECTOR_LENGTH (Vthis_command_keys);
|
|
712 for (i = 0; i < len; i++)
|
|
713 if (EQ (event, XVECTOR_DATA (Vthis_command_keys) [i]))
|
0
|
714 abort ();
|
153
|
715 if (!NILP (Vrecent_keys_ring))
|
|
716 {
|
173
|
717 int recent_ring_len = XVECTOR_LENGTH (Vrecent_keys_ring);
|
|
718 for (i = 0; i < recent_ring_len; i++)
|
|
719 if (EQ (event, XVECTOR_DATA (Vrecent_keys_ring) [i]))
|
153
|
720 abort ();
|
|
721 }
|
0
|
722 }
|
|
723 #endif /* 0 */
|
|
724
|
|
725 assert (!EQ (event, Vevent_resource));
|
|
726 deinitialize_event (event);
|
|
727 #ifndef ALLOC_NO_POOLS
|
|
728 XSET_EVENT_NEXT (event, Vevent_resource);
|
|
729 Vevent_resource = event;
|
|
730 #endif
|
|
731 return Qnil;
|
|
732 }
|
|
733
|
20
|
734 DEFUN ("copy-event", Fcopy_event, 1, 2, 0, /*
|
0
|
735 Make a copy of the given event object.
|
|
736 If a second argument is given, the first event is copied into the second
|
|
737 and the second is returned. If the second argument is not supplied (or
|
|
738 is nil) then a new event will be made as with `allocate-event.' See also
|
|
739 the function `deallocate-event'.
|
20
|
740 */
|
|
741 (event1, event2))
|
0
|
742 {
|
|
743 CHECK_LIVE_EVENT (event1);
|
|
744 if (NILP (event2))
|
189
|
745 event2 = Fmake_event (Qnil, Qnil);
|
0
|
746 else CHECK_LIVE_EVENT (event2);
|
|
747 if (EQ (event1, event2))
|
|
748 return signal_simple_continuable_error_2
|
|
749 ("copy-event called with `eq' events", event1, event2);
|
|
750
|
|
751 assert (XEVENT_TYPE (event1) <= last_event_type);
|
|
752 assert (XEVENT_TYPE (event2) <= last_event_type);
|
|
753
|
|
754 {
|
|
755 Lisp_Object save_next = XEVENT_NEXT (event2);
|
|
756
|
|
757 *XEVENT (event2) = *XEVENT (event1);
|
|
758 XSET_EVENT_NEXT (event2, save_next);
|
173
|
759 return event2;
|
0
|
760 }
|
|
761 }
|
|
762
|
|
763
|
|
764
|
|
765 /* Given a chain of events (or possibly nil), deallocate them all. */
|
|
766
|
|
767 void
|
|
768 deallocate_event_chain (Lisp_Object event_chain)
|
|
769 {
|
|
770 while (!NILP (event_chain))
|
|
771 {
|
|
772 Lisp_Object next = XEVENT_NEXT (event_chain);
|
|
773 Fdeallocate_event (event_chain);
|
|
774 event_chain = next;
|
|
775 }
|
|
776 }
|
|
777
|
|
778 /* Return the last event in a chain.
|
|
779 NOTE: You cannot pass nil as a value here! The routine will
|
|
780 abort if you do. */
|
|
781
|
|
782 Lisp_Object
|
|
783 event_chain_tail (Lisp_Object event_chain)
|
|
784 {
|
|
785 while (1)
|
|
786 {
|
|
787 Lisp_Object next = XEVENT_NEXT (event_chain);
|
|
788 if (NILP (next))
|
|
789 return event_chain;
|
|
790 event_chain = next;
|
|
791 }
|
|
792 }
|
|
793
|
|
794 /* Enqueue a single event onto the end of a chain of events.
|
|
795 HEAD points to the first event in the chain, TAIL to the last event.
|
|
796 If the chain is empty, both values should be nil. */
|
|
797
|
|
798 void
|
|
799 enqueue_event (Lisp_Object event, Lisp_Object *head, Lisp_Object *tail)
|
|
800 {
|
|
801 assert (NILP (XEVENT_NEXT (event)));
|
|
802 assert (!EQ (*tail, event));
|
|
803
|
|
804 if (!NILP (*tail))
|
|
805 XSET_EVENT_NEXT (*tail, event);
|
|
806 else
|
|
807 *head = event;
|
|
808 *tail = event;
|
|
809
|
|
810 assert (!EQ (event, XEVENT_NEXT (event)));
|
|
811 }
|
|
812
|
|
813 /* Remove an event off the head of a chain of events and return it.
|
|
814 HEAD points to the first event in the chain, TAIL to the last event. */
|
173
|
815
|
0
|
816 Lisp_Object
|
|
817 dequeue_event (Lisp_Object *head, Lisp_Object *tail)
|
|
818 {
|
|
819 Lisp_Object event;
|
|
820
|
|
821 event = *head;
|
|
822 *head = XEVENT_NEXT (event);
|
|
823 XSET_EVENT_NEXT (event, Qnil);
|
|
824 if (NILP (*head))
|
|
825 *tail = Qnil;
|
|
826 return event;
|
|
827 }
|
|
828
|
|
829 /* Enqueue a chain of events (or possibly nil) onto the end of another
|
|
830 chain of events. HEAD points to the first event in the chain being
|
|
831 queued onto, TAIL to the last event. If the chain is empty, both values
|
|
832 should be nil. */
|
|
833
|
|
834 void
|
|
835 enqueue_event_chain (Lisp_Object event_chain, Lisp_Object *head,
|
|
836 Lisp_Object *tail)
|
|
837 {
|
|
838 if (NILP (event_chain))
|
|
839 return;
|
|
840
|
|
841 if (NILP (*head))
|
|
842 {
|
|
843 *head = event_chain;
|
|
844 *tail = event_chain;
|
|
845 }
|
|
846 else
|
|
847 {
|
|
848 XSET_EVENT_NEXT (*tail, event_chain);
|
|
849 *tail = event_chain_tail (event_chain);
|
|
850 }
|
|
851 }
|
|
852
|
|
853 /* Return the number of events (possibly 0) on an event chain. */
|
|
854
|
|
855 int
|
|
856 event_chain_count (Lisp_Object event_chain)
|
|
857 {
|
|
858 Lisp_Object event;
|
|
859 int n = 0;
|
|
860
|
|
861 EVENT_CHAIN_LOOP (event, event_chain)
|
|
862 n++;
|
|
863
|
|
864 return n;
|
|
865 }
|
|
866
|
|
867 /* Find the event before EVENT in an event chain. This aborts
|
|
868 if the event is not in the chain. */
|
|
869
|
|
870 Lisp_Object
|
|
871 event_chain_find_previous (Lisp_Object event_chain, Lisp_Object event)
|
|
872 {
|
|
873 Lisp_Object previous = Qnil;
|
|
874
|
|
875 while (!NILP (event_chain))
|
|
876 {
|
|
877 if (EQ (event_chain, event))
|
|
878 return previous;
|
|
879 previous = event_chain;
|
|
880 event_chain = XEVENT_NEXT (event_chain);
|
|
881 }
|
|
882
|
|
883 abort ();
|
|
884 return Qnil;
|
|
885 }
|
|
886
|
|
887 Lisp_Object
|
|
888 event_chain_nth (Lisp_Object event_chain, int n)
|
|
889 {
|
|
890 Lisp_Object event;
|
|
891 EVENT_CHAIN_LOOP (event, event_chain)
|
|
892 {
|
|
893 if (!n)
|
|
894 return event;
|
|
895 n--;
|
|
896 }
|
|
897 return Qnil;
|
|
898 }
|
|
899
|
|
900 Lisp_Object
|
|
901 copy_event_chain (Lisp_Object event_chain)
|
|
902 {
|
|
903 Lisp_Object new_chain = Qnil;
|
|
904 Lisp_Object new_chain_tail = Qnil;
|
|
905 Lisp_Object event;
|
|
906
|
|
907 EVENT_CHAIN_LOOP (event, event_chain)
|
|
908 {
|
|
909 Lisp_Object copy = Fcopy_event (event, Qnil);
|
|
910 enqueue_event (copy, &new_chain, &new_chain_tail);
|
|
911 }
|
|
912
|
|
913 return new_chain;
|
|
914 }
|
|
915
|
|
916
|
|
917
|
|
918 Lisp_Object QKbackspace, QKtab, QKlinefeed, QKreturn, QKescape,
|
|
919 QKspace, QKdelete;
|
|
920
|
|
921 int
|
|
922 command_event_p (Lisp_Object event)
|
|
923 {
|
|
924 switch (XEVENT_TYPE (event))
|
|
925 {
|
|
926 case key_press_event:
|
|
927 case button_press_event:
|
|
928 case button_release_event:
|
|
929 case misc_user_event:
|
173
|
930 return 1;
|
0
|
931 default:
|
173
|
932 return 0;
|
0
|
933 }
|
|
934 }
|
|
935
|
|
936
|
|
937 void
|
|
938 character_to_event (Emchar c, struct Lisp_Event *event, struct console *con,
|
263
|
939 int use_console_meta_flag, int do_backspace_mapping)
|
0
|
940 {
|
|
941 Lisp_Object k = Qnil;
|
|
942 unsigned int m = 0;
|
|
943 if (event->event_type == dead_event)
|
|
944 error ("character-to-event called with a deallocated event!");
|
|
945
|
70
|
946 #ifndef MULE
|
0
|
947 c &= 255;
|
70
|
948 #endif
|
0
|
949 if (c > 127 && c <= 255)
|
|
950 {
|
|
951 int meta_flag = 1;
|
|
952 if (use_console_meta_flag && CONSOLE_TTY_P (con))
|
|
953 meta_flag = TTY_FLAGS (con).meta_key;
|
|
954 switch (meta_flag)
|
|
955 {
|
|
956 case 0: /* ignore top bit; it's parity */
|
|
957 c -= 128;
|
|
958 break;
|
|
959 case 1: /* top bit is meta */
|
|
960 c -= 128;
|
|
961 m = MOD_META;
|
|
962 break;
|
|
963 default: /* this is a real character */
|
|
964 break;
|
|
965 }
|
|
966 }
|
|
967 if (c < ' ') c += '@', m |= MOD_CONTROL;
|
|
968 if (m & MOD_CONTROL)
|
|
969 {
|
|
970 switch (c)
|
|
971 {
|
|
972 case 'I': k = QKtab; m &= ~MOD_CONTROL; break;
|
|
973 case 'J': k = QKlinefeed; m &= ~MOD_CONTROL; break;
|
|
974 case 'M': k = QKreturn; m &= ~MOD_CONTROL; break;
|
|
975 case '[': k = QKescape; m &= ~MOD_CONTROL; break;
|
259
|
976 default:
|
267
|
977 #if defined(HAVE_TTY)
|
263
|
978 if (do_backspace_mapping &&
|
|
979 CHARP (con->tty_erase_char) &&
|
|
980 c - '@' == XCHAR (con->tty_erase_char))
|
|
981 {
|
|
982 k = QKbackspace;
|
|
983 m &= ~MOD_CONTROL;
|
|
984 }
|
|
985 #endif /* defined(HAVE_TTY) && !defined(__CYGWIN32__) */
|
259
|
986 break;
|
0
|
987 }
|
|
988 if (c >= 'A' && c <= 'Z') c -= 'A'-'a';
|
|
989 }
|
267
|
990 #if defined(HAVE_TTY)
|
263
|
991 else if (do_backspace_mapping &&
|
|
992 CHARP (con->tty_erase_char) && c == XCHAR (con->tty_erase_char))
|
259
|
993 k = QKbackspace;
|
263
|
994 #endif /* defined(HAVE_TTY) && !defined(__CYGWIN32__) */
|
0
|
995 else if (c == 127)
|
|
996 k = QKdelete;
|
|
997 else if (c == ' ')
|
|
998 k = QKspace;
|
173
|
999
|
2
|
1000 event->event_type = key_press_event;
|
|
1001 event->timestamp = 0; /* #### */
|
|
1002 event->channel = make_console (con);
|
|
1003 event->event.key.keysym = (!NILP (k) ? k : make_char (c));
|
|
1004 event->event.key.modifiers = m;
|
0
|
1005 }
|
|
1006
|
|
1007
|
|
1008 /* This variable controls what character name -> character code mapping
|
|
1009 we are using. Window-system-specific code sets this to some symbol,
|
|
1010 and we use that symbol as the plist key to convert keysyms into 8-bit
|
|
1011 codes. In this way one can have several character sets predefined and
|
|
1012 switch them by changing this.
|
|
1013 */
|
|
1014 Lisp_Object Vcharacter_set_property;
|
|
1015
|
|
1016 Emchar
|
|
1017 event_to_character (struct Lisp_Event *event,
|
|
1018 int allow_extra_modifiers,
|
|
1019 int allow_meta,
|
|
1020 int allow_non_ascii)
|
|
1021 {
|
|
1022 Emchar c = 0;
|
|
1023 Lisp_Object code;
|
|
1024
|
|
1025 if (event->event_type != key_press_event)
|
|
1026 {
|
|
1027 if (event->event_type == dead_event) abort ();
|
|
1028 return -1;
|
|
1029 }
|
|
1030 if (!allow_extra_modifiers &&
|
|
1031 event->event.key.modifiers & (MOD_SUPER|MOD_HYPER|MOD_ALT))
|
|
1032 return -1;
|
|
1033 if (CHAR_OR_CHAR_INTP (event->event.key.keysym))
|
|
1034 c = XCHAR_OR_CHAR_INT (event->event.key.keysym);
|
|
1035 else if (!SYMBOLP (event->event.key.keysym))
|
|
1036 abort ();
|
|
1037 else if (allow_non_ascii && !NILP (Vcharacter_set_property)
|
|
1038 /* Allow window-system-specific extensibility of
|
|
1039 keysym->code mapping */
|
|
1040 && CHAR_OR_CHAR_INTP (code = Fget (event->event.key.keysym,
|
|
1041 Vcharacter_set_property,
|
|
1042 Qnil)))
|
|
1043 c = XCHAR_OR_CHAR_INT (code);
|
|
1044 else if (CHAR_OR_CHAR_INTP (code = Fget (event->event.key.keysym,
|
|
1045 Qascii_character, Qnil)))
|
|
1046 c = XCHAR_OR_CHAR_INT (code);
|
|
1047 else
|
|
1048 return -1;
|
|
1049
|
|
1050 if (event->event.key.modifiers & MOD_CONTROL)
|
|
1051 {
|
|
1052 if (c >= 'a' && c <= 'z')
|
|
1053 c -= ('a' - 'A');
|
|
1054 else
|
|
1055 /* reject Control-Shift- keys */
|
|
1056 if (c >= 'A' && c <= 'Z' && !allow_extra_modifiers)
|
|
1057 return -1;
|
173
|
1058
|
0
|
1059 if (c >= '@' && c <= '_')
|
|
1060 c -= '@';
|
|
1061 else if (c == ' ') /* C-space and C-@ are the same. */
|
|
1062 c = 0;
|
|
1063 else
|
|
1064 /* reject keys that can't take Control- modifiers */
|
|
1065 if (! allow_extra_modifiers) return -1;
|
|
1066 }
|
|
1067
|
|
1068 if (event->event.key.modifiers & MOD_META)
|
|
1069 {
|
|
1070 if (! allow_meta) return -1;
|
|
1071 if (c & 0200) return -1; /* don't allow M-oslash (overlap) */
|
70
|
1072 #ifdef MULE
|
|
1073 if (c >= 256) return -1;
|
|
1074 #endif
|
0
|
1075 c |= 0200;
|
|
1076 }
|
|
1077 return c;
|
|
1078 }
|
|
1079
|
20
|
1080 DEFUN ("event-to-character", Fevent_to_character, 1, 4, 0, /*
|
0
|
1081 Return the closest ASCII approximation to the given event object.
|
|
1082 If the event isn't a keypress, this returns nil.
|
|
1083 If the ALLOW-EXTRA-MODIFIERS argument is non-nil, then this is lenient in
|
|
1084 its translation; it will ignore modifier keys other than control and meta,
|
|
1085 and will ignore the shift modifier on those characters which have no
|
|
1086 shifted ASCII equivalent (Control-Shift-A for example, will be mapped to
|
|
1087 the same ASCII code as Control-A).
|
|
1088 If the ALLOW-META argument is non-nil, then the Meta modifier will be
|
|
1089 represented by turning on the high bit of the byte returned; otherwise, nil
|
|
1090 will be returned for events containing the Meta modifier.
|
|
1091 If the ALLOW-NON-ASCII argument is non-nil, then characters which are
|
|
1092 present in the prevailing character set (see the `character-set-property'
|
|
1093 variable) will be returned as their code in that character set, instead of
|
|
1094 the return value being restricted to ASCII.
|
|
1095 Note that specifying both ALLOW-META and ALLOW-NON-ASCII is ambiguous, as
|
|
1096 both use the high bit; `M-x' and `oslash' will be indistinguishable.
|
20
|
1097 */
|
70
|
1098 (event, allow_extra_modifiers, allow_meta, allow_non_ascii))
|
0
|
1099 {
|
|
1100 Emchar c;
|
|
1101 CHECK_LIVE_EVENT (event);
|
|
1102 c = event_to_character (XEVENT (event),
|
|
1103 !NILP (allow_extra_modifiers),
|
|
1104 !NILP (allow_meta),
|
|
1105 !NILP (allow_non_ascii));
|
173
|
1106 return c < 0 ? Qnil : make_char (c);
|
0
|
1107 }
|
|
1108
|
20
|
1109 DEFUN ("character-to-event", Fcharacter_to_event, 1, 4, 0, /*
|
272
|
1110 Convert keystroke CH into an event structure ,replete with bucky bits.
|
|
1111 The keystroke is the first argument, and the event to fill
|
0
|
1112 in is the second. This function contains knowledge about what the codes
|
|
1113 ``mean'' -- for example, the number 9 is converted to the character ``Tab'',
|
|
1114 not the distinct character ``Control-I''.
|
|
1115
|
|
1116 Note that CH (the keystroke specifier) can be an integer, a character,
|
2
|
1117 a symbol such as 'clear, or a list such as '(control backspace).
|
0
|
1118
|
2
|
1119 If the optional second argument is an event, it is modified;
|
|
1120 otherwise, a new event object is created.
|
0
|
1121
|
2
|
1122 Optional third arg CONSOLE is the console to store in the event, and
|
|
1123 defaults to the selected console.
|
0
|
1124
|
|
1125 If CH is an integer or character, the high bit may be interpreted as the
|
2
|
1126 meta key. (This is done for backward compatibility in lots of places.)
|
|
1127 If USE-CONSOLE-META-FLAG is nil, this will always be the case. If
|
|
1128 USE-CONSOLE-META-FLAG is non-nil, the `meta' flag for CONSOLE affects
|
|
1129 whether the high bit is interpreted as a meta key. (See `set-input-mode'.)
|
|
1130 If you don't want this silly meta interpretation done, you should pass
|
|
1131 in a list containing the character.
|
0
|
1132
|
|
1133 Beware that character-to-event and event-to-character are not strictly
|
2
|
1134 inverse functions, since events contain much more information than the
|
|
1135 ASCII character set can encode.
|
20
|
1136 */
|
|
1137 (ch, event, console, use_console_meta_flag))
|
0
|
1138 {
|
|
1139 struct console *con = decode_console (console);
|
|
1140 if (NILP (event))
|
189
|
1141 event = Fmake_event (Qnil, Qnil);
|
0
|
1142 else
|
|
1143 CHECK_LIVE_EVENT (event);
|
|
1144 if (CONSP (ch) || SYMBOLP (ch))
|
|
1145 key_desc_list_to_event (ch, event, 1);
|
|
1146 else
|
|
1147 {
|
|
1148 CHECK_CHAR_COERCE_INT (ch);
|
|
1149 character_to_event (XCHAR (ch), XEVENT (event), con,
|
263
|
1150 !NILP (use_console_meta_flag), 1);
|
0
|
1151 }
|
|
1152 return event;
|
|
1153 }
|
|
1154
|
|
1155 void
|
|
1156 nth_of_key_sequence_as_event (Lisp_Object seq, int n, Lisp_Object event)
|
|
1157 {
|
|
1158 assert (STRINGP (seq) || VECTORP (seq));
|
|
1159 assert (n < XINT (Flength (seq)));
|
|
1160
|
|
1161 if (STRINGP (seq))
|
|
1162 {
|
|
1163 Emchar ch = string_char (XSTRING (seq), n);
|
|
1164 Fcharacter_to_event (make_char (ch), event, Qnil, Qnil);
|
|
1165 }
|
|
1166 else
|
|
1167 {
|
173
|
1168 Lisp_Object keystroke = XVECTOR_DATA (seq)[n];
|
0
|
1169 if (EVENTP (keystroke))
|
|
1170 Fcopy_event (keystroke, event);
|
|
1171 else
|
|
1172 Fcharacter_to_event (keystroke, event, Qnil, Qnil);
|
|
1173 }
|
|
1174 }
|
|
1175
|
|
1176 Lisp_Object
|
|
1177 key_sequence_to_event_chain (Lisp_Object seq)
|
|
1178 {
|
|
1179 int len = XINT (Flength (seq));
|
|
1180 int i;
|
|
1181 Lisp_Object head = Qnil, tail = Qnil;
|
|
1182
|
|
1183 for (i = 0; i < len; i++)
|
|
1184 {
|
189
|
1185 Lisp_Object event = Fmake_event (Qnil, Qnil);
|
0
|
1186 nth_of_key_sequence_as_event (seq, i, event);
|
|
1187 enqueue_event (event, &head, &tail);
|
|
1188 }
|
|
1189
|
|
1190 return head;
|
|
1191 }
|
|
1192
|
|
1193 void
|
|
1194 format_event_object (char *buf, struct Lisp_Event *event, int brief)
|
|
1195 {
|
|
1196 int mouse_p = 0;
|
|
1197 int mod = 0;
|
|
1198 Lisp_Object key;
|
|
1199
|
|
1200 switch (event->event_type)
|
|
1201 {
|
|
1202 case key_press_event:
|
|
1203 {
|
|
1204 mod = event->event.key.modifiers;
|
|
1205 key = event->event.key.keysym;
|
|
1206 /* Hack. */
|
|
1207 if (! brief && CHARP (key) &&
|
|
1208 mod & (MOD_CONTROL | MOD_META | MOD_SUPER | MOD_HYPER))
|
|
1209 {
|
|
1210 int k = XCHAR (key);
|
|
1211 if (k >= 'a' && k <= 'z')
|
|
1212 key = make_char (k - ('a' - 'A'));
|
|
1213 else if (k >= 'A' && k <= 'Z')
|
|
1214 mod |= MOD_SHIFT;
|
|
1215 }
|
|
1216 break;
|
|
1217 }
|
|
1218 case button_release_event:
|
|
1219 mouse_p++;
|
|
1220 /* Fall through */
|
|
1221 case button_press_event:
|
|
1222 {
|
|
1223 mouse_p++;
|
|
1224 mod = event->event.button.modifiers;
|
|
1225 key = make_char (event->event.button.button + '0');
|
|
1226 break;
|
|
1227 }
|
|
1228 case magic_event:
|
|
1229 {
|
183
|
1230 CONST char *name = NULL;
|
0
|
1231
|
|
1232 #ifdef HAVE_X_WINDOWS
|
183
|
1233 {
|
|
1234 Lisp_Object console = CDFW_CONSOLE (EVENT_CHANNEL (event));
|
|
1235 if (CONSOLE_X_P (XCONSOLE (console)))
|
|
1236 name = x_event_name (event->event.magic.underlying_x_event.type);
|
|
1237 }
|
|
1238 #endif /* HAVE_X_WINDOWS */
|
0
|
1239 if (name) strcpy (buf, name);
|
|
1240 else strcpy (buf, "???");
|
|
1241 return;
|
|
1242 }
|
|
1243 case magic_eval_event: strcpy (buf, "magic-eval"); return;
|
183
|
1244 case pointer_motion_event: strcpy (buf, "motion"); return;
|
|
1245 case misc_user_event: strcpy (buf, "misc-user"); return;
|
|
1246 case eval_event: strcpy (buf, "eval"); return;
|
|
1247 case process_event: strcpy (buf, "process"); return;
|
|
1248 case timeout_event: strcpy (buf, "timeout"); return;
|
|
1249 case empty_event: strcpy (buf, "empty"); return;
|
|
1250 case dead_event: strcpy (buf, "DEAD-EVENT"); return;
|
0
|
1251 default:
|
|
1252 abort ();
|
|
1253 }
|
|
1254 #define modprint1(x) { strcpy (buf, (x)); buf += sizeof (x)-1; }
|
|
1255 #define modprint(x,y) { if (brief) modprint1 (y) else modprint1 (x) }
|
|
1256 if (mod & MOD_CONTROL) modprint ("control-", "C-");
|
|
1257 if (mod & MOD_META) modprint ("meta-", "M-");
|
|
1258 if (mod & MOD_SUPER) modprint ("super-", "S-");
|
|
1259 if (mod & MOD_HYPER) modprint ("hyper-", "H-");
|
|
1260 if (mod & MOD_ALT) modprint ("alt-", "A-");
|
|
1261 if (mod & MOD_SHIFT) modprint ("shift-", "Sh-");
|
|
1262 if (mouse_p)
|
|
1263 {
|
|
1264 modprint1 ("button");
|
|
1265 --mouse_p;
|
|
1266 }
|
197
|
1267
|
0
|
1268 #undef modprint
|
|
1269 #undef modprint1
|
|
1270
|
|
1271 if (CHARP (key))
|
|
1272 {
|
|
1273 buf += set_charptr_emchar ((Bufbyte *) buf, XCHAR (key));
|
|
1274 *buf = 0;
|
|
1275 }
|
|
1276 else if (SYMBOLP (key))
|
|
1277 {
|
|
1278 CONST char *str = 0;
|
|
1279 if (brief)
|
|
1280 {
|
|
1281 if (EQ (key, QKlinefeed)) str = "LFD";
|
|
1282 else if (EQ (key, QKtab)) str = "TAB";
|
|
1283 else if (EQ (key, QKreturn)) str = "RET";
|
|
1284 else if (EQ (key, QKescape)) str = "ESC";
|
|
1285 else if (EQ (key, QKdelete)) str = "DEL";
|
|
1286 else if (EQ (key, QKspace)) str = "SPC";
|
|
1287 else if (EQ (key, QKbackspace)) str = "BS";
|
|
1288 }
|
|
1289 if (str)
|
|
1290 {
|
|
1291 int i = strlen (str);
|
|
1292 memcpy (buf, str, i+1);
|
|
1293 str += i;
|
|
1294 }
|
|
1295 else
|
|
1296 {
|
183
|
1297 struct Lisp_String *name = XSYMBOL (key)->name;
|
|
1298 memcpy (buf, string_data (name), string_length (name) + 1);
|
|
1299 str += string_length (name);
|
0
|
1300 }
|
|
1301 }
|
|
1302 else
|
|
1303 abort ();
|
|
1304 if (mouse_p)
|
|
1305 strncpy (buf, "up", 4);
|
|
1306 }
|
|
1307
|
20
|
1308 DEFUN ("eventp", Feventp, 1, 1, 0, /*
|
0
|
1309 True if OBJECT is an event object.
|
20
|
1310 */
|
|
1311 (object))
|
0
|
1312 {
|
149
|
1313 return EVENTP (object) ? Qt : Qnil;
|
0
|
1314 }
|
|
1315
|
20
|
1316 DEFUN ("event-live-p", Fevent_live_p, 1, 1, 0, /*
|
0
|
1317 True if OBJECT is an event object that has not been deallocated.
|
20
|
1318 */
|
|
1319 (object))
|
0
|
1320 {
|
149
|
1321 return EVENTP (object) && XEVENT (object)->event_type != dead_event ?
|
|
1322 Qt : Qnil;
|
0
|
1323 }
|
|
1324
|
|
1325 #if 0 /* debugging functions */
|
|
1326
|
149
|
1327 xxDEFUN ("event-next", Fevent_next, 1, 1, 0, /*
|
0
|
1328 Return the event object's `next' event, or nil if it has none.
|
|
1329 The `next-event' field is changed by calling `set-next-event'.
|
149
|
1330 */
|
|
1331 (event))
|
0
|
1332 {
|
|
1333 struct Lisp_Event *e;
|
|
1334 CHECK_LIVE_EVENT (event);
|
|
1335
|
|
1336 return XEVENT_NEXT (event);
|
|
1337 }
|
|
1338
|
149
|
1339 xxDEFUN ("set-event-next", Fset_event_next, 2, 2, 0, /*
|
0
|
1340 Set the `next event' of EVENT to NEXT-EVENT.
|
|
1341 NEXT-EVENT must be an event object or nil.
|
149
|
1342 */
|
|
1343 (event, next_event))
|
0
|
1344 {
|
|
1345 Lisp_Object ev;
|
|
1346
|
|
1347 CHECK_LIVE_EVENT (event);
|
|
1348 if (NILP (next_event))
|
|
1349 {
|
|
1350 XSET_EVENT_NEXT (event, Qnil);
|
173
|
1351 return Qnil;
|
0
|
1352 }
|
|
1353
|
|
1354 CHECK_LIVE_EVENT (next_event);
|
|
1355
|
|
1356 EVENT_CHAIN_LOOP (ev, XEVENT_NEXT (event))
|
|
1357 {
|
|
1358 QUIT;
|
|
1359 if (EQ (ev, event))
|
173
|
1360 signal_error (Qerror,
|
0
|
1361 list3 (build_string ("Cyclic event-next"),
|
173
|
1362 event,
|
0
|
1363 next_event));
|
|
1364 }
|
|
1365 XSET_EVENT_NEXT (event, next_event);
|
149
|
1366 return next_event;
|
0
|
1367 }
|
|
1368
|
|
1369 #endif /* 0 */
|
|
1370
|
20
|
1371 DEFUN ("event-type", Fevent_type, 1, 1, 0, /*
|
0
|
1372 Return the type of EVENT.
|
|
1373 This will be a symbol; one of
|
|
1374
|
|
1375 key-press A key was pressed.
|
|
1376 button-press A mouse button was pressed.
|
|
1377 button-release A mouse button was released.
|
|
1378 misc-user Some other user action happened; typically, this is
|
|
1379 a menu selection or scrollbar action.
|
|
1380 motion The mouse moved.
|
|
1381 process Input is available from a subprocess.
|
|
1382 timeout A timeout has expired.
|
|
1383 eval This causes a specified action to occur when dispatched.
|
|
1384 magic Some window-system-specific event has occurred.
|
122
|
1385 empty The event has been allocated but not assigned.
|
|
1386
|
20
|
1387 */
|
|
1388 (event))
|
0
|
1389 {
|
|
1390 CHECK_LIVE_EVENT (event);
|
|
1391 switch (XEVENT (event)->event_type)
|
|
1392 {
|
149
|
1393 case key_press_event: return Qkey_press;
|
|
1394 case button_press_event: return Qbutton_press;
|
|
1395 case button_release_event: return Qbutton_release;
|
|
1396 case misc_user_event: return Qmisc_user;
|
|
1397 case pointer_motion_event: return Qmotion;
|
|
1398 case process_event: return Qprocess;
|
|
1399 case timeout_event: return Qtimeout;
|
|
1400 case eval_event: return Qeval;
|
0
|
1401 case magic_event:
|
|
1402 case magic_eval_event:
|
|
1403 return Qmagic;
|
|
1404
|
122
|
1405 case empty_event:
|
|
1406 return Qempty;
|
|
1407
|
0
|
1408 default:
|
|
1409 abort ();
|
|
1410 return Qnil;
|
|
1411 }
|
|
1412 }
|
|
1413
|
20
|
1414 DEFUN ("event-timestamp", Fevent_timestamp, 1, 1, 0, /*
|
149
|
1415 Return the timestamp of the event object EVENT.
|
20
|
1416 */
|
|
1417 (event))
|
0
|
1418 {
|
|
1419 CHECK_LIVE_EVENT (event);
|
|
1420 /* This junk is so that timestamps don't get to be negative, but contain
|
|
1421 as many bits as this particular emacs will allow.
|
|
1422 */
|
|
1423 return make_int (((1L << (VALBITS - 1)) - 1) &
|
|
1424 XEVENT (event)->timestamp);
|
|
1425 }
|
|
1426
|
185
|
1427 #define CHECK_EVENT_TYPE(e,t1,sym) do { \
|
|
1428 CHECK_LIVE_EVENT (e); \
|
0
|
1429 if (XEVENT(e)->event_type != (t1)) \
|
185
|
1430 e = wrong_type_argument ((sym),(e)); \
|
|
1431 } while (0)
|
0
|
1432
|
185
|
1433 #define CHECK_EVENT_TYPE2(e,t1,t2,sym) do { \
|
|
1434 CHECK_LIVE_EVENT (e); \
|
|
1435 if (XEVENT(e)->event_type != (t1) && \
|
|
1436 XEVENT(e)->event_type != (t2)) \
|
|
1437 e = wrong_type_argument ((sym),(e)); \
|
|
1438 } while (0)
|
0
|
1439
|
282
|
1440 #define CHECK_EVENT_TYPE3(e,t1,t2,t3,sym) do { \
|
|
1441 CHECK_LIVE_EVENT (e); \
|
|
1442 if (XEVENT(e)->event_type != (t1) && \
|
|
1443 XEVENT(e)->event_type != (t2) && \
|
|
1444 XEVENT(e)->event_type != (t3)) \
|
|
1445 e = wrong_type_argument ((sym),(e)); \
|
|
1446 } while (0)
|
|
1447
|
20
|
1448 DEFUN ("event-key", Fevent_key, 1, 1, 0, /*
|
149
|
1449 Return the Keysym of the key-press event EVENT.
|
|
1450 This will be a character if the event is associated with one, else a symbol.
|
20
|
1451 */
|
|
1452 (event))
|
0
|
1453 {
|
|
1454 CHECK_EVENT_TYPE (event, key_press_event, Qkey_press_event_p);
|
149
|
1455 return XEVENT (event)->event.key.keysym;
|
0
|
1456 }
|
|
1457
|
20
|
1458 DEFUN ("event-button", Fevent_button, 1, 1, 0, /*
|
149
|
1459 Return the button-number of the given button-press or button-release event.
|
20
|
1460 */
|
|
1461 (event))
|
0
|
1462 {
|
197
|
1463
|
282
|
1464 CHECK_EVENT_TYPE3 (event, button_press_event, button_release_event,
|
|
1465 misc_user_event, Qbutton_event_p);
|
0
|
1466 #ifdef HAVE_WINDOW_SYSTEM
|
282
|
1467 if ( XEVENT (event)->event_type == misc_user_event)
|
|
1468 return make_int (XEVENT (event)->event.misc.button);
|
|
1469 else
|
|
1470 return make_int (XEVENT (event)->event.button.button);
|
0
|
1471 #else /* !HAVE_WINDOW_SYSTEM */
|
|
1472 return Qzero;
|
|
1473 #endif /* !HAVE_WINDOW_SYSTEM */
|
197
|
1474
|
0
|
1475 }
|
|
1476
|
20
|
1477 DEFUN ("event-modifier-bits", Fevent_modifier_bits, 1, 1, 0, /*
|
0
|
1478 Return a number representing the modifier keys which were down
|
183
|
1479 when the given mouse or keyboard event was produced.
|
|
1480 See also the function event-modifiers.
|
20
|
1481 */
|
|
1482 (event))
|
0
|
1483 {
|
|
1484 again:
|
|
1485 CHECK_LIVE_EVENT (event);
|
183
|
1486 switch (XEVENT (event)->event_type)
|
0
|
1487 {
|
183
|
1488 case key_press_event:
|
|
1489 return make_int (XEVENT (event)->event.key.modifiers);
|
|
1490 case button_press_event:
|
|
1491 case button_release_event:
|
|
1492 return make_int (XEVENT (event)->event.button.modifiers);
|
|
1493 case pointer_motion_event:
|
|
1494 return make_int (XEVENT (event)->event.motion.modifiers);
|
282
|
1495 case misc_user_event:
|
|
1496 return make_int (XEVENT (event)->event.misc.modifiers);
|
183
|
1497 default:
|
0
|
1498 event = wrong_type_argument (intern ("key-or-mouse-event-p"), event);
|
|
1499 goto again;
|
|
1500 }
|
|
1501 }
|
|
1502
|
20
|
1503 DEFUN ("event-modifiers", Fevent_modifiers, 1, 1, 0, /*
|
0
|
1504 Return a list of symbols, the names of the modifier keys
|
|
1505 which were down when the given mouse or keyboard event was produced.
|
|
1506 See also the function event-modifier-bits.
|
20
|
1507 */
|
|
1508 (event))
|
0
|
1509 {
|
|
1510 int mod = XINT (Fevent_modifier_bits (event));
|
|
1511 Lisp_Object result = Qnil;
|
|
1512 if (mod & MOD_SHIFT) result = Fcons (Qshift, result);
|
|
1513 if (mod & MOD_ALT) result = Fcons (Qalt, result);
|
|
1514 if (mod & MOD_HYPER) result = Fcons (Qhyper, result);
|
|
1515 if (mod & MOD_SUPER) result = Fcons (Qsuper, result);
|
|
1516 if (mod & MOD_META) result = Fcons (Qmeta, result);
|
|
1517 if (mod & MOD_CONTROL) result = Fcons (Qcontrol, result);
|
|
1518 return result;
|
|
1519 }
|
|
1520
|
|
1521 static int
|
|
1522 event_x_y_pixel_internal (Lisp_Object event, int *x, int *y, int relative)
|
|
1523 {
|
|
1524 struct window *w;
|
|
1525 struct frame *f;
|
|
1526
|
|
1527 if (XEVENT (event)->event_type == pointer_motion_event)
|
|
1528 {
|
|
1529 *x = XEVENT (event)->event.motion.x;
|
|
1530 *y = XEVENT (event)->event.motion.y;
|
|
1531 }
|
|
1532 else if (XEVENT (event)->event_type == button_press_event ||
|
|
1533 XEVENT (event)->event_type == button_release_event)
|
|
1534 {
|
|
1535 *x = XEVENT (event)->event.button.x;
|
|
1536 *y = XEVENT (event)->event.button.y;
|
|
1537 }
|
282
|
1538 else if (XEVENT (event)->event_type == misc_user_event)
|
197
|
1539 {
|
282
|
1540 *x = XEVENT (event)->event.misc.x;
|
|
1541 *y = XEVENT (event)->event.misc.y;
|
197
|
1542 }
|
0
|
1543 else
|
|
1544 return 0;
|
|
1545
|
|
1546 f = XFRAME (EVENT_CHANNEL (XEVENT (event)));
|
|
1547
|
|
1548 if (relative)
|
|
1549 {
|
|
1550 w = find_window_by_pixel_pos (*x, *y, f->root_window);
|
|
1551
|
|
1552 if (!w)
|
|
1553 return 1; /* #### What should really happen here. */
|
|
1554
|
|
1555 *x -= w->pixel_left;
|
|
1556 *y -= w->pixel_top;
|
|
1557 }
|
|
1558 else
|
|
1559 {
|
215
|
1560 *y -= FRAME_REAL_TOP_TOOLBAR_HEIGHT (f) -
|
|
1561 FRAME_REAL_TOP_TOOLBAR_BORDER_WIDTH (f);
|
|
1562 *x -= FRAME_REAL_LEFT_TOOLBAR_WIDTH (f) -
|
|
1563 FRAME_REAL_LEFT_TOOLBAR_BORDER_WIDTH (f);
|
0
|
1564 }
|
|
1565
|
|
1566 return 1;
|
|
1567 }
|
|
1568
|
20
|
1569 DEFUN ("event-window-x-pixel", Fevent_window_x_pixel, 1, 1, 0, /*
|
149
|
1570 Return the X position in pixels of mouse event EVENT.
|
0
|
1571 The value returned is relative to the window the event occurred in.
|
149
|
1572 This will signal an error if the event is not a mouse event.
|
|
1573 See also `mouse-event-p' and `event-x-pixel'.
|
20
|
1574 */
|
|
1575 (event))
|
0
|
1576 {
|
|
1577 int x, y;
|
|
1578
|
|
1579 CHECK_LIVE_EVENT (event);
|
|
1580
|
|
1581 if (!event_x_y_pixel_internal (event, &x, &y, 1))
|
|
1582 return wrong_type_argument (Qmouse_event_p, event);
|
|
1583 else
|
|
1584 return make_int (x);
|
|
1585 }
|
|
1586
|
20
|
1587 DEFUN ("event-window-y-pixel", Fevent_window_y_pixel, 1, 1, 0, /*
|
149
|
1588 Return the Y position in pixels of mouse event EVENT.
|
0
|
1589 The value returned is relative to the window the event occurred in.
|
149
|
1590 This will signal an error if the event is not a mouse event.
|
|
1591 See also `mouse-event-p' and `event-y-pixel'.
|
20
|
1592 */
|
|
1593 (event))
|
0
|
1594 {
|
|
1595 int x, y;
|
|
1596
|
|
1597 CHECK_LIVE_EVENT (event);
|
|
1598
|
|
1599 if (!event_x_y_pixel_internal (event, &x, &y, 1))
|
|
1600 return wrong_type_argument (Qmouse_event_p, event);
|
|
1601 else
|
|
1602 return make_int (y);
|
|
1603 }
|
|
1604
|
20
|
1605 DEFUN ("event-x-pixel", Fevent_x_pixel, 1, 1, 0, /*
|
149
|
1606 Return the X position in pixels of mouse event EVENT.
|
0
|
1607 The value returned is relative to the frame the event occurred in.
|
149
|
1608 This will signal an error if the event is not a mouse event.
|
|
1609 See also `mouse-event-p' and `event-window-x-pixel'.
|
20
|
1610 */
|
|
1611 (event))
|
0
|
1612 {
|
|
1613 int x, y;
|
|
1614
|
|
1615 CHECK_LIVE_EVENT (event);
|
|
1616
|
|
1617 if (!event_x_y_pixel_internal (event, &x, &y, 0))
|
|
1618 return wrong_type_argument (Qmouse_event_p, event);
|
|
1619 else
|
|
1620 return make_int (x);
|
|
1621 }
|
|
1622
|
20
|
1623 DEFUN ("event-y-pixel", Fevent_y_pixel, 1, 1, 0, /*
|
149
|
1624 Return the Y position in pixels of mouse event EVENT.
|
0
|
1625 The value returned is relative to the frame the event occurred in.
|
149
|
1626 This will signal an error if the event is not a mouse event.
|
|
1627 See also `mouse-event-p' `event-window-y-pixel'.
|
20
|
1628 */
|
|
1629 (event))
|
0
|
1630 {
|
|
1631 int x, y;
|
|
1632
|
|
1633 CHECK_LIVE_EVENT (event);
|
|
1634
|
|
1635 if (!event_x_y_pixel_internal (event, &x, &y, 0))
|
|
1636 return wrong_type_argument (Qmouse_event_p, event);
|
|
1637 else
|
|
1638 return make_int (y);
|
|
1639 }
|
|
1640
|
|
1641 /* Given an event, return a value:
|
|
1642
|
|
1643 OVER_TOOLBAR: over one of the 4 frame toolbars
|
|
1644 OVER_MODELINE: over a modeline
|
|
1645 OVER_BORDER: over an internal border
|
|
1646 OVER_NOTHING: over the text area, but not over text
|
|
1647 OVER_OUTSIDE: outside of the frame border
|
|
1648 OVER_TEXT: over text in the text area
|
284
|
1649 OVER_V_DIVIDER: over windows vertical divider
|
0
|
1650
|
|
1651 and return:
|
|
1652
|
|
1653 The X char position in CHAR_X, if not a null pointer.
|
|
1654 The Y char position in CHAR_Y, if not a null pointer.
|
|
1655 (These last two values are relative to the window the event is over.)
|
|
1656 The window it's over in W, if not a null pointer.
|
|
1657 The buffer position it's over in BUFP, if not a null pointer.
|
|
1658 The closest buffer position in CLOSEST, if not a null pointer.
|
|
1659
|
|
1660 OBJ_X, OBJ_Y, OBJ1, and OBJ2 are as in pixel_to_glyph_translation().
|
|
1661 */
|
173
|
1662
|
0
|
1663 static int
|
|
1664 event_pixel_translation (Lisp_Object event, int *char_x, int *char_y,
|
|
1665 int *obj_x, int *obj_y,
|
|
1666 struct window **w, Bufpos *bufp, Bufpos *closest,
|
|
1667 Charcount *modeline_closest,
|
|
1668 Lisp_Object *obj1, Lisp_Object *obj2)
|
|
1669 {
|
|
1670 int pix_x = 0;
|
|
1671 int pix_y = 0;
|
|
1672 int result;
|
272
|
1673 Lisp_Object frame;
|
0
|
1674
|
|
1675 int ret_x, ret_y, ret_obj_x, ret_obj_y;
|
|
1676 struct window *ret_w;
|
|
1677 Bufpos ret_bufp, ret_closest;
|
|
1678 Charcount ret_modeline_closest;
|
|
1679 Lisp_Object ret_obj1, ret_obj2;
|
173
|
1680
|
0
|
1681 CHECK_LIVE_EVENT (event);
|
173
|
1682 frame = XEVENT (event)->channel;
|
|
1683 switch (XEVENT (event)->event_type)
|
0
|
1684 {
|
173
|
1685 case pointer_motion_event :
|
0
|
1686 pix_x = XEVENT (event)->event.motion.x;
|
|
1687 pix_y = XEVENT (event)->event.motion.y;
|
173
|
1688 break;
|
|
1689 case button_press_event :
|
|
1690 case button_release_event :
|
0
|
1691 pix_x = XEVENT (event)->event.button.x;
|
|
1692 pix_y = XEVENT (event)->event.button.y;
|
173
|
1693 break;
|
282
|
1694 case misc_user_event :
|
|
1695 pix_x = XEVENT (event)->event.misc.x;
|
|
1696 pix_y = XEVENT (event)->event.misc.y;
|
197
|
1697 break;
|
173
|
1698 default:
|
|
1699 dead_wrong_type_argument (Qmouse_event_p, event);
|
0
|
1700 }
|
|
1701
|
|
1702 result = pixel_to_glyph_translation (XFRAME (frame), pix_x, pix_y,
|
|
1703 &ret_x, &ret_y, &ret_obj_x, &ret_obj_y,
|
|
1704 &ret_w, &ret_bufp, &ret_closest,
|
|
1705 &ret_modeline_closest,
|
|
1706 &ret_obj1, &ret_obj2);
|
|
1707
|
|
1708 if (result == OVER_NOTHING || result == OVER_OUTSIDE)
|
|
1709 ret_bufp = 0;
|
|
1710 else if (ret_w && NILP (ret_w->buffer))
|
|
1711 /* Why does this happen? (Does it still happen?)
|
|
1712 I guess the window has gotten reused as a non-leaf... */
|
|
1713 ret_w = 0;
|
|
1714
|
|
1715 /* #### pixel_to_glyph_translation() sometimes returns garbage...
|
185
|
1716 The word has type Lisp_Type_Record (presumably meaning `extent') but the
|
0
|
1717 pointer points to random memory, often filled with 0, sometimes not.
|
|
1718 */
|
|
1719 /* #### Chuck, do we still need this crap? */
|
|
1720 if (!NILP (ret_obj1) && !(GLYPHP (ret_obj1)
|
|
1721 #ifdef HAVE_TOOLBARS
|
|
1722 || TOOLBAR_BUTTONP (ret_obj1)
|
|
1723 #endif
|
|
1724 ))
|
|
1725 abort ();
|
173
|
1726 if (!NILP (ret_obj2) && !(EXTENTP (ret_obj2) || CONSP (ret_obj2)))
|
0
|
1727 abort ();
|
|
1728
|
|
1729 if (char_x)
|
|
1730 *char_x = ret_x;
|
|
1731 if (char_y)
|
|
1732 *char_y = ret_y;
|
|
1733 if (obj_x)
|
|
1734 *obj_x = ret_obj_x;
|
|
1735 if (obj_y)
|
|
1736 *obj_y = ret_obj_y;
|
|
1737 if (w)
|
|
1738 *w = ret_w;
|
|
1739 if (bufp)
|
|
1740 *bufp = ret_bufp;
|
|
1741 if (closest)
|
|
1742 *closest = ret_closest;
|
|
1743 if (modeline_closest)
|
|
1744 *modeline_closest = ret_modeline_closest;
|
|
1745 if (obj1)
|
|
1746 *obj1 = ret_obj1;
|
|
1747 if (obj2)
|
|
1748 *obj2 = ret_obj2;
|
|
1749
|
|
1750 return result;
|
|
1751 }
|
|
1752
|
20
|
1753 DEFUN ("event-over-text-area-p", Fevent_over_text_area_p, 1, 1, 0, /*
|
149
|
1754 Return t if the mouse event EVENT occurred over the text area of a window.
|
0
|
1755 The modeline is not considered to be part of the text area.
|
20
|
1756 */
|
|
1757 (event))
|
0
|
1758 {
|
|
1759 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
1760
|
149
|
1761 return result == OVER_TEXT || result == OVER_NOTHING ? Qt : Qnil;
|
0
|
1762 }
|
|
1763
|
20
|
1764 DEFUN ("event-over-modeline-p", Fevent_over_modeline_p, 1, 1, 0, /*
|
149
|
1765 Return t if the mouse event EVENT occurred over the modeline of a window.
|
20
|
1766 */
|
|
1767 (event))
|
0
|
1768 {
|
|
1769 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
1770
|
149
|
1771 return result == OVER_MODELINE ? Qt : Qnil;
|
0
|
1772 }
|
|
1773
|
20
|
1774 DEFUN ("event-over-border-p", Fevent_over_border_p, 1, 1, 0, /*
|
149
|
1775 Return t if the mouse event EVENT occurred over an internal border.
|
20
|
1776 */
|
|
1777 (event))
|
0
|
1778 {
|
|
1779 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
1780
|
149
|
1781 return result == OVER_BORDER ? Qt : Qnil;
|
0
|
1782 }
|
|
1783
|
20
|
1784 DEFUN ("event-over-toolbar-p", Fevent_over_toolbar_p, 1, 1, 0, /*
|
149
|
1785 Return t if the mouse event EVENT occurred over a toolbar.
|
20
|
1786 */
|
|
1787 (event))
|
0
|
1788 {
|
|
1789 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
1790
|
149
|
1791 return result == OVER_TOOLBAR ? Qt : Qnil;
|
0
|
1792 }
|
|
1793
|
284
|
1794 DEFUN ("event-over-vertical-divider-p", Fevent_over_vertical_divider_p, 1, 1, 0, /*
|
|
1795 Return t if the mouse event EVENT occurred over a window divider.
|
|
1796 */
|
|
1797 (event))
|
|
1798 {
|
|
1799 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
1800
|
|
1801 return result == OVER_V_DIVIDER ? Qt : Qnil;
|
|
1802 }
|
|
1803
|
0
|
1804 struct console *
|
|
1805 event_console_or_selected (Lisp_Object event)
|
|
1806 {
|
|
1807 Lisp_Object channel = EVENT_CHANNEL (XEVENT (event));
|
|
1808 Lisp_Object console = CDFW_CONSOLE (channel);
|
|
1809
|
|
1810 if (NILP (console))
|
|
1811 console = Vselected_console;
|
|
1812
|
|
1813 return XCONSOLE (console);
|
|
1814 }
|
|
1815
|
20
|
1816 DEFUN ("event-channel", Fevent_channel, 1, 1, 0, /*
|
149
|
1817 Return the channel that the event EVENT occurred on.
|
0
|
1818 This will be a frame, device, console, or nil for some types
|
|
1819 of events (e.g. eval events).
|
20
|
1820 */
|
|
1821 (event))
|
0
|
1822 {
|
|
1823 CHECK_LIVE_EVENT (event);
|
|
1824 return EVENT_CHANNEL (XEVENT (event));
|
|
1825 }
|
|
1826
|
20
|
1827 DEFUN ("event-window", Fevent_window, 1, 1, 0, /*
|
149
|
1828 Return the window over which mouse event EVENT occurred.
|
0
|
1829 This may be nil if the event occurred in the border or over a toolbar.
|
149
|
1830 The modeline is considered to be within the window it describes.
|
20
|
1831 */
|
|
1832 (event))
|
0
|
1833 {
|
|
1834 struct window *w;
|
|
1835
|
|
1836 event_pixel_translation (event, 0, 0, 0, 0, &w, 0, 0, 0, 0, 0);
|
|
1837
|
|
1838 if (!w)
|
|
1839 return Qnil;
|
|
1840 else
|
|
1841 {
|
149
|
1842 Lisp_Object window;
|
|
1843
|
0
|
1844 XSETWINDOW (window, w);
|
|
1845 return window;
|
|
1846 }
|
|
1847 }
|
|
1848
|
20
|
1849 DEFUN ("event-point", Fevent_point, 1, 1, 0, /*
|
149
|
1850 Return the character position of the mouse event EVENT.
|
0
|
1851 If the event did not occur over a window, or did not occur over text,
|
149
|
1852 then this returns nil. Otherwise, it returns a position in the buffer
|
0
|
1853 visible in the event's window.
|
20
|
1854 */
|
|
1855 (event))
|
0
|
1856 {
|
|
1857 Bufpos bufp;
|
|
1858 struct window *w;
|
|
1859
|
|
1860 event_pixel_translation (event, 0, 0, 0, 0, &w, &bufp, 0, 0, 0, 0);
|
|
1861
|
149
|
1862 return w && bufp ? make_int (bufp) : Qnil;
|
0
|
1863 }
|
|
1864
|
20
|
1865 DEFUN ("event-closest-point", Fevent_closest_point, 1, 1, 0, /*
|
149
|
1866 Return the character position closest to the mouse event EVENT.
|
0
|
1867 If the event did not occur over a window or over text, return the
|
|
1868 closest point to the location of the event. If the Y pixel position
|
|
1869 overlaps a window and the X pixel position is to the left of that
|
|
1870 window, the closest point is the beginning of the line containing the
|
|
1871 Y position. If the Y pixel position overlaps a window and the X pixel
|
|
1872 position is to the right of that window, the closest point is the end
|
|
1873 of the line containing the Y position. If the Y pixel position is
|
149
|
1874 above a window, return 0. If it is below the last character in a window,
|
|
1875 return the value of (window-end).
|
20
|
1876 */
|
|
1877 (event))
|
0
|
1878 {
|
|
1879 Bufpos bufp;
|
|
1880
|
|
1881 event_pixel_translation (event, 0, 0, 0, 0, 0, 0, &bufp, 0, 0, 0);
|
|
1882
|
149
|
1883 return bufp ? make_int (bufp) : Qnil;
|
0
|
1884 }
|
|
1885
|
20
|
1886 DEFUN ("event-x", Fevent_x, 1, 1, 0, /*
|
149
|
1887 Return the X position of the mouse event EVENT in characters.
|
0
|
1888 This is relative to the window the event occurred over.
|
20
|
1889 */
|
|
1890 (event))
|
0
|
1891 {
|
|
1892 int char_x;
|
|
1893
|
|
1894 event_pixel_translation (event, &char_x, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
1895
|
|
1896 return make_int (char_x);
|
|
1897 }
|
|
1898
|
20
|
1899 DEFUN ("event-y", Fevent_y, 1, 1, 0, /*
|
149
|
1900 Return the Y position of the mouse event EVENT in characters.
|
0
|
1901 This is relative to the window the event occurred over.
|
20
|
1902 */
|
|
1903 (event))
|
0
|
1904 {
|
|
1905 int char_y;
|
|
1906
|
|
1907 event_pixel_translation (event, 0, &char_y, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
1908
|
|
1909 return make_int (char_y);
|
|
1910 }
|
|
1911
|
20
|
1912 DEFUN ("event-modeline-position", Fevent_modeline_position, 1, 1, 0, /*
|
0
|
1913 Return the character position in the modeline that EVENT occurred over.
|
|
1914 EVENT should be a mouse event. If EVENT did not occur over a modeline,
|
|
1915 nil is returned. You can determine the actual character that the
|
|
1916 event occurred over by looking in `generated-modeline-string' at the
|
|
1917 returned character position. Note that `generated-modeline-string'
|
|
1918 is buffer-local, and you must use EVENT's buffer when retrieving
|
|
1919 `generated-modeline-string' in order to get accurate results.
|
20
|
1920 */
|
|
1921 (event))
|
0
|
1922 {
|
|
1923 Charcount mbufp;
|
209
|
1924 int where;
|
0
|
1925
|
209
|
1926 where = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, &mbufp, 0, 0);
|
0
|
1927
|
209
|
1928 return (mbufp < 0 || where != OVER_MODELINE) ? Qnil : make_int (mbufp);
|
0
|
1929 }
|
|
1930
|
20
|
1931 DEFUN ("event-glyph", Fevent_glyph, 1, 1, 0, /*
|
149
|
1932 Return the glyph that the mouse event EVENT occurred over, or nil.
|
20
|
1933 */
|
|
1934 (event))
|
0
|
1935 {
|
|
1936 Lisp_Object glyph;
|
|
1937 struct window *w;
|
|
1938
|
|
1939 event_pixel_translation (event, 0, 0, 0, 0, &w, 0, 0, 0, &glyph, 0);
|
|
1940
|
149
|
1941 return w && GLYPHP (glyph) ? glyph : Qnil;
|
0
|
1942 }
|
|
1943
|
20
|
1944 DEFUN ("event-glyph-extent", Fevent_glyph_extent, 1, 1, 0, /*
|
149
|
1945 Return the extent of the glyph that the mouse event EVENT occurred over.
|
0
|
1946 If the event did not occur over a glyph, nil is returned.
|
20
|
1947 */
|
|
1948 (event))
|
0
|
1949 {
|
|
1950 Lisp_Object extent;
|
|
1951 struct window *w;
|
|
1952
|
|
1953 event_pixel_translation (event, 0, 0, 0, 0, &w, 0, 0, 0, 0, &extent);
|
|
1954
|
149
|
1955 return w && EXTENTP (extent) ? extent : Qnil;
|
0
|
1956 }
|
|
1957
|
20
|
1958 DEFUN ("event-glyph-x-pixel", Fevent_glyph_x_pixel, 1, 1, 0, /*
|
0
|
1959 Return the X pixel position of EVENT relative to the glyph it occurred over.
|
|
1960 EVENT should be a mouse event. If the event did not occur over a glyph,
|
|
1961 nil is returned.
|
20
|
1962 */
|
|
1963 (event))
|
0
|
1964 {
|
|
1965 Lisp_Object extent;
|
|
1966 struct window *w;
|
|
1967 int obj_x;
|
|
1968
|
|
1969 event_pixel_translation (event, 0, 0, &obj_x, 0, &w, 0, 0, 0, 0, &extent);
|
|
1970
|
149
|
1971 return w && EXTENTP (extent) ? make_int (obj_x) : Qnil;
|
0
|
1972 }
|
|
1973
|
20
|
1974 DEFUN ("event-glyph-y-pixel", Fevent_glyph_y_pixel, 1, 1, 0, /*
|
0
|
1975 Return the Y pixel position of EVENT relative to the glyph it occurred over.
|
|
1976 EVENT should be a mouse event. If the event did not occur over a glyph,
|
|
1977 nil is returned.
|
20
|
1978 */
|
|
1979 (event))
|
0
|
1980 {
|
|
1981 Lisp_Object extent;
|
|
1982 struct window *w;
|
|
1983 int obj_y;
|
|
1984
|
|
1985 event_pixel_translation (event, 0, 0, 0, &obj_y, &w, 0, 0, 0, 0, &extent);
|
|
1986
|
149
|
1987 return w && EXTENTP (extent) ? make_int (obj_y) : Qnil;
|
0
|
1988 }
|
|
1989
|
20
|
1990 DEFUN ("event-toolbar-button", Fevent_toolbar_button, 1, 1, 0, /*
|
149
|
1991 Return the toolbar button that the mouse event EVENT occurred over.
|
|
1992 If the event did not occur over a toolbar button, nil is returned.
|
20
|
1993 */
|
|
1994 (event))
|
0
|
1995 {
|
|
1996 #ifdef HAVE_TOOLBARS
|
|
1997 Lisp_Object button;
|
|
1998
|
149
|
1999 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, &button, 0);
|
0
|
2000
|
149
|
2001 return result == OVER_TOOLBAR && TOOLBAR_BUTTONP (button) ? button : Qnil;
|
|
2002 #else
|
272
|
2003 return Qnil;
|
0
|
2004 #endif
|
|
2005 }
|
|
2006
|
20
|
2007 DEFUN ("event-process", Fevent_process, 1, 1, 0, /*
|
0
|
2008 Return the process of the given process-output event.
|
20
|
2009 */
|
|
2010 (event))
|
0
|
2011 {
|
|
2012 CHECK_EVENT_TYPE (event, process_event, Qprocess_event_p);
|
149
|
2013 return XEVENT (event)->event.process.process;
|
0
|
2014 }
|
|
2015
|
20
|
2016 DEFUN ("event-function", Fevent_function, 1, 1, 0, /*
|
0
|
2017 Return the callback function of EVENT.
|
|
2018 EVENT should be a timeout, misc-user, or eval event.
|
20
|
2019 */
|
|
2020 (event))
|
0
|
2021 {
|
272
|
2022 again:
|
0
|
2023 CHECK_LIVE_EVENT (event);
|
|
2024 switch (XEVENT (event)->event_type)
|
|
2025 {
|
|
2026 case timeout_event:
|
173
|
2027 return XEVENT (event)->event.timeout.function;
|
0
|
2028 case misc_user_event:
|
282
|
2029 return XEVENT (event)->event.misc.function;
|
0
|
2030 case eval_event:
|
173
|
2031 return XEVENT (event)->event.eval.function;
|
0
|
2032 default:
|
272
|
2033 event = wrong_type_argument (intern ("timeout-or-eval-event-p"), event);
|
|
2034 goto again;
|
0
|
2035 }
|
|
2036 }
|
|
2037
|
20
|
2038 DEFUN ("event-object", Fevent_object, 1, 1, 0, /*
|
0
|
2039 Return the callback function argument of EVENT.
|
|
2040 EVENT should be a timeout, misc-user, or eval event.
|
20
|
2041 */
|
|
2042 (event))
|
0
|
2043 {
|
|
2044 again:
|
|
2045 CHECK_LIVE_EVENT (event);
|
|
2046 switch (XEVENT (event)->event_type)
|
|
2047 {
|
|
2048 case timeout_event:
|
173
|
2049 return XEVENT (event)->event.timeout.object;
|
0
|
2050 case misc_user_event:
|
282
|
2051 return XEVENT (event)->event.misc.object;
|
0
|
2052 case eval_event:
|
173
|
2053 return XEVENT (event)->event.eval.object;
|
0
|
2054 default:
|
|
2055 event = wrong_type_argument (intern ("timeout-or-eval-event-p"), event);
|
|
2056 goto again;
|
|
2057 }
|
|
2058 }
|
|
2059
|
20
|
2060 DEFUN ("event-properties", Fevent_properties, 1, 1, 0, /*
|
0
|
2061 Return a list of all of the properties of EVENT.
|
|
2062 This is in the form of a property list (alternating keyword/value pairs).
|
20
|
2063 */
|
|
2064 (event))
|
0
|
2065 {
|
|
2066 Lisp_Object props = Qnil;
|
|
2067 struct Lisp_Event *e;
|
|
2068 struct gcpro gcpro1;
|
|
2069
|
|
2070 CHECK_LIVE_EVENT (event);
|
|
2071 e = XEVENT (event);
|
|
2072 GCPRO1 (props);
|
|
2073
|
272
|
2074 props = cons3 (Qtimestamp, Fevent_timestamp (event), props);
|
0
|
2075
|
|
2076 switch (e->event_type)
|
|
2077 {
|
|
2078 case process_event:
|
272
|
2079 props = cons3 (Qprocess, e->event.process.process, props);
|
0
|
2080 break;
|
173
|
2081
|
0
|
2082 case timeout_event:
|
272
|
2083 props = cons3 (Qobject, Fevent_object (event), props);
|
|
2084 props = cons3 (Qfunction, Fevent_function (event), props);
|
|
2085 props = cons3 (Qid, make_int (e->event.timeout.id_number), props);
|
0
|
2086 break;
|
|
2087
|
|
2088 case key_press_event:
|
272
|
2089 props = cons3 (Qmodifiers, Fevent_modifiers (event), props);
|
|
2090 props = cons3 (Qkey, Fevent_key (event), props);
|
0
|
2091 break;
|
|
2092
|
|
2093 case button_press_event:
|
|
2094 case button_release_event:
|
272
|
2095 props = cons3 (Qy, Fevent_y_pixel (event), props);
|
|
2096 props = cons3 (Qx, Fevent_x_pixel (event), props);
|
|
2097 props = cons3 (Qmodifiers, Fevent_modifiers (event), props);
|
|
2098 props = cons3 (Qbutton, Fevent_button (event), props);
|
0
|
2099 break;
|
|
2100
|
|
2101 case pointer_motion_event:
|
272
|
2102 props = cons3 (Qmodifiers, Fevent_modifiers (event), props);
|
|
2103 props = cons3 (Qy, Fevent_y_pixel (event), props);
|
|
2104 props = cons3 (Qx, Fevent_x_pixel (event), props);
|
0
|
2105 break;
|
|
2106
|
|
2107 case misc_user_event:
|
282
|
2108 props = cons3 (Qobject, Fevent_object (event), props);
|
|
2109 props = cons3 (Qfunction, Fevent_function (event), props);
|
|
2110 props = cons3 (Qy, Fevent_y_pixel (event), props);
|
|
2111 props = cons3 (Qx, Fevent_x_pixel (event), props);
|
|
2112 props = cons3 (Qmodifiers, Fevent_modifiers (event), props);
|
|
2113 props = cons3 (Qbutton, Fevent_button (event), props);
|
|
2114 break;
|
|
2115
|
0
|
2116 case eval_event:
|
272
|
2117 props = cons3 (Qobject, Fevent_object (event), props);
|
|
2118 props = cons3 (Qfunction, Fevent_function (event), props);
|
0
|
2119 break;
|
|
2120
|
|
2121 case magic_eval_event:
|
|
2122 case magic_event:
|
149
|
2123 break;
|
|
2124
|
122
|
2125 case empty_event:
|
149
|
2126 RETURN_UNGCPRO (Qnil);
|
0
|
2127 break;
|
|
2128
|
|
2129 default:
|
|
2130 abort ();
|
|
2131 break; /* not reached; warning suppression */
|
|
2132 }
|
|
2133
|
272
|
2134 props = cons3 (Qchannel, Fevent_channel (event), props);
|
0
|
2135 UNGCPRO;
|
|
2136
|
|
2137 return props;
|
|
2138 }
|
|
2139
|
|
2140
|
|
2141 /************************************************************************/
|
|
2142 /* initialization */
|
|
2143 /************************************************************************/
|
|
2144
|
|
2145 void
|
|
2146 syms_of_events (void)
|
|
2147 {
|
20
|
2148 DEFSUBR (Fcharacter_to_event);
|
|
2149 DEFSUBR (Fevent_to_character);
|
0
|
2150
|
20
|
2151 DEFSUBR (Fmake_event);
|
|
2152 DEFSUBR (Fdeallocate_event);
|
|
2153 DEFSUBR (Fcopy_event);
|
|
2154 DEFSUBR (Feventp);
|
|
2155 DEFSUBR (Fevent_live_p);
|
|
2156 DEFSUBR (Fevent_type);
|
|
2157 DEFSUBR (Fevent_properties);
|
0
|
2158
|
20
|
2159 DEFSUBR (Fevent_timestamp);
|
|
2160 DEFSUBR (Fevent_key);
|
|
2161 DEFSUBR (Fevent_button);
|
|
2162 DEFSUBR (Fevent_modifier_bits);
|
|
2163 DEFSUBR (Fevent_modifiers);
|
|
2164 DEFSUBR (Fevent_x_pixel);
|
|
2165 DEFSUBR (Fevent_y_pixel);
|
|
2166 DEFSUBR (Fevent_window_x_pixel);
|
|
2167 DEFSUBR (Fevent_window_y_pixel);
|
|
2168 DEFSUBR (Fevent_over_text_area_p);
|
|
2169 DEFSUBR (Fevent_over_modeline_p);
|
|
2170 DEFSUBR (Fevent_over_border_p);
|
|
2171 DEFSUBR (Fevent_over_toolbar_p);
|
284
|
2172 DEFSUBR (Fevent_over_vertical_divider_p);
|
20
|
2173 DEFSUBR (Fevent_channel);
|
|
2174 DEFSUBR (Fevent_window);
|
|
2175 DEFSUBR (Fevent_point);
|
|
2176 DEFSUBR (Fevent_closest_point);
|
|
2177 DEFSUBR (Fevent_x);
|
|
2178 DEFSUBR (Fevent_y);
|
|
2179 DEFSUBR (Fevent_modeline_position);
|
|
2180 DEFSUBR (Fevent_glyph);
|
|
2181 DEFSUBR (Fevent_glyph_extent);
|
|
2182 DEFSUBR (Fevent_glyph_x_pixel);
|
|
2183 DEFSUBR (Fevent_glyph_y_pixel);
|
|
2184 DEFSUBR (Fevent_toolbar_button);
|
|
2185 DEFSUBR (Fevent_process);
|
|
2186 DEFSUBR (Fevent_function);
|
|
2187 DEFSUBR (Fevent_object);
|
0
|
2188
|
|
2189 defsymbol (&Qeventp, "eventp");
|
|
2190 defsymbol (&Qevent_live_p, "event-live-p");
|
|
2191 defsymbol (&Qkey_press_event_p, "key-press-event-p");
|
|
2192 defsymbol (&Qbutton_event_p, "button-event-p");
|
|
2193 defsymbol (&Qmouse_event_p, "mouse-event-p");
|
|
2194 defsymbol (&Qprocess_event_p, "process-event-p");
|
|
2195 defsymbol (&Qkey_press, "key-press");
|
|
2196 defsymbol (&Qbutton_press, "button-press");
|
|
2197 defsymbol (&Qbutton_release, "button-release");
|
|
2198 defsymbol (&Qmisc_user, "misc-user");
|
|
2199 defsymbol (&Qascii_character, "ascii-character");
|
|
2200 }
|
|
2201
|
|
2202 void
|
|
2203 vars_of_events (void)
|
|
2204 {
|
|
2205 DEFVAR_LISP ("character-set-property", &Vcharacter_set_property /*
|
|
2206 A symbol used to look up the 8-bit character of a keysym.
|
|
2207 To convert a keysym symbol to an 8-bit code, as when that key is
|
|
2208 bound to self-insert-command, we will look up the property that this
|
|
2209 variable names on the property list of the keysym-symbol. The window-
|
|
2210 system-specific code will set up appropriate properties and set this
|
|
2211 variable.
|
|
2212 */ );
|
|
2213 Vcharacter_set_property = Qnil;
|
|
2214
|
|
2215 Vevent_resource = Qnil;
|
|
2216
|
|
2217 QKbackspace = KEYSYM ("backspace");
|
|
2218 QKtab = KEYSYM ("tab");
|
|
2219 QKlinefeed = KEYSYM ("linefeed");
|
|
2220 QKreturn = KEYSYM ("return");
|
|
2221 QKescape = KEYSYM ("escape");
|
|
2222 QKspace = KEYSYM ("space");
|
|
2223 QKdelete = KEYSYM ("delete");
|
|
2224
|
|
2225 staticpro (&QKbackspace);
|
|
2226 staticpro (&QKtab);
|
|
2227 staticpro (&QKlinefeed);
|
|
2228 staticpro (&QKreturn);
|
|
2229 staticpro (&QKescape);
|
|
2230 staticpro (&QKspace);
|
|
2231 staticpro (&QKdelete);
|
|
2232 }
|