Mercurial > hg > xemacs-beta
comparison src/events.c @ 440:8de8e3f6228a r21-2-28
Import from CVS: tag r21-2-28
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:33:38 +0200 |
parents | 84b14dcb0985 |
children | abe6d1db359e |
comparison
equal
deleted
inserted
replaced
439:357dd071b03c | 440:8de8e3f6228a |
---|---|
79 /* Make sure we lose quickly if we try to use this event */ | 79 /* Make sure we lose quickly if we try to use this event */ |
80 static void | 80 static void |
81 deinitialize_event (Lisp_Object ev) | 81 deinitialize_event (Lisp_Object ev) |
82 { | 82 { |
83 int i; | 83 int i; |
84 struct Lisp_Event *event = XEVENT (ev); | 84 Lisp_Event *event = XEVENT (ev); |
85 | 85 |
86 for (i = 0; i < (int) (sizeof (struct Lisp_Event) / sizeof (int)); i++) | 86 for (i = 0; i < (int) (sizeof (Lisp_Event) / sizeof (int)); i++) |
87 ((int *) event) [i] = 0xdeadbeef; | 87 ((int *) event) [i] = 0xdeadbeef; |
88 event->event_type = dead_event; | 88 event->event_type = dead_event; |
89 event->channel = Qnil; | 89 event->channel = Qnil; |
90 set_lheader_implementation (&(event->lheader), &lrecord_event); | 90 set_lheader_implementation (&(event->lheader), &lrecord_event); |
91 XSET_EVENT_NEXT (ev, Qnil); | 91 XSET_EVENT_NEXT (ev, Qnil); |
92 } | 92 } |
93 | 93 |
94 /* Set everything to zero or nil so that it's predictable. */ | 94 /* Set everything to zero or nil so that it's predictable. */ |
95 void | 95 void |
96 zero_event (struct Lisp_Event *e) | 96 zero_event (Lisp_Event *e) |
97 { | 97 { |
98 xzero (*e); | 98 xzero (*e); |
99 set_lheader_implementation (&(e->lheader), &lrecord_event); | 99 set_lheader_implementation (&(e->lheader), &lrecord_event); |
100 e->event_type = empty_event; | 100 e->event_type = empty_event; |
101 e->next = Qnil; | 101 e->next = Qnil; |
103 } | 103 } |
104 | 104 |
105 static Lisp_Object | 105 static Lisp_Object |
106 mark_event (Lisp_Object obj) | 106 mark_event (Lisp_Object obj) |
107 { | 107 { |
108 struct Lisp_Event *event = XEVENT (obj); | 108 Lisp_Event *event = XEVENT (obj); |
109 | 109 |
110 switch (event->event_type) | 110 switch (event->event_type) |
111 { | 111 { |
112 case key_press_event: | 112 case key_press_event: |
113 mark_object (event->event.key.keysym); | 113 mark_object (event->event.key.keysym); |
219 } | 219 } |
220 | 220 |
221 static int | 221 static int |
222 event_equal (Lisp_Object obj1, Lisp_Object obj2, int depth) | 222 event_equal (Lisp_Object obj1, Lisp_Object obj2, int depth) |
223 { | 223 { |
224 struct Lisp_Event *e1 = XEVENT (obj1); | 224 Lisp_Event *e1 = XEVENT (obj1); |
225 struct Lisp_Event *e2 = XEVENT (obj2); | 225 Lisp_Event *e2 = XEVENT (obj2); |
226 | 226 |
227 if (e1->event_type != e2->event_type) return 0; | 227 if (e1->event_type != e2->event_type) return 0; |
228 if (!EQ (e1->channel, e2->channel)) return 0; | 228 if (!EQ (e1->channel, e2->channel)) return 0; |
229 /* if (e1->timestamp != e2->timestamp) return 0; */ | 229 /* if (e1->timestamp != e2->timestamp) return 0; */ |
230 switch (e1->event_type) | 230 switch (e1->event_type) |
291 #endif | 291 #endif |
292 #ifdef HAVE_MS_WINDOWS | 292 #ifdef HAVE_MS_WINDOWS |
293 if (CONSOLE_MSWINDOWS_P (con)) | 293 if (CONSOLE_MSWINDOWS_P (con)) |
294 return (!memcmp(&e1->event.magic.underlying_mswindows_event, | 294 return (!memcmp(&e1->event.magic.underlying_mswindows_event, |
295 &e2->event.magic.underlying_mswindows_event, | 295 &e2->event.magic.underlying_mswindows_event, |
296 sizeof(union magic_data))); | 296 sizeof (union magic_data))); |
297 #endif | 297 #endif |
298 abort (); | |
298 return 1; /* not reached */ | 299 return 1; /* not reached */ |
299 } | 300 } |
300 | 301 |
301 case empty_event: /* Empty and deallocated events are equal. */ | 302 case empty_event: /* Empty and deallocated events are equal. */ |
302 case dead_event: | 303 case dead_event: |
305 } | 306 } |
306 | 307 |
307 static unsigned long | 308 static unsigned long |
308 event_hash (Lisp_Object obj, int depth) | 309 event_hash (Lisp_Object obj, int depth) |
309 { | 310 { |
310 struct Lisp_Event *e = XEVENT (obj); | 311 Lisp_Event *e = XEVENT (obj); |
311 unsigned long hash; | 312 unsigned long hash; |
312 | 313 |
313 hash = HASH2 (e->event_type, LISP_HASH (e->channel)); | 314 hash = HASH2 (e->event_type, LISP_HASH (e->channel)); |
314 switch (e->event_type) | 315 switch (e->event_type) |
315 { | 316 { |
358 #endif | 359 #endif |
359 #ifdef HAVE_MS_WINDOWS | 360 #ifdef HAVE_MS_WINDOWS |
360 if (CONSOLE_MSWINDOWS_P (con)) | 361 if (CONSOLE_MSWINDOWS_P (con)) |
361 return HASH2 (hash, e->event.magic.underlying_mswindows_event); | 362 return HASH2 (hash, e->event.magic.underlying_mswindows_event); |
362 #endif | 363 #endif |
364 abort (); | |
365 return 0; | |
363 } | 366 } |
364 | 367 |
365 case empty_event: | 368 case empty_event: |
366 case dead_event: | 369 case dead_event: |
367 return hash; | 370 return hash; |
373 return 0; /* unreached */ | 376 return 0; /* unreached */ |
374 } | 377 } |
375 | 378 |
376 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("event", event, | 379 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("event", event, |
377 mark_event, print_event, 0, event_equal, | 380 mark_event, print_event, 0, event_equal, |
378 event_hash, 0, struct Lisp_Event); | 381 event_hash, 0, Lisp_Event); |
379 | 382 |
380 | 383 |
381 DEFUN ("make-event", Fmake_event, 0, 2, 0, /* | 384 DEFUN ("make-event", Fmake_event, 0, 2, 0, /* |
382 Return a new event of type TYPE, with properties described by PLIST. | 385 Return a new event of type TYPE, with properties described by PLIST. |
383 | 386 |
426 */ | 429 */ |
427 (type, plist)) | 430 (type, plist)) |
428 { | 431 { |
429 Lisp_Object tail, keyword, value; | 432 Lisp_Object tail, keyword, value; |
430 Lisp_Object event = Qnil; | 433 Lisp_Object event = Qnil; |
431 struct Lisp_Event *e; | 434 Lisp_Event *e; |
432 EMACS_INT coord_x = 0, coord_y = 0; | 435 EMACS_INT coord_x = 0, coord_y = 0; |
433 struct gcpro gcpro1; | 436 struct gcpro gcpro1; |
434 | 437 |
435 GCPRO1 (event); | 438 GCPRO1 (event); |
436 | 439 |
968 } | 971 } |
969 } | 972 } |
970 | 973 |
971 | 974 |
972 void | 975 void |
973 character_to_event (Emchar c, struct Lisp_Event *event, struct console *con, | 976 character_to_event (Emchar c, Lisp_Event *event, struct console *con, |
974 int use_console_meta_flag, int do_backspace_mapping) | 977 int use_console_meta_flag, int do_backspace_mapping) |
975 { | 978 { |
976 Lisp_Object k = Qnil; | 979 Lisp_Object k = Qnil; |
977 unsigned int m = 0; | 980 unsigned int m = 0; |
978 if (event->event_type == dead_event) | 981 if (event->event_type == dead_event) |
1037 event->channel = make_console (con); | 1040 event->channel = make_console (con); |
1038 event->event.key.keysym = (!NILP (k) ? k : make_char (c)); | 1041 event->event.key.keysym = (!NILP (k) ? k : make_char (c)); |
1039 event->event.key.modifiers = m; | 1042 event->event.key.modifiers = m; |
1040 } | 1043 } |
1041 | 1044 |
1042 | |
1043 /* This variable controls what character name -> character code mapping | 1045 /* This variable controls what character name -> character code mapping |
1044 we are using. Window-system-specific code sets this to some symbol, | 1046 we are using. Window-system-specific code sets this to some symbol, |
1045 and we use that symbol as the plist key to convert keysyms into 8-bit | 1047 and we use that symbol as the plist key to convert keysyms into 8-bit |
1046 codes. In this way one can have several character sets predefined and | 1048 codes. In this way one can have several character sets predefined and |
1047 switch them by changing this. | 1049 switch them by changing this. |
1050 | |
1051 #### This is utterly bogus and should be removed. | |
1048 */ | 1052 */ |
1049 Lisp_Object Vcharacter_set_property; | 1053 Lisp_Object Vcharacter_set_property; |
1050 | 1054 |
1051 Emchar | 1055 Emchar |
1052 event_to_character (struct Lisp_Event *event, | 1056 event_to_character (Lisp_Event *event, |
1053 int allow_extra_modifiers, | 1057 int allow_extra_modifiers, |
1054 int allow_meta, | 1058 int allow_meta, |
1055 int allow_non_ascii) | 1059 int allow_non_ascii) |
1056 { | 1060 { |
1057 Emchar c = 0; | 1061 Emchar c = 0; |
1224 | 1228 |
1225 return head; | 1229 return head; |
1226 } | 1230 } |
1227 | 1231 |
1228 void | 1232 void |
1229 format_event_object (char *buf, struct Lisp_Event *event, int brief) | 1233 format_event_object (char *buf, Lisp_Event *event, int brief) |
1230 { | 1234 { |
1231 int mouse_p = 0; | 1235 int mouse_p = 0; |
1232 int mod = 0; | 1236 int mod = 0; |
1233 Lisp_Object key; | 1237 Lisp_Object key; |
1234 | 1238 |
1327 memcpy (buf, str, i+1); | 1331 memcpy (buf, str, i+1); |
1328 str += i; | 1332 str += i; |
1329 } | 1333 } |
1330 else | 1334 else |
1331 { | 1335 { |
1332 struct Lisp_String *name = XSYMBOL (key)->name; | 1336 Lisp_String *name = XSYMBOL (key)->name; |
1333 memcpy (buf, string_data (name), string_length (name) + 1); | 1337 memcpy (buf, string_data (name), string_length (name) + 1); |
1334 str += string_length (name); | 1338 str += string_length (name); |
1335 } | 1339 } |
1336 } | 1340 } |
1337 else | 1341 else |
1363 Return the event object's `next' event, or nil if it has none. | 1367 Return the event object's `next' event, or nil if it has none. |
1364 The `next-event' field is changed by calling `set-next-event'. | 1368 The `next-event' field is changed by calling `set-next-event'. |
1365 */ | 1369 */ |
1366 (event)) | 1370 (event)) |
1367 { | 1371 { |
1368 struct Lisp_Event *e; | 1372 Lisp_Event *e; |
1369 CHECK_LIVE_EVENT (event); | 1373 CHECK_LIVE_EVENT (event); |
1370 | 1374 |
1371 return XEVENT_NEXT (event); | 1375 return XEVENT_NEXT (event); |
1372 } | 1376 } |
1373 | 1377 |
2103 This is in the form of a property list (alternating keyword/value pairs). | 2107 This is in the form of a property list (alternating keyword/value pairs). |
2104 */ | 2108 */ |
2105 (event)) | 2109 (event)) |
2106 { | 2110 { |
2107 Lisp_Object props = Qnil; | 2111 Lisp_Object props = Qnil; |
2108 struct Lisp_Event *e; | 2112 Lisp_Event *e; |
2109 struct gcpro gcpro1; | 2113 struct gcpro gcpro1; |
2110 | 2114 |
2111 CHECK_LIVE_EVENT (event); | 2115 CHECK_LIVE_EVENT (event); |
2112 e = XEVENT (event); | 2116 e = XEVENT (event); |
2113 GCPRO1 (props); | 2117 GCPRO1 (props); |