Mercurial > hg > xemacs-beta
comparison src/event-stream.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 | 9d177e8d4150 |
children | abe6d1db359e |
comparison
equal
deleted
inserted
replaced
439:357dd071b03c | 440:8de8e3f6228a |
---|---|
506 { | 506 { |
507 return event_stream && event_stream->event_pending_p (user); | 507 return event_stream && event_stream->event_pending_p (user); |
508 } | 508 } |
509 | 509 |
510 static int | 510 static int |
511 maybe_read_quit_event (struct Lisp_Event *event) | 511 maybe_read_quit_event (Lisp_Event *event) |
512 { | 512 { |
513 /* A C-g that came from `sigint_happened' will always come from the | 513 /* A C-g that came from `sigint_happened' will always come from the |
514 controlling terminal. If that doesn't exist, however, then the | 514 controlling terminal. If that doesn't exist, however, then the |
515 user manually sent us a SIGINT, and we pretend the C-g came from | 515 user manually sent us a SIGINT, and we pretend the C-g came from |
516 the selected console. */ | 516 the selected console. */ |
533 } | 533 } |
534 return 0; | 534 return 0; |
535 } | 535 } |
536 | 536 |
537 void | 537 void |
538 event_stream_next_event (struct Lisp_Event *event) | 538 event_stream_next_event (Lisp_Event *event) |
539 { | 539 { |
540 Lisp_Object event_obj; | 540 Lisp_Object event_obj; |
541 | 541 |
542 check_event_stream_ok (EVENT_STREAM_READ); | 542 check_event_stream_ok (EVENT_STREAM_READ); |
543 | 543 |
577 #endif | 577 #endif |
578 maybe_kbd_translate (event_obj); | 578 maybe_kbd_translate (event_obj); |
579 } | 579 } |
580 | 580 |
581 void | 581 void |
582 event_stream_handle_magic_event (struct Lisp_Event *event) | 582 event_stream_handle_magic_event (Lisp_Event *event) |
583 { | 583 { |
584 check_event_stream_ok (EVENT_STREAM_READ); | 584 check_event_stream_ok (EVENT_STREAM_READ); |
585 event_stream->handle_magic_event_cb (event); | 585 event_stream->handle_magic_event_cb (event); |
586 } | 586 } |
587 | 587 |
620 con->input_enabled = 0; | 620 con->input_enabled = 0; |
621 } | 621 } |
622 } | 622 } |
623 | 623 |
624 void | 624 void |
625 event_stream_select_process (struct Lisp_Process *proc) | 625 event_stream_select_process (Lisp_Process *proc) |
626 { | 626 { |
627 check_event_stream_ok (EVENT_STREAM_PROCESS); | 627 check_event_stream_ok (EVENT_STREAM_PROCESS); |
628 if (!get_process_selected_p (proc)) | 628 if (!get_process_selected_p (proc)) |
629 { | 629 { |
630 event_stream->select_process_cb (proc); | 630 event_stream->select_process_cb (proc); |
631 set_process_selected_p (proc, 1); | 631 set_process_selected_p (proc, 1); |
632 } | 632 } |
633 } | 633 } |
634 | 634 |
635 void | 635 void |
636 event_stream_unselect_process (struct Lisp_Process *proc) | 636 event_stream_unselect_process (Lisp_Process *proc) |
637 { | 637 { |
638 check_event_stream_ok (EVENT_STREAM_PROCESS); | 638 check_event_stream_ok (EVENT_STREAM_PROCESS); |
639 if (get_process_selected_p (proc)) | 639 if (get_process_selected_p (proc)) |
640 { | 640 { |
641 event_stream->unselect_process_cb (proc); | 641 event_stream->unselect_process_cb (proc); |
795 XEVENT (event)->event.key.modifiers = 0; | 795 XEVENT (event)->event.key.modifiers = 0; |
796 did_translate = 1; | 796 did_translate = 1; |
797 } | 797 } |
798 else if (CHARP (traduit)) | 798 else if (CHARP (traduit)) |
799 { | 799 { |
800 struct Lisp_Event ev2; | 800 Lisp_Event ev2; |
801 | 801 |
802 /* This used to call Fcharacter_to_event() directly into EVENT, | 802 /* This used to call Fcharacter_to_event() directly into EVENT, |
803 but that can eradicate timestamps and other such stuff. | 803 but that can eradicate timestamps and other such stuff. |
804 This way is safer. */ | 804 This way is safer. */ |
805 zero_event (&ev2); | 805 zero_event (&ev2); |
1104 static Lisp_Object Vtimeout_free_list; | 1104 static Lisp_Object Vtimeout_free_list; |
1105 | 1105 |
1106 static Lisp_Object | 1106 static Lisp_Object |
1107 mark_timeout (Lisp_Object obj) | 1107 mark_timeout (Lisp_Object obj) |
1108 { | 1108 { |
1109 struct Lisp_Timeout *tm = XTIMEOUT (obj); | 1109 Lisp_Timeout *tm = XTIMEOUT (obj); |
1110 mark_object (tm->function); | 1110 mark_object (tm->function); |
1111 return tm->object; | 1111 return tm->object; |
1112 } | 1112 } |
1113 | 1113 |
1114 /* Should never, ever be called. (except by an external debugger) */ | 1114 /* Should never, ever be called. (except by an external debugger) */ |
1115 static void | 1115 static void |
1116 print_timeout (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) | 1116 print_timeout (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) |
1117 { | 1117 { |
1118 CONST struct Lisp_Timeout *t = XTIMEOUT (obj); | 1118 CONST Lisp_Timeout *t = XTIMEOUT (obj); |
1119 char buf[64]; | 1119 char buf[64]; |
1120 | 1120 |
1121 sprintf (buf, "#<INTERNAL OBJECT (XEmacs bug?) (timeout) 0x%lx>", | 1121 sprintf (buf, "#<INTERNAL OBJECT (XEmacs bug?) (timeout) 0x%lx>", |
1122 (unsigned long) t); | 1122 (unsigned long) t); |
1123 write_c_string (buf, printcharfun); | 1123 write_c_string (buf, printcharfun); |
1124 } | 1124 } |
1125 | 1125 |
1126 static const struct lrecord_description timeout_description[] = { | 1126 static const struct lrecord_description timeout_description[] = { |
1127 { XD_LISP_OBJECT, offsetof(struct Lisp_Timeout, function), 2 }, | 1127 { XD_LISP_OBJECT, offsetof (Lisp_Timeout, function) }, |
1128 { XD_LISP_OBJECT, offsetof (Lisp_Timeout, object) }, | |
1128 { XD_END } | 1129 { XD_END } |
1129 }; | 1130 }; |
1130 | 1131 |
1131 DEFINE_LRECORD_IMPLEMENTATION ("timeout", timeout, | 1132 DEFINE_LRECORD_IMPLEMENTATION ("timeout", timeout, |
1132 mark_timeout, print_timeout, | 1133 mark_timeout, print_timeout, |
1133 0, 0, 0, timeout_description, struct Lisp_Timeout); | 1134 0, 0, 0, timeout_description, Lisp_Timeout); |
1134 | 1135 |
1135 /* Generate a timeout and return its ID. */ | 1136 /* Generate a timeout and return its ID. */ |
1136 | 1137 |
1137 int | 1138 int |
1138 event_stream_generate_wakeup (unsigned int milliseconds, | 1139 event_stream_generate_wakeup (unsigned int milliseconds, |
1139 unsigned int vanilliseconds, | 1140 unsigned int vanilliseconds, |
1140 Lisp_Object function, Lisp_Object object, | 1141 Lisp_Object function, Lisp_Object object, |
1141 int async_p) | 1142 int async_p) |
1142 { | 1143 { |
1143 Lisp_Object op = allocate_managed_lcrecord (Vtimeout_free_list); | 1144 Lisp_Object op = allocate_managed_lcrecord (Vtimeout_free_list); |
1144 struct Lisp_Timeout *timeout = XTIMEOUT (op); | 1145 Lisp_Timeout *timeout = XTIMEOUT (op); |
1145 EMACS_TIME current_time; | 1146 EMACS_TIME current_time; |
1146 EMACS_TIME interval; | 1147 EMACS_TIME interval; |
1147 | 1148 |
1148 timeout->id = timeout_id_tick++; | 1149 timeout->id = timeout_id_tick++; |
1149 timeout->resignal_msecs = vanilliseconds; | 1150 timeout->resignal_msecs = vanilliseconds; |
1188 static int | 1189 static int |
1189 event_stream_resignal_wakeup (int interval_id, int async_p, | 1190 event_stream_resignal_wakeup (int interval_id, int async_p, |
1190 Lisp_Object *function, Lisp_Object *object) | 1191 Lisp_Object *function, Lisp_Object *object) |
1191 { | 1192 { |
1192 Lisp_Object op = Qnil, rest; | 1193 Lisp_Object op = Qnil, rest; |
1193 struct Lisp_Timeout *timeout; | 1194 Lisp_Timeout *timeout; |
1194 Lisp_Object *timeout_list; | 1195 Lisp_Object *timeout_list; |
1195 struct gcpro gcpro1; | 1196 struct gcpro gcpro1; |
1196 int id; | 1197 int id; |
1197 | 1198 |
1198 GCPRO1 (op); /* just in case ... because it's removed from the list | 1199 GCPRO1 (op); /* just in case ... because it's removed from the list |
1261 } | 1262 } |
1262 | 1263 |
1263 void | 1264 void |
1264 event_stream_disable_wakeup (int id, int async_p) | 1265 event_stream_disable_wakeup (int id, int async_p) |
1265 { | 1266 { |
1266 struct Lisp_Timeout *timeout = 0; | 1267 Lisp_Timeout *timeout = 0; |
1267 Lisp_Object rest; | 1268 Lisp_Object rest; |
1268 Lisp_Object *timeout_list; | 1269 Lisp_Object *timeout_list; |
1269 | 1270 |
1270 if (async_p) | 1271 if (async_p) |
1271 timeout_list = &pending_async_timeout_list; | 1272 timeout_list = &pending_async_timeout_list; |
1296 } | 1297 } |
1297 | 1298 |
1298 static int | 1299 static int |
1299 event_stream_wakeup_pending_p (int id, int async_p) | 1300 event_stream_wakeup_pending_p (int id, int async_p) |
1300 { | 1301 { |
1301 struct Lisp_Timeout *timeout; | 1302 Lisp_Timeout *timeout; |
1302 Lisp_Object rest; | 1303 Lisp_Object rest; |
1303 Lisp_Object timeout_list; | 1304 Lisp_Object timeout_list; |
1304 int found = 0; | 1305 int found = 0; |
1305 | 1306 |
1306 | 1307 |
2013 Fdeallocate_event (event); | 2014 Fdeallocate_event (event); |
2014 DEBUG_PRINT_EMACS_EVENT ("command event queue", target_event); | 2015 DEBUG_PRINT_EMACS_EVENT ("command event queue", target_event); |
2015 } | 2016 } |
2016 else | 2017 else |
2017 { | 2018 { |
2018 struct Lisp_Event *e = XEVENT (target_event); | 2019 Lisp_Event *e = XEVENT (target_event); |
2019 | 2020 |
2020 /* The command_event_queue was empty. Wait for an event. */ | 2021 /* The command_event_queue was empty. Wait for an event. */ |
2021 event_stream_next_event (e); | 2022 event_stream_next_event (e); |
2022 /* If this was a timeout, then we need to extract some data | 2023 /* If this was a timeout, then we need to extract some data |
2023 out of the returned closure and might need to resignal | 2024 out of the returned closure and might need to resignal |
3035 return; | 3036 return; |
3036 } | 3037 } |
3037 | 3038 |
3038 case timeout_event: | 3039 case timeout_event: |
3039 { | 3040 { |
3040 struct Lisp_Event *e = XEVENT (event); | 3041 Lisp_Event *e = XEVENT (event); |
3041 if (!NILP (e->event.timeout.function)) | 3042 if (!NILP (e->event.timeout.function)) |
3042 call1 (e->event.timeout.function, | 3043 call1 (e->event.timeout.function, |
3043 e->event.timeout.object); | 3044 e->event.timeout.object); |
3044 return; | 3045 return; |
3045 } | 3046 } |
3767 Emchar c = 0; | 3768 Emchar c = 0; |
3768 if ((key->modifiers & MOD_SHIFT) | 3769 if ((key->modifiers & MOD_SHIFT) |
3769 || (CHAR_OR_CHAR_INTP (key->keysym) | 3770 || (CHAR_OR_CHAR_INTP (key->keysym) |
3770 && ((c = XCHAR_OR_CHAR_INT (key->keysym)), c >= 'A' && c <= 'Z'))) | 3771 && ((c = XCHAR_OR_CHAR_INT (key->keysym)), c >= 'A' && c <= 'Z'))) |
3771 { | 3772 { |
3772 struct Lisp_Event terminal_copy = *XEVENT (terminal); | 3773 Lisp_Event terminal_copy = *XEVENT (terminal); |
3773 | 3774 |
3774 if (key->modifiers & MOD_SHIFT) | 3775 if (key->modifiers & MOD_SHIFT) |
3775 key->modifiers &= (~ MOD_SHIFT); | 3776 key->modifiers &= (~ MOD_SHIFT); |
3776 else | 3777 else |
3777 key->keysym = make_char (c + 'a' - 'A'); | 3778 key->keysym = make_char (c + 'a' - 'A'); |
4160 Lisp_Object recent = command_builder->most_current_event; | 4161 Lisp_Object recent = command_builder->most_current_event; |
4161 | 4162 |
4162 if (EVENTP (recent) | 4163 if (EVENTP (recent) |
4163 && event_matches_key_specifier_p (XEVENT (recent), Vmeta_prefix_char)) | 4164 && event_matches_key_specifier_p (XEVENT (recent), Vmeta_prefix_char)) |
4164 { | 4165 { |
4165 struct Lisp_Event *e; | 4166 Lisp_Event *e; |
4166 /* When we see a sequence like "ESC x", pretend we really saw "M-x". | 4167 /* When we see a sequence like "ESC x", pretend we really saw "M-x". |
4167 DoubleThink the recent-keys and this-command-keys as well. */ | 4168 DoubleThink the recent-keys and this-command-keys as well. */ |
4168 | 4169 |
4169 /* Modify the previous most-recently-pushed event on the command | 4170 /* Modify the previous most-recently-pushed event on the command |
4170 builder to be a copy of this one with the meta-bit set instead of | 4171 builder to be a copy of this one with the meta-bit set instead of |
4227 else | 4228 else |
4228 maybe_echo_keys (command_builder, 0); | 4229 maybe_echo_keys (command_builder, 0); |
4229 } | 4230 } |
4230 else if (!NILP (Vquit_flag)) { | 4231 else if (!NILP (Vquit_flag)) { |
4231 Lisp_Object quit_event = Fmake_event(Qnil, Qnil); | 4232 Lisp_Object quit_event = Fmake_event(Qnil, Qnil); |
4232 struct Lisp_Event *e = XEVENT (quit_event); | 4233 Lisp_Event *e = XEVENT (quit_event); |
4233 /* if quit happened during menu acceleration, pretend we read it */ | 4234 /* if quit happened during menu acceleration, pretend we read it */ |
4234 struct console *con = XCONSOLE (Fselected_console ()); | 4235 struct console *con = XCONSOLE (Fselected_console ()); |
4235 int ch = CONSOLE_QUIT_CHAR (con); | 4236 int ch = CONSOLE_QUIT_CHAR (con); |
4236 | 4237 |
4237 character_to_event (ch, e, con, 1, 1); | 4238 character_to_event (ch, e, con, 1, 1); |
4398 Lisp_Object win = Fselected_window (Qnil); | 4399 Lisp_Object win = Fselected_window (Qnil); |
4399 | 4400 |
4400 #if 0 | 4401 #if 0 |
4401 /* If the last command deleted the frame, `win' might be nil. | 4402 /* If the last command deleted the frame, `win' might be nil. |
4402 It seems safest to do nothing in this case. */ | 4403 It seems safest to do nothing in this case. */ |
4403 /* ### This doesn't really fix the problem, | 4404 /* #### This doesn't really fix the problem, |
4404 if delete-frame is called by some hook */ | 4405 if delete-frame is called by some hook */ |
4405 if (NILP (win)) | 4406 if (NILP (win)) |
4406 return; | 4407 return; |
4407 #endif | 4408 #endif |
4408 | 4409 |
4477 */ | 4478 */ |
4478 (event)) | 4479 (event)) |
4479 { | 4480 { |
4480 /* This function can GC */ | 4481 /* This function can GC */ |
4481 struct command_builder *command_builder; | 4482 struct command_builder *command_builder; |
4482 struct Lisp_Event *ev; | 4483 Lisp_Event *ev; |
4483 Lisp_Object console; | 4484 Lisp_Object console; |
4484 Lisp_Object channel; | 4485 Lisp_Object channel; |
4485 | 4486 |
4486 CHECK_LIVE_EVENT (event); | 4487 CHECK_LIVE_EVENT (event); |
4487 ev = XEVENT (event); | 4488 ev = XEVENT (event); |
4974 reinit_vars_of_event_stream (void) | 4975 reinit_vars_of_event_stream (void) |
4975 { | 4976 { |
4976 recent_keys_ring_index = 0; | 4977 recent_keys_ring_index = 0; |
4977 recent_keys_ring_size = 100; | 4978 recent_keys_ring_size = 100; |
4978 num_input_chars = 0; | 4979 num_input_chars = 0; |
4979 Vtimeout_free_list = make_lcrecord_list (sizeof (struct Lisp_Timeout), | 4980 Vtimeout_free_list = make_lcrecord_list (sizeof (Lisp_Timeout), |
4980 &lrecord_timeout); | 4981 &lrecord_timeout); |
4981 staticpro_nodump (&Vtimeout_free_list); | 4982 staticpro_nodump (&Vtimeout_free_list); |
4982 the_low_level_timeout_blocktype = | 4983 the_low_level_timeout_blocktype = |
4983 Blocktype_new (struct low_level_timeout_blocktype); | 4984 Blocktype_new (struct low_level_timeout_blocktype); |
4984 something_happened = 0; | 4985 something_happened = 0; |