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